1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-12-23 05:34:56 +00:00

Merge pull request #153 from actions/start-v2

updated tests
This commit is contained in:
Bryan MacFarlane 2020-05-02 11:41:20 -04:00 committed by GitHub
commit ed3a918d25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 4784 additions and 953 deletions

21
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests on Nix",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}

View file

@ -1,31 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`installer 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`] = `
"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`] = `
"//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`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=true"
`;
exports[`installer tests Sets up npmrc for npmjs 1`] = `
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=false"
`;

View file

@ -1,22 +1,26 @@
import * as io from '@actions/io'; import os = require('os');
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as auth from '../src/authutil'; import * as auth from '../src/authutil';
let rcFile: string; let rcFile: string;
describe('installer tests', () => { describe('authutil tests', () => {
const _runnerDir = path.join(__dirname, 'runner');
let cnSpy: jest.SpyInstance;
let logSpy: jest.SpyInstance;
let dbgSpy: jest.SpyInstance;
beforeAll(async () => { beforeAll(async () => {
const tempDir = path.join( const randPath = path.join(
__dirname, Math.random()
'runner', .toString(36)
path.join( .substring(7)
Math.random()
.toString(36)
.substring(7)
),
'temp'
); );
const tempDir = path.join(_runnerDir, randPath, 'temp');
await io.rmRF(tempDir); await io.rmRF(tempDir);
await io.mkdirP(tempDir); await io.mkdirP(tempDir);
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo'; process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
@ -24,44 +28,96 @@ describe('installer tests', () => {
rcFile = path.join(tempDir, '.npmrc'); rcFile = path.join(tempDir, '.npmrc');
}, 100000); }, 100000);
beforeEach(() => { beforeEach(async () => {
if (fs.existsSync(rcFile)) { await io.rmRF(rcFile);
fs.unlinkSync(rcFile); // if (fs.existsSync(rcFile)) {
} // fs.unlinkSync(rcFile);
// }
process.env['INPUT_SCOPE'] = ''; process.env['INPUT_SCOPE'] = '';
});
// writes
cnSpy = jest.spyOn(process.stdout, 'write');
logSpy = jest.spyOn(console, 'log');
dbgSpy = jest.spyOn(core, 'debug');
cnSpy.mockImplementation(line => {
// uncomment to debug
// process.stderr.write('write:' + line + '\n');
});
logSpy.mockImplementation(line => {
// uncomment to debug
// process.stderr.write('log:' + line + '\n');
});
dbgSpy.mockImplementation(msg => {
// uncomment to see debug output
// process.stderr.write(msg + '\n');
});
}, 100000);
function dbg(message: string) {
process.stderr.write('dbg::' + message + '::\n');
}
afterAll(async () => {
if (_runnerDir) {
await io.rmRF(_runnerDir);
}
}, 100000);
function readRcFile(rcFile: string) {
let rc = {};
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
for (const line of contents.split(os.EOL)) {
let parts = line.split('=');
if (parts.length == 2) {
rc[parts[0].trim()] = parts[1].trim();
}
}
return rc;
}
it('Sets up npmrc for npmjs', async () => { it('Sets up npmrc for npmjs', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false'); await auth.configAuthentication('https://registry.npmjs.org/', 'false');
expect(fs.existsSync(rcFile)).toBe(true);
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); expect(fs.statSync(rcFile)).toBeDefined();
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
let rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Appends trailing slash to registry', async () => { it('Appends trailing slash to registry', async () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.statSync(rcFile)).toBeDefined();
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); let rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Configures scoped npm registries', async () => { it('Configures scoped npm registries', async () => {
process.env['INPUT_SCOPE'] = 'myScope'; process.env['INPUT_SCOPE'] = 'myScope';
await auth.configAuthentication('https://registry.npmjs.org', 'false'); await auth.configAuthentication('https://registry.npmjs.org', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.statSync(rcFile)).toBeDefined();
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); let rc = readRcFile(rcFile);
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
}); });
it('Automatically configures GPR scope', async () => { it('Automatically configures GPR scope', async () => {
await auth.configAuthentication('npm.pkg.github.com', 'false'); await auth.configAuthentication('npm.pkg.github.com', 'false');
expect(fs.existsSync(rcFile)).toBe(true); expect(fs.statSync(rcFile)).toBeDefined();
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); let rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false');
}); });
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.existsSync(rcFile)).toBe(true); expect(fs.statSync(rcFile)).toBeDefined();
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot(); let rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('true');
}); });
}); });

View file

@ -0,0 +1,770 @@
[
{
"version": "v14.1.0",
"date": "2020-04-29",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "8.1.307.31",
"uv": "1.37.0",
"zlib": "1.2.11",
"openssl": "1.1.1g",
"modules": "83",
"lts": false,
"security": false
},
{
"version": "v14.0.0",
"date": "2020-04-21",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "8.1.307.30",
"uv": "1.37.0",
"zlib": "1.2.11",
"openssl": "1.1.1f",
"modules": "83",
"lts": false,
"security": false
},
{
"version": "v13.14.0",
"date": "2020-04-28",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "7.9.317.25",
"uv": "1.37.0",
"zlib": "1.2.11",
"openssl": "1.1.1g",
"modules": "79",
"lts": false,
"security": false
},
{
"version": "v13.13.0",
"date": "2020-04-14",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "7.9.317.25",
"uv": "1.35.0",
"zlib": "1.2.11",
"openssl": "1.1.1f",
"modules": "79",
"lts": false,
"security": false
},
{
"version": "v12.16.3",
"date": "2020-04-28",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "7.8.279.23",
"uv": "1.34.2",
"zlib": "1.2.11",
"openssl": "1.1.1g",
"modules": "72",
"lts": "Erbium",
"security": false
},
{
"version": "v12.16.2",
"date": "2020-04-08",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "7.8.279.23",
"uv": "1.34.2",
"zlib": "1.2.11",
"openssl": "1.1.1e",
"modules": "72",
"lts": "Erbium",
"security": false
},
{
"version": "v12.1.0",
"date": "2019-04-29",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.9.0",
"v8": "7.4.288.21",
"uv": "1.28.0",
"zlib": "1.2.11",
"openssl": "1.1.1b",
"modules": "72",
"lts": false,
"security": false
},
{
"version": "v11.15.0",
"date": "2019-04-30",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.7.0",
"v8": "7.0.276.38",
"uv": "1.27.0",
"zlib": "1.2.11",
"openssl": "1.1.1b",
"modules": "67",
"lts": false,
"security": false
},
{
"version": "v10.20.1",
"date": "2020-04-10",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "6.8.275.32",
"uv": "1.34.2",
"zlib": "1.2.11",
"openssl": "1.1.1e",
"modules": "64",
"lts": "Dubnium",
"security": false
},
{
"version": "v10.20.0",
"date": "2020-03-24",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.14.4",
"v8": "6.8.275.32",
"uv": "1.34.2",
"zlib": "1.2.11",
"openssl": "1.1.1e",
"modules": "64",
"lts": "Dubnium",
"security": false
},
{
"version": "v9.11.2",
"date": "2018-06-12",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "5.6.0",
"v8": "6.2.414.46",
"uv": "1.19.2",
"zlib": "1.2.11",
"openssl": "1.0.2o",
"modules": "59",
"lts": false,
"security": false
},
{
"version": "v9.11.1",
"date": "2018-04-05",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "5.6.0",
"v8": "6.2.414.46",
"uv": "1.19.2",
"zlib": "1.2.11",
"openssl": "1.0.2o",
"modules": "59",
"lts": false,
"security": false
},
{
"version": "v8.17.0",
"date": "2019-12-17",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.13.4",
"v8": "6.2.414.78",
"uv": "1.23.2",
"zlib": "1.2.11",
"openssl": "1.0.2s",
"modules": "57",
"lts": "Carbon",
"security": true
},
{
"version": "v8.16.2",
"date": "2019-10-08",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "6.4.1",
"v8": "6.2.414.78",
"uv": "1.23.2",
"zlib": "1.2.11",
"openssl": "1.0.2s",
"modules": "57",
"lts": "Carbon",
"security": false
},
{
"version": "v7.10.1",
"date": "2017-07-11",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "4.2.0",
"v8": "5.5.372.43",
"uv": "1.11.0",
"zlib": "1.2.11",
"openssl": "1.0.2k",
"modules": "51",
"lts": false,
"security": true
},
{
"version": "v7.10.0",
"date": "2017-05-02",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "4.2.0",
"v8": "5.5.372.43",
"uv": "1.11.0",
"zlib": "1.2.11",
"openssl": "1.0.2k",
"modules": "51",
"lts": false,
"security": false
},
{
"version": "v6.17.1",
"date": "2019-04-03",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "3.10.10",
"v8": "5.1.281.111",
"uv": "1.16.1",
"zlib": "1.2.11",
"openssl": "1.0.2r",
"modules": "48",
"lts": "Boron",
"security": false
},
{
"version": "v6.17.0",
"date": "2019-02-28",
"files": [
"aix-ppc64",
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "3.10.10",
"v8": "5.1.281.111",
"uv": "1.16.1",
"zlib": "1.2.11",
"openssl": "1.0.2r",
"modules": "48",
"lts": "Boron",
"security": true
},
{
"version": "v5.12.0",
"date": "2016-06-23",
"files": [
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-exe",
"win-x64-msi",
"win-x86-exe",
"win-x86-msi"
],
"npm": "3.8.6",
"v8": "4.6.85.32",
"uv": "1.8.0",
"zlib": "1.2.8",
"openssl": "1.0.2h",
"modules": "47",
"lts": false,
"security": false
},
{
"version": "v4.9.1",
"date": "2018-03-29",
"files": [
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "2.15.11",
"v8": "4.5.103.53",
"uv": "1.9.1",
"zlib": "1.2.11",
"openssl": "1.0.2o",
"modules": "46",
"lts": "Argon",
"security": false
},
{
"version": "v4.9.0",
"date": "2018-03-28",
"files": [
"headers",
"linux-arm64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-7z",
"win-x64-exe",
"win-x64-msi",
"win-x64-zip",
"win-x86-7z",
"win-x86-exe",
"win-x86-msi",
"win-x86-zip"
],
"npm": "2.15.11",
"v8": "4.5.103.53",
"uv": "1.9.1",
"zlib": "1.2.11",
"openssl": "1.0.2o",
"modules": "46",
"lts": "Argon",
"security": true
},
{
"version": "v0.12.18",
"date": "2017-02-22",
"files": [
"headers",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"osx-x86-tar",
"src",
"sunos-x86",
"win-x64-exe",
"win-x86-exe",
"win-x86-msi"
],
"npm": "2.15.11",
"v8": "3.28.71.20",
"uv": "1.6.1",
"zlib": "1.2.8",
"openssl": "1.0.1u",
"modules": "14",
"lts": false,
"security": false
},
{
"version": "v0.12.17",
"date": "2016-10-18",
"files": [
"headers",
"linux-x64",
"linux-x86",
"osx-x64-pkg",
"osx-x64-tar",
"osx-x86-tar",
"src",
"sunos-x64",
"sunos-x86",
"win-x64-exe",
"win-x86-exe",
"win-x86-msi"
],
"npm": "2.15.1",
"v8": "3.28.71.19",
"uv": "1.6.1",
"zlib": "1.2.8",
"openssl": "1.0.1u",
"modules": "14",
"lts": false,
"security": true
}
]

View file

@ -0,0 +1,152 @@
[
{
"version": "14.0.0",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200423.30",
"files": [
{
"filename": "node-14.0.0-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-darwin-x64.tar.gz"
},
{
"filename": "node-14.0.0-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz"
},
{
"filename": "node-14.0.0-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-win32-x64.zip"
}
]
},
{
"version": "13.13.0",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200423.29",
"files": [
{
"filename": "node-13.13.0-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-darwin-x64.tar.gz"
},
{
"filename": "node-13.13.0-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-linux-x64.tar.gz"
},
{
"filename": "node-13.13.0-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-win32-x64.zip"
}
]
},
{
"version": "12.16.2",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200423.28",
"files": [
{
"filename": "node-12.16.2-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-darwin-x64.tar.gz"
},
{
"filename": "node-12.16.2-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz"
},
{
"filename": "node-12.16.2-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-win32-x64.zip"
}
]
},
{
"version": "10.20.1",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200423.27",
"files": [
{
"filename": "node-10.20.1-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-darwin-x64.tar.gz"
},
{
"filename": "node-10.20.1-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-linux-x64.tar.gz"
},
{
"filename": "node-10.20.1-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-win32-x64.zip"
}
]
},
{
"version": "8.17.0",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200423.26",
"files": [
{
"filename": "node-8.17.0-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-darwin-x64.tar.gz"
},
{
"filename": "node-8.17.0-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-linux-x64.tar.gz"
},
{
"filename": "node-8.17.0-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-win32-x64.zip"
}
]
},
{
"version": "6.17.1",
"stable": true,
"release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200423.25",
"files": [
{
"filename": "node-6.17.1-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-darwin-x64.tar.gz"
},
{
"filename": "node-6.17.1-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-linux-x64.tar.gz"
},
{
"filename": "node-6.17.1-win32-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-win32-x64.zip"
}
]
}
]

View file

@ -1,123 +1,336 @@
import * as core from '@actions/core';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as fs from 'fs'; import fs from 'fs';
import * as os from 'os'; import cp from 'child_process';
import * as path from 'path'; import osm = require('os');
import * as installer from '../src/installer'; import path from 'path';
import * as main from '../src/main';
import * as im from '../src/installer';
import * as auth from '../src/authutil';
const isWindows = process.platform === 'win32'; let nodeTestManifest = require('./data/versions-manifest.json');
let toolDir: string; let nodeTestDist = require('./data/node-dist-index.json');
describe('installer tests', () => { // let matchers = require('../matchers.json');
beforeAll(async () => { // let matcherPattern = matchers.problemMatcher[0].pattern[0];
toolDir = path.join( // let matcherRegExp = new RegExp(matcherPattern.regexp);
__dirname,
'runner', describe('setup-node', () => {
path.join( let inputs = {} as any;
Math.random() let os = {} as any;
.toString(36)
.substring(7) let inSpy: jest.SpyInstance;
), let findSpy: jest.SpyInstance;
'tools' let cnSpy: jest.SpyInstance;
let logSpy: jest.SpyInstance;
let getManifestSpy: jest.SpyInstance;
let getDistSpy: jest.SpyInstance;
let platSpy: jest.SpyInstance;
let archSpy: jest.SpyInstance;
let dlSpy: jest.SpyInstance;
let exSpy: jest.SpyInstance;
let cacheSpy: jest.SpyInstance;
let dbgSpy: jest.SpyInstance;
let whichSpy: jest.SpyInstance;
let existsSpy: jest.SpyInstance;
let mkdirpSpy: jest.SpyInstance;
let execSpy: jest.SpyInstance;
let authSpy: jest.SpyInstance;
beforeEach(() => {
// @actions/core
inputs = {};
inSpy = jest.spyOn(core, 'getInput');
inSpy.mockImplementation(name => inputs[name]);
// node
os = {};
platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => os['platform']);
archSpy = jest.spyOn(osm, 'arch');
archSpy.mockImplementation(() => os['arch']);
execSpy = jest.spyOn(cp, 'execSync');
// @actions/tool-cache
findSpy = jest.spyOn(tc, 'find');
dlSpy = jest.spyOn(tc, 'downloadTool');
exSpy = jest.spyOn(tc, 'extractTar');
cacheSpy = jest.spyOn(tc, 'cacheDir');
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
// io
whichSpy = jest.spyOn(io, 'which');
existsSpy = jest.spyOn(fs, 'existsSync');
mkdirpSpy = jest.spyOn(io, 'mkdirP');
// disable authentication portion for installer tests
authSpy = jest.spyOn(auth, 'configAuthentication');
authSpy.mockImplementation(() => {});
// gets
getManifestSpy.mockImplementation(
() => <tc.IToolRelease[]>nodeTestManifest
); );
const tempDir = path.join( getDistSpy.mockImplementation(() => <im.INodeVersion>nodeTestDist);
__dirname,
'runner', // writes
path.join( cnSpy = jest.spyOn(process.stdout, 'write');
Math.random() logSpy = jest.spyOn(console, 'log');
.toString(36) dbgSpy = jest.spyOn(core, 'debug');
.substring(7) cnSpy.mockImplementation(line => {
), // uncomment to debug
'temp' // process.stderr.write('write:' + line + '\n');
});
logSpy.mockImplementation(line => {
// uncomment to debug
// process.stderr.write('log:' + line + '\n');
});
dbgSpy.mockImplementation(msg => {
// uncomment to see debug output
// process.stderr.write(msg + '\n');
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
//jest.restoreAllMocks();
});
afterAll(async () => {}, 100000);
//--------------------------------------------------
// Manifest find tests
//--------------------------------------------------
it('can mock manifest versions', async () => {
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
'actions',
'node-versions',
'mocktoken'
); );
await io.rmRF(toolDir); expect(versions).toBeDefined();
await io.rmRF(tempDir); expect(versions?.length).toBe(6);
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
}, 100000);
it('Acquires version of node if no matching version is installed', async () => {
await installer.getNode('10.16.0');
const nodeDir = path.join(toolDir, 'node', '10.16.0', os.arch());
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (isWindows) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
if (isWindows) {
it('Falls back to backup location if first one doesnt contain correct version', async () => {
await installer.getNode('5.10.1');
const nodeDir = path.join(toolDir, 'node', '5.10.1', os.arch());
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
}, 100000);
it('Falls back to third location if second one doesnt contain correct version', async () => {
await installer.getNode('0.12.18');
const nodeDir = path.join(toolDir, 'node', '0.12.18', os.arch());
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
}, 100000);
}
it('Throws if no location contains correct node version', async () => {
let thrown = false;
try {
await installer.getNode('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
}); });
it('Acquires version of node with long paths', async () => { it('can mock dist versions', async () => {
const toolpath = await installer.getNode('8.8.1'); let versions: im.INodeVersion[] = await im.getVersionsFromDist();
const nodeDir = path.join(toolDir, 'node', '8.8.1', os.arch()); expect(versions).toBeDefined();
expect(versions?.length).toBe(23);
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
if (isWindows) {
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
}
}, 100000);
it('Uses version of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch());
await io.mkdirP(nodeDir);
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getNode('250.0.0');
return;
}); });
it('Doesnt use version of node that was only partially installed in cache', async () => { it('can find 12.16.2 from manifest on osx', async () => {
const nodeDir: string = path.join(toolDir, 'node', '251.0.0', os.arch()); os.platform = 'darwin';
await io.mkdirP(nodeDir); os.arch = 'x64';
let thrown = false; let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
try { 'actions',
// This will throw if it doesn't find it in the cache (because no such version exists) 'node-versions',
await installer.getNode('251.0.0'); 'mocktoken'
} catch { );
thrown = true; expect(versions).toBeDefined();
} let match = await tc.findFromManifest('12.16.2', true, versions);
expect(thrown).toBe(true); expect(match).toBeDefined();
return; expect(match?.version).toBe('12.16.2');
}); });
it('Resolves semantic versions of node installed in cache', async () => { it('can find 12 from manifest on linux', async () => {
const nodeDir: string = path.join(toolDir, 'node', '252.0.0', os.arch()); os.platform = 'linux';
await io.mkdirP(nodeDir); os.arch = 'x64';
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
// These will throw if it doesn't find it in the cache (because no such version exists) 'actions',
await installer.getNode('252.0.0'); 'node-versions',
await installer.getNode('252'); 'mocktoken'
await installer.getNode('252.0'); );
expect(versions).toBeDefined();
let match = await tc.findFromManifest('12.16.2', true, versions);
expect(match).toBeDefined();
expect(match?.version).toBe('12.16.2');
});
it('can find 10 from manifest on windows', async () => {
os.platform = 'win32';
os.arch = 'x64';
let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
'actions',
'node-versions',
'mocktoken'
);
expect(versions).toBeDefined();
let match = await tc.findFromManifest('10', true, versions);
expect(match).toBeDefined();
expect(match?.version).toBe('10.20.1');
});
//--------------------------------------------------
// Found in cache tests
//--------------------------------------------------
it('finds version in cache with stable true', async () => {
inputs['node-version'] = '12';
inputs.stable = 'true';
let toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
});
it('finds version in cache with stable not supplied', async () => {
inputs['node-version'] = '12';
inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
});
it('finds version in cache and adds it to the path', async () => {
inputs['node-version'] = '12';
inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.16.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
let expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
});
it('handles unhandled find error and reports error', async () => {
let errMsg = 'unhandled error message';
inputs['node-version'] = '12';
findSpy.mockImplementation(() => {
throw new Error(errMsg);
});
await main.run();
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL);
});
it('downloads a version from a manifest match', async () => {
os.platform = 'linux';
os.arch = 'x64';
// a version which is in the manifest
let versionSpec = '12.16.2';
let resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
let expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
// ... but not in the local cache
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/12.16.2/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
await main.run();
let expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith(
`Acquiring ${resolvedVersion} from ${expectedUrl}`
);
expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${versionSpec}...`
);
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
});
it('falls back to a version from node dist', async () => {
os.platform = 'linux';
os.arch = 'x64';
// a version which is not in the manifest but is in node dist
let versionSpec = '11.15.0';
let resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
let expectedUrl =
'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz';
// ... but not in the local cache
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/11.11.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
await main.run();
let expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith(
'Not found in manifest. Falling back to download directly from Node'
);
expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${versionSpec}...`
);
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
});
it('does not find a version that does not exist', async () => {
os.platform = 'linux';
os.arch = 'x64';
let versionSpec = '9.99.9';
inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => '');
await main.run();
expect(logSpy).toHaveBeenCalledWith(
'Not found in manifest. Falling back to download directly from Node'
);
expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${versionSpec}...`
);
expect(cnSpy).toHaveBeenCalledWith(
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
);
});
it('reports a failed download', async () => {
let errMsg = 'unhandled download message';
os.platform = 'linux';
os.arch = 'x64';
// a version which is in the manifest
let versionSpec = '12.16.2';
let resolvedVersion = versionSpec;
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(() => {
throw new Error(errMsg);
});
await main.run();
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
}); });
}); });

191
dist/index.js vendored
View file

@ -4590,6 +4590,69 @@ function checkMode (stat, options) {
} }
/***/ }),
/***/ 198:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
const installer = __importStar(__webpack_require__(749));
const auth = __importStar(__webpack_require__(202));
const path = __importStar(__webpack_require__(622));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
let version = core.getInput('node-version');
if (!version) {
version = core.getInput('version');
}
console.log(`version: ${version}`);
if (version) {
let token = core.getInput('token');
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
yield installer.getNode(version, stable, token);
}
const registryUrl = core.getInput('registry-url');
const alwaysAuth = core.getInput('always-auth');
if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.run = run;
//# sourceMappingURL=main.js.map
/***/ }), /***/ }),
/***/ 202: /***/ 202:
@ -4652,7 +4715,7 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
// Export empty node_auth_token so npm doesn't complain about not being able to find it // Export empty node_auth_token so npm doesn't complain about not being able to find it
core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX');
} }
//# sourceMappingURL=authutil.js.map
/***/ }), /***/ }),
@ -4666,7 +4729,7 @@ module.exports = require("https");
/***/ 215: /***/ 215:
/***/ (function(module) { /***/ (function(module) {
module.exports = {"_args":[["@octokit/rest@16.38.1","/Users/bryan/Projects/setup-node"]],"_from":"@octokit/rest@16.38.1","_id":"@octokit/rest@16.38.1","_inBundle":false,"_integrity":"sha512-zyNFx+/Bd1EXt7LQjfrc6H4wryBQ/oDuZeZhGMBSFr1eMPFDmpEweFQR3R25zjKwBQpDY7L5GQO6A3XSaOfV1w==","_location":"/@octokit/rest","_phantomChildren":{"os-name":"3.1.0"},"_requested":{"type":"version","registry":true,"raw":"@octokit/rest@16.38.1","name":"@octokit/rest","escapedName":"@octokit%2frest","scope":"@octokit","rawSpec":"16.38.1","saveSpec":null,"fetchSpec":"16.38.1"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.38.1.tgz","_spec":"16.38.1","_where":"/Users/bryan/Projects/setup-node","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/rest.js/issues"},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"dependencies":{"@octokit/auth-token":"^2.4.0","@octokit/request":"^5.2.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"description":"GitHub REST API client for Node.js","devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/auth":"^1.1.1","@octokit/fixtures-server":"^5.0.6","@octokit/graphql":"^4.2.0","@types/node":"^13.1.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.1.0","cypress":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^3.0.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","mustache":"^4.0.0","nock":"^11.3.3","npm-run-all":"^4.1.2","nyc":"^15.0.0","prettier":"^1.14.2","proxy":"^1.0.0","semantic-release":"^16.0.0","sinon":"^8.0.0","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"files":["index.js","index.d.ts","lib","plugins"],"homepage":"https://github.com/octokit/rest.js#readme","keywords":["octokit","github","rest","api-client"],"license":"MIT","name":"@octokit/rest","nyc":{"ignore":["test"]},"publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/rest.js.git"},"scripts":{"build":"npm-run-all build:*","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","build:ts":"npm run -s update-endpoints:typescript","coverage":"nyc report --reporter=html && open coverage/index.html","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","lint":"prettier --check '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","lint:fix":"prettier --write '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","prebuild:browser":"mkdirp dist/","pretest":"npm run -s lint","prevalidate:ts":"npm run -s build:ts","start-fixtures-server":"octokit-fixtures-server","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","update-endpoints":"npm-run-all update-endpoints:*","update-endpoints:code":"node scripts/update-endpoints/code","update-endpoints:fetch-json":"node scripts/update-endpoints/fetch-json","update-endpoints:typescript":"node scripts/update-endpoints/typescript","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts"},"types":"index.d.ts","version":"16.38.1"}; module.exports = {"name":"@octokit/rest","version":"16.38.1","publishConfig":{"access":"public"},"description":"GitHub REST API client for Node.js","keywords":["octokit","github","rest","api-client"],"author":"Gregor Martynus (https://github.com/gr2m)","contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"repository":"https://github.com/octokit/rest.js","dependencies":{"@octokit/auth-token":"^2.4.0","@octokit/request":"^5.2.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/auth":"^1.1.1","@octokit/fixtures-server":"^5.0.6","@octokit/graphql":"^4.2.0","@types/node":"^13.1.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.1.0","cypress":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^3.0.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","mustache":"^4.0.0","nock":"^11.3.3","npm-run-all":"^4.1.2","nyc":"^15.0.0","prettier":"^1.14.2","proxy":"^1.0.0","semantic-release":"^16.0.0","sinon":"^8.0.0","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"types":"index.d.ts","scripts":{"coverage":"nyc report --reporter=html && open coverage/index.html","lint":"prettier --check '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","lint:fix":"prettier --write '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","pretest":"npm run -s lint","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","build":"npm-run-all build:*","build:ts":"npm run -s update-endpoints:typescript","prebuild:browser":"mkdirp dist/","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","update-endpoints":"npm-run-all update-endpoints:*","update-endpoints:fetch-json":"node scripts/update-endpoints/fetch-json","update-endpoints:code":"node scripts/update-endpoints/code","update-endpoints:typescript":"node scripts/update-endpoints/typescript","prevalidate:ts":"npm run -s build:ts","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","start-fixtures-server":"octokit-fixtures-server"},"license":"MIT","files":["index.js","index.d.ts","lib","plugins"],"nyc":{"ignore":["test"]},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.38.1.tgz","_integrity":"sha512-zyNFx+/Bd1EXt7LQjfrc6H4wryBQ/oDuZeZhGMBSFr1eMPFDmpEweFQR3R25zjKwBQpDY7L5GQO6A3XSaOfV1w==","_from":"@octokit/rest@16.38.1"};
/***/ }), /***/ }),
@ -6816,7 +6879,7 @@ function normalizePaginatedListResponse(octokit, url, response) {
/***/ 314: /***/ 314:
/***/ (function(module) { /***/ (function(module) {
module.exports = {"_args":[["@octokit/graphql@2.1.3","/Users/bryan/Projects/setup-node"]],"_from":"@octokit/graphql@2.1.3","_id":"@octokit/graphql@2.1.3","_inBundle":false,"_integrity":"sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==","_location":"/@octokit/graphql","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"@octokit/graphql@2.1.3","name":"@octokit/graphql","escapedName":"@octokit%2fgraphql","scope":"@octokit","rawSpec":"2.1.3","saveSpec":null,"fetchSpec":"2.1.3"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz","_spec":"2.1.3","_where":"/Users/bryan/Projects/setup-node","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/graphql.js/issues"},"bundlesize":[{"path":"./dist/octokit-graphql.min.js.gz","maxSize":"5KB"}],"dependencies":{"@octokit/request":"^5.0.0","universal-user-agent":"^2.0.3"},"description":"GitHub GraphQL API client for browsers and Node","devDependencies":{"chai":"^4.2.0","compression-webpack-plugin":"^2.0.0","coveralls":"^3.0.3","cypress":"^3.1.5","fetch-mock":"^7.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","npm-run-all":"^4.1.3","nyc":"^14.0.0","semantic-release":"^15.13.3","simple-mock":"^0.8.0","standard":"^12.0.1","webpack":"^4.29.6","webpack-bundle-analyzer":"^3.1.0","webpack-cli":"^3.2.3"},"files":["lib"],"homepage":"https://github.com/octokit/graphql.js#readme","keywords":["octokit","github","api","graphql"],"license":"MIT","main":"index.js","name":"@octokit/graphql","publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/graphql.js.git"},"scripts":{"build":"npm-run-all build:*","build:development":"webpack --mode development --entry . --output-library=octokitGraphql --output=./dist/octokit-graphql.js --profile --json > dist/bundle-stats.json","build:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=octokitGraphql --output-path=./dist --output-filename=octokit-graphql.min.js --devtool source-map","bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","prebuild":"mkdirp dist/","pretest":"standard","test":"nyc mocha test/*-test.js","test:browser":"cypress run --browser chrome"},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect"]},"version":"2.1.3"}; module.exports = {"name":"@octokit/graphql","version":"2.1.3","publishConfig":{"access":"public"},"description":"GitHub GraphQL API client for browsers and Node","main":"index.js","scripts":{"prebuild":"mkdirp dist/","build":"npm-run-all build:*","build:development":"webpack --mode development --entry . --output-library=octokitGraphql --output=./dist/octokit-graphql.js --profile --json > dist/bundle-stats.json","build:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=octokitGraphql --output-path=./dist --output-filename=octokit-graphql.min.js --devtool source-map","bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","pretest":"standard","test":"nyc mocha test/*-test.js","test:browser":"cypress run --browser chrome"},"repository":{"type":"git","url":"https://github.com/octokit/graphql.js.git"},"keywords":["octokit","github","api","graphql"],"author":"Gregor Martynus (https://github.com/gr2m)","license":"MIT","bugs":{"url":"https://github.com/octokit/graphql.js/issues"},"homepage":"https://github.com/octokit/graphql.js#readme","dependencies":{"@octokit/request":"^5.0.0","universal-user-agent":"^2.0.3"},"devDependencies":{"chai":"^4.2.0","compression-webpack-plugin":"^2.0.0","coveralls":"^3.0.3","cypress":"^3.1.5","fetch-mock":"^7.3.1","mkdirp":"^0.5.1","mocha":"^6.0.0","npm-run-all":"^4.1.3","nyc":"^14.0.0","semantic-release":"^15.13.3","simple-mock":"^0.8.0","standard":"^12.0.1","webpack":"^4.29.6","webpack-bundle-analyzer":"^3.1.0","webpack-cli":"^3.2.3"},"bundlesize":[{"path":"./dist/octokit-graphql.min.js.gz","maxSize":"5KB"}],"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"standard":{"globals":["describe","before","beforeEach","afterEach","after","it","expect"]},"files":["lib"],"_resolved":"https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz","_integrity":"sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==","_from":"@octokit/graphql@2.1.3"};
/***/ }), /***/ }),
@ -11583,15 +11646,6 @@ class HttpClient {
// we need to finish reading the response before reassigning response // we need to finish reading the response before reassigning response
// which will leak the open socket. // which will leak the open socket.
await response.readBody(); await response.readBody();
// strip authorization header if redirected to a different hostname
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
for (let header in headers) {
// header names are case insensitive
if (header.toLowerCase() === 'authorization') {
delete headers[header];
}
}
}
// let's make the request with the new redirectUrl // let's make the request with the new redirectUrl
info = this._prepareRequest(verb, parsedRedirectUrl, headers); info = this._prepareRequest(verb, parsedRedirectUrl, headers);
response = await this.requestRaw(info, data); response = await this.requestRaw(info, data);
@ -12873,15 +12927,16 @@ module.exports = require("fs");
/***/ }), /***/ }),
/***/ 749: /***/ 749:
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
@ -12893,18 +12948,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __webpack_require__(87);
const assert = __importStar(__webpack_require__(357)); const assert = __importStar(__webpack_require__(357));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const hc = __importStar(__webpack_require__(539)); const hc = __importStar(__webpack_require__(539));
const io = __importStar(__webpack_require__(1)); const io = __importStar(__webpack_require__(1));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const semver = __importStar(__webpack_require__(280)); const semver = __importStar(__webpack_require__(280));
let osPlat = os.platform();
let osArch = translateArchToDistUrl(os.arch());
function getNode(versionSpec, stable, token) { function getNode(versionSpec, stable, token) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(os.arch());
// check cache // check cache
let info = null; let info = null;
let toolPath; let toolPath;
@ -12924,7 +12979,7 @@ function getNode(versionSpec, stable, token) {
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`); throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
} }
console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
let downloadPath = ""; let downloadPath = '';
try { try {
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, token); downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, token);
} }
@ -12967,7 +13022,7 @@ exports.getNode = getNode;
function getInfoFromManifest(versionSpec, stable, token) { function getInfoFromManifest(versionSpec, stable, token) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let info = null; let info = null;
const releases = yield tc.getManifestFromRepo("actions", "node-versions", token); const releases = yield tc.getManifestFromRepo('actions', 'node-versions', token);
console.log(`matching ${versionSpec}...`); console.log(`matching ${versionSpec}...`);
const rel = yield tc.findFromManifest(versionSpec, stable, releases); const rel = yield tc.findFromManifest(versionSpec, stable, releases);
if (rel && rel.files.length > 0) { if (rel && rel.files.length > 0) {
@ -12982,19 +13037,13 @@ function getInfoFromManifest(versionSpec, stable, token) {
} }
function getInfoFromDist(versionSpec) { function getInfoFromDist(versionSpec) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(os.arch());
let info = null; let info = null;
let version; let version;
// If explicit version don't query version = yield queryDistForMatch(versionSpec);
if (semver.clean(versionSpec) != null) { if (!version) {
// version to download return null;
version = versionSpec;
}
else {
// query nodejs.org for a matching version
version = yield queryDistForMatch(versionSpec);
if (!version) {
return null;
}
} }
// //
// Download - a tool installer intimately knows how to get the tool (and construct urls) // Download - a tool installer intimately knows how to get the tool (and construct urls)
@ -13040,6 +13089,8 @@ function evaluateVersions(versions, versionSpec) {
} }
function queryDistForMatch(versionSpec) { function queryDistForMatch(versionSpec) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(os.arch());
// node offers a json list of versions // node offers a json list of versions
let dataFileName; let dataFileName;
switch (osPlat) { switch (osPlat) {
@ -13056,13 +13107,7 @@ function queryDistForMatch(versionSpec) {
throw new Error(`Unexpected OS '${osPlat}'`); throw new Error(`Unexpected OS '${osPlat}'`);
} }
let versions = []; let versions = [];
let dataUrl = 'https://nodejs.org/dist/index.json'; let nodeVersions = yield module.exports.getVersionsFromDist();
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = yield httpClient.getJson(dataUrl);
let nodeVersions = response.result || [];
nodeVersions.forEach((nodeVersion) => { nodeVersions.forEach((nodeVersion) => {
// ensure this version supports your os and platform // ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) { if (nodeVersion.files.indexOf(dataFileName) >= 0) {
@ -13074,6 +13119,18 @@ function queryDistForMatch(versionSpec) {
return version; return version;
}); });
} }
function getVersionsFromDist() {
return __awaiter(this, void 0, void 0, function* () {
let dataUrl = 'https://nodejs.org/dist/index.json';
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = yield httpClient.getJson(dataUrl);
return response.result || [];
});
}
exports.getVersionsFromDist = getVersionsFromDist;
// For non LTS versions of Node, the files we need (for Windows) are sometimes located // For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions. // in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z // Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
@ -13088,6 +13145,8 @@ function queryDistForMatch(versionSpec) {
// and lib file in a folder, not zipped. // and lib file in a folder, not zipped.
function acquireNodeFromFallbackLocation(version) { function acquireNodeFromFallbackLocation(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(os.arch());
// Create temporary folder to download in to // Create temporary folder to download in to
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000); const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDirectory = process.env['RUNNER_TEMP'] || '';
@ -13133,7 +13192,7 @@ function translateArchToDistUrl(arch) {
return arch; return arch;
} }
} }
//# sourceMappingURL=installer.js.map
/***/ }), /***/ }),
@ -15989,60 +16048,10 @@ function hasNextPage (link) {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470)); const main_1 = __webpack_require__(198);
const installer = __importStar(__webpack_require__(749)); main_1.run();
const auth = __importStar(__webpack_require__(202)); //# sourceMappingURL=setup-node.js.map
const path = __importStar(__webpack_require__(622));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
let version = core.getInput('node-version');
if (!version) {
version = core.getInput('version');
}
console.log(`version: ${version}`);
if (version) {
let token = core.getInput('token');
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
yield installer.getNode(version, stable, token);
}
const registryUrl = core.getInput('registry-url');
const alwaysAuth = core.getInput('always-auth');
if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
/***/ }), /***/ }),

3844
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -35,10 +35,10 @@
"@types/node": "^12.0.4", "@types/node": "^12.0.4",
"@types/semver": "^6.0.0", "@types/semver": "^6.0.0",
"@zeit/ncc": "^0.21.0", "@zeit/ncc": "^0.21.0",
"jest": "^24.8.0", "jest": "^24.9.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.7.1",
"prettier": "^1.17.1", "prettier": "^1.19.1",
"ts-jest": "^24.0.2", "ts-jest": "^24.3.0",
"typescript": "^3.5.1" "typescript": "^3.8.3"
} }
} }

View file

@ -1,21 +1,18 @@
import os = require('os');
import * as assert from 'assert'; import * as assert from 'assert';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as hc from '@actions/http-client'; import * as hc from '@actions/http-client';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
import { Url } from 'url'; import {Url} from 'url';
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(os.arch());
// //
// Node versions interface // Node versions interface
// see https://nodejs.org/dist/index.json // see https://nodejs.org/dist/index.json
// //
interface INodeVersion { export interface INodeVersion {
version: string; version: string;
files: string[]; files: string[];
} }
@ -27,7 +24,14 @@ interface INodeVersionInfo {
fileName: string; fileName: string;
} }
export async function getNode(versionSpec: string, stable: boolean, token: string) { export async function getNode(
versionSpec: string,
stable: boolean,
token: string
) {
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(os.arch());
// check cache // check cache
let info: INodeVersionInfo | null = null; let info: INodeVersionInfo | null = null;
let toolPath: string; let toolPath: string;
@ -37,13 +41,15 @@ export async function getNode(versionSpec: string, stable: boolean, token: strin
if (toolPath) { if (toolPath) {
console.log(`Found in cache @ ${toolPath}`); console.log(`Found in cache @ ${toolPath}`);
} else { } else {
console.log(`Attempting to download ${versionSpec}...`) console.log(`Attempting to download ${versionSpec}...`);
let info = await getInfoFromManifest(versionSpec, stable, token); let info = await getInfoFromManifest(versionSpec, stable, token);
if (!info) { if (!info) {
console.log('Not found in manifest. Falling back to download directly from Node') console.log(
'Not found in manifest. Falling back to download directly from Node'
);
info = await getInfoFromDist(versionSpec); info = await getInfoFromDist(versionSpec);
} }
if (!info) { if (!info) {
throw new Error( throw new Error(
`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.` `Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
@ -52,7 +58,7 @@ export async function getNode(versionSpec: string, stable: boolean, token: strin
console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
let downloadPath = "" let downloadPath = '';
try { try {
downloadPath = await tc.downloadTool(info.downloadUrl, undefined, token); downloadPath = await tc.downloadTool(info.downloadUrl, undefined, token);
} catch (err) { } catch (err) {
@ -77,7 +83,7 @@ export async function getNode(versionSpec: string, stable: boolean, token: strin
// //
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
// //
toolPath = await tc.cacheDir(extPath, 'node', info.resolvedVersion); toolPath = await tc.cacheDir(extPath, 'node', info.resolvedVersion);
} }
// //
@ -94,12 +100,20 @@ export async function getNode(versionSpec: string, stable: boolean, token: strin
core.addPath(toolPath); core.addPath(toolPath);
} }
async function getInfoFromManifest(versionSpec: string, stable: boolean, token: string): Promise<INodeVersionInfo | null> { async function getInfoFromManifest(
versionSpec: string,
stable: boolean,
token: string
): Promise<INodeVersionInfo | null> {
let info: INodeVersionInfo | null = null; let info: INodeVersionInfo | null = null;
const releases = await tc.getManifestFromRepo("actions", "node-versions", token) const releases = await tc.getManifestFromRepo(
console.log(`matching ${versionSpec}...`) 'actions',
'node-versions',
token
);
console.log(`matching ${versionSpec}...`);
const rel = await tc.findFromManifest(versionSpec, stable, releases); const rel = await tc.findFromManifest(versionSpec, stable, releases);
if (rel && rel.files.length > 0) { if (rel && rel.files.length > 0) {
info = <INodeVersionInfo>{}; info = <INodeVersionInfo>{};
info.resolvedVersion = rel.version; info.resolvedVersion = rel.version;
@ -111,20 +125,18 @@ async function getInfoFromManifest(versionSpec: string, stable: boolean, token:
return info; return info;
} }
async function getInfoFromDist(versionSpec: string): Promise<INodeVersionInfo | null> { async function getInfoFromDist(
versionSpec: string
): Promise<INodeVersionInfo | null> {
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(os.arch());
let info: INodeVersionInfo | null = null; let info: INodeVersionInfo | null = null;
let version: string; let version: string;
// If explicit version don't query version = await queryDistForMatch(versionSpec);
if (semver.clean(versionSpec) != null) { if (!version) {
// version to download return null;
version = versionSpec;
} else {
// query nodejs.org for a matching version
version = await queryDistForMatch(versionSpec);
if (!version) {
return null;
}
} }
// //
@ -143,7 +155,7 @@ async function getInfoFromDist(versionSpec: string): Promise<INodeVersionInfo |
downloadUrl: url, downloadUrl: url,
resolvedVersion: version, resolvedVersion: version,
fileName: fileName fileName: fileName
} };
} }
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there // TODO - should we just export this from @actions/tool-cache? Lifted directly from there
@ -175,6 +187,9 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
} }
async function queryDistForMatch(versionSpec: string): Promise<string> { async function queryDistForMatch(versionSpec: string): Promise<string> {
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(os.arch());
// node offers a json list of versions // node offers a json list of versions
let dataFileName: string; let dataFileName: string;
switch (osPlat) { switch (osPlat) {
@ -192,13 +207,8 @@ async function queryDistForMatch(versionSpec: string): Promise<string> {
} }
let versions: string[] = []; let versions: string[] = [];
let dataUrl = 'https://nodejs.org/dist/index.json'; let nodeVersions = await module.exports.getVersionsFromDist();
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = await httpClient.getJson<INodeVersion[]>(dataUrl);
let nodeVersions = response.result || [];
nodeVersions.forEach((nodeVersion: INodeVersion) => { nodeVersions.forEach((nodeVersion: INodeVersion) => {
// ensure this version supports your os and platform // ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) { if (nodeVersion.files.indexOf(dataFileName) >= 0) {
@ -211,6 +221,16 @@ async function queryDistForMatch(versionSpec: string): Promise<string> {
return version; return version;
} }
export async function getVersionsFromDist(): Promise<INodeVersion[]> {
let dataUrl = 'https://nodejs.org/dist/index.json';
let httpClient = new hc.HttpClient('setup-node', [], {
allowRetries: true,
maxRetries: 3
});
let response = await httpClient.getJson<INodeVersion[]>(dataUrl);
return response.result || [];
}
// For non LTS versions of Node, the files we need (for Windows) are sometimes located // For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions. // in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z // Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
@ -226,6 +246,9 @@ async function queryDistForMatch(versionSpec: string): Promise<string> {
async function acquireNodeFromFallbackLocation( async function acquireNodeFromFallbackLocation(
version: string version: string
): Promise<string> { ): Promise<string> {
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(os.arch());
// Create temporary folder to download in to // Create temporary folder to download in to
const tempDownloadFolder: string = const tempDownloadFolder: string =
'temp_' + Math.floor(Math.random() * 2000000000); 'temp_' + Math.floor(Math.random() * 2000000000);

41
src/main.ts Normal file
View file

@ -0,0 +1,41 @@
import * as core from '@actions/core';
import * as installer from './installer';
import * as auth from './authutil';
import * as path from 'path';
export async function run() {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
let version = core.getInput('node-version');
if (!version) {
version = core.getInput('version');
}
console.log(`version: ${version}`);
if (version) {
let token = core.getInput('token');
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
await installer.getNode(version, stable, token);
}
const registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth');
if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log(
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
);
console.log(
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
);
} catch (error) {
core.setFailed(error.message);
}
}

View file

@ -1,43 +1,3 @@
import * as core from '@actions/core'; import {run} from './main';
import * as installer from './installer';
import * as auth from './authutil';
import * as path from 'path';
async function run() {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
let version = core.getInput('node-version');
if (!version) {
version = core.getInput('version');
}
console.log(`version: ${version}`);
if (version) {
let token = core.getInput('token');
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
await installer.getNode(version, stable, token);
}
const registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth');
if (registryUrl) {
auth.configAuthentication(registryUrl, alwaysAuth);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
console.log(
`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`
);
console.log(
`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
);
} catch (error) {
core.setFailed(error.message);
}
}
run(); run();

View file

@ -7,6 +7,7 @@
], ],
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"sourceMap": true,
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */