Update tool-cache we consume

This commit is contained in:
Danny McCormick 2019-06-05 11:22:12 -04:00
parent d83862c273
commit d7b6952411
18 changed files with 230 additions and 163 deletions

View File

@ -1,19 +1,18 @@
import installer = require('../src/installer');
import io = require('@actions/io');
import fs = require('fs');
import os = require('os');
import path = require('path');
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
process.env['RUNNER_TOOLSDIRECTORY'] = toolDir;
process.env['RUNNER_TEMPDIRECTORY'] = tempDir;
import * as installer from '../src/installer';
describe('installer tests', () => {
beforeAll(() => {});
beforeAll(async () => {
// TODO - these should eventually be changed to match new method of loading dir
process.env['Runner.ToolsDirectory'] = toolDir;
process.env['Runner.TempDirectory'] = tempDir;
await io.rmRF(toolDir);
await io.rmRF(tempDir);
});
@ -63,7 +62,7 @@ describe('installer tests', () => {
}, 100000);
it('Uses version of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, '250.0.0', os.arch());
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)
@ -72,7 +71,7 @@ describe('installer tests', () => {
});
it('Doesnt use version of node that was only partially installed in cache', async () => {
const nodeDir: string = path.join(toolDir, '250.0.0', os.arch());
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch());
await io.mkdirP(nodeDir);
let thrown = false;
try {
@ -86,7 +85,7 @@ describe('installer tests', () => {
});
it('Resolves semantic versions of node installed in cache', async () => {
const nodeDir: string = path.join(toolDir, '250.0.0', os.arch());
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch());
await io.mkdirP(nodeDir);
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
// These will throw if it doesn't find it in the cache (because no such version exists)

View File

@ -15,6 +15,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
const tc = __importStar(require("@actions/tool-cache"));
@ -24,6 +26,22 @@ const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
let osPlat = os.platform();
let osArch = os.arch();
if (!tempDirectory) {
let baseLocation;
if (process.platform === 'win32') {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
function getNode(versionSpec) {
return __awaiter(this, void 0, void 0, function* () {
// check cache
@ -140,7 +158,7 @@ function acquireNode(version) {
downloadPath = yield tc.downloadTool(downloadUrl);
}
catch (err) {
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
return yield acquireNodeFromFallbackLocation(version);
}
throw err;
@ -179,7 +197,7 @@ function acquireNodeFromFallbackLocation(version) {
return __awaiter(this, void 0, void 0, function* () {
// Create temporary folder to download in to
let tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir = path.join(__dirname, tempDownloadFolder);
let tempDir = path.join(tempDirectory, tempDownloadFolder);
yield io.mkdirP(tempDir);
let exeUrl;
let libUrl;
@ -192,7 +210,7 @@ function acquireNodeFromFallbackLocation(version) {
yield io.mv(libPath, path.join(tempDir, 'node.lib'));
}
catch (err) {
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
const exePath = yield tc.downloadTool(exeUrl);

View File

@ -1,5 +1,5 @@
{
"_from": "file:toolkit/actions-core-0.1.0.tgz",
"_from": "file:toolkit\\actions-core-0.1.0.tgz",
"_id": "@actions/core@0.1.0",
"_inBundle": false,
"_integrity": "sha512-1I2vFY5r80QcbM1R8Ika5Ke9uWGrF8nl33oQuP3bXVG47wMIw1DdAVK0A17CHJe5ObHU4gpwTuQakUdZaOlg0w==",
@ -7,21 +7,23 @@
"_phantomChildren": {},
"_requested": {
"type": "file",
"where": "/Users/bryan/Projects/setup-node",
"where": "C:\\Users\\damccorm\\Documents\\setup-node",
"raw": "@actions/core@file:toolkit/actions-core-0.1.0.tgz",
"name": "@actions/core",
"escapedName": "@actions%2fcore",
"scope": "@actions",
"rawSpec": "file:toolkit/actions-core-0.1.0.tgz",
"saveSpec": "file:toolkit/actions-core-0.1.0.tgz",
"fetchSpec": "/Users/bryan/Projects/setup-node/toolkit/actions-core-0.1.0.tgz"
"saveSpec": "file:toolkit\\actions-core-0.1.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-core-0.1.0.tgz"
},
"_requiredBy": [
"/"
"/",
"/@actions/tool-cache"
],
"_resolved": "/Users/bryan/Projects/setup-node/toolkit/actions-core-0.1.0.tgz",
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-core-0.1.0.tgz",
"_shasum": "a2d7cc689a05e28a677af34e2d69826d2029232c",
"_spec": "@actions/core@file:toolkit/actions-core-0.1.0.tgz",
"_where": "/Users/bryan/Projects/setup-node",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"author": {
"name": "Bryan MacFarlane",
"email": "bryanmac@microsoft.com"

View File

@ -1,5 +1,5 @@
{
"_from": "file:toolkit/actions-exec-1.0.0.tgz",
"_from": "file:toolkit\\actions-exec-1.0.0.tgz",
"_id": "@actions/exec@1.0.0",
"_inBundle": false,
"_integrity": "sha512-AxtupsjQceVIf6nEECts5a1pDpWO4r3yq5lpTA73g1FXA0awDdTW3r9NFn8NGF6UaydkIN0BEOasQlS5qS30zg==",
@ -7,21 +7,23 @@
"_phantomChildren": {},
"_requested": {
"type": "file",
"where": "/Users/bryan/Projects/setup-node",
"where": "C:\\Users\\damccorm\\Documents\\setup-node",
"raw": "@actions/exec@file:toolkit/actions-exec-1.0.0.tgz",
"name": "@actions/exec",
"escapedName": "@actions%2fexec",
"scope": "@actions",
"rawSpec": "file:toolkit/actions-exec-1.0.0.tgz",
"saveSpec": "file:toolkit/actions-exec-1.0.0.tgz",
"fetchSpec": "/Users/bryan/Projects/setup-node/toolkit/actions-exec-1.0.0.tgz"
"saveSpec": "file:toolkit\\actions-exec-1.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exec-1.0.0.tgz"
},
"_requiredBy": [
"/"
"/",
"/@actions/tool-cache"
],
"_resolved": "/Users/bryan/Projects/setup-node/toolkit/actions-exec-1.0.0.tgz",
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exec-1.0.0.tgz",
"_shasum": "6845691df4b14de24cf3b0a45c847070db8f9b6d",
"_spec": "@actions/exec@file:toolkit/actions-exec-1.0.0.tgz",
"_where": "/Users/bryan/Projects/setup-node",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"author": {
"name": "Bryan MacFarlane",
"email": "bryanmac@microsoft.com"

View File

@ -1,5 +1,5 @@
{
"_from": "file:toolkit/actions-exit-0.0.0.tgz",
"_from": "file:toolkit\\actions-exit-0.0.0.tgz",
"_id": "@actions/exit@0.0.0",
"_inBundle": false,
"_integrity": "sha512-vQdxFWM0/AERkC79mQ886SqPmV4joWhrSF7hiSTiJoKkE9eTjrKV5WQtp7SXv6OntrQkKX+ZjgdGpv+0rvJRCw==",
@ -7,22 +7,23 @@
"_phantomChildren": {},
"_requested": {
"type": "file",
"where": "/Users/bryan/Projects/setup-node",
"where": "C:\\Users\\damccorm\\Documents\\setup-node",
"raw": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
"name": "@actions/exit",
"escapedName": "@actions%2fexit",
"scope": "@actions",
"rawSpec": "file:toolkit/actions-exit-0.0.0.tgz",
"saveSpec": "file:toolkit/actions-exit-0.0.0.tgz",
"fetchSpec": "/Users/bryan/Projects/setup-node/toolkit/actions-exit-0.0.0.tgz"
"saveSpec": "file:toolkit\\actions-exit-0.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exit-0.0.0.tgz"
},
"_requiredBy": [
"/",
"/@actions/core"
],
"_resolved": "/Users/bryan/Projects/setup-node/toolkit/actions-exit-0.0.0.tgz",
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exit-0.0.0.tgz",
"_shasum": "d47c8c61b45750ae49fea3061e3419a547b2a48f",
"_spec": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
"_where": "/Users/bryan/Projects/setup-node",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},

View File

@ -1,5 +1,5 @@
{
"_from": "file:toolkit/actions-io-1.0.0.tgz",
"_from": "file:toolkit\\actions-io-1.0.0.tgz",
"_id": "@actions/io@1.0.0",
"_inBundle": false,
"_integrity": "sha512-Dox3bRCdyxoG0o1mSHt/uINbyQ2SfbhtJmmMuUQny6ARB1hU8ZUi+XR0cHUfd/SrwdzLUrxX4dV8x8ylNSBQpA==",
@ -7,21 +7,23 @@
"_phantomChildren": {},
"_requested": {
"type": "file",
"where": "/Users/bryan/Projects/setup-node",
"where": "C:\\Users\\damccorm\\Documents\\setup-node",
"raw": "@actions/io@file:toolkit/actions-io-1.0.0.tgz",
"name": "@actions/io",
"escapedName": "@actions%2fio",
"scope": "@actions",
"rawSpec": "file:toolkit/actions-io-1.0.0.tgz",
"saveSpec": "file:toolkit/actions-io-1.0.0.tgz",
"fetchSpec": "/Users/bryan/Projects/setup-node/toolkit/actions-io-1.0.0.tgz"
"saveSpec": "file:toolkit\\actions-io-1.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-io-1.0.0.tgz"
},
"_requiredBy": [
"/"
"/",
"/@actions/tool-cache"
],
"_resolved": "/Users/bryan/Projects/setup-node/toolkit/actions-io-1.0.0.tgz",
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-io-1.0.0.tgz",
"_shasum": "a395423c226d068e7caced224d51356ad15c41a7",
"_spec": "@actions/io@file:toolkit/actions-io-1.0.0.tgz",
"_where": "/Users/bryan/Projects/setup-node",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"author": {
"name": "Danny McCormick",
"email": "damccorm@microsoft.com"

View File

@ -1,3 +1,7 @@
export declare class HTTPError extends Error {
readonly httpStatusCode: number | undefined;
constructor(httpStatusCode: number | undefined);
}
/**
* Download a tool from an url and stream it into a file
*

View File

@ -17,8 +17,44 @@ const httpm = require("typed-rest-client/HttpClient");
const semver = require("semver");
const uuidV4 = require("uuid/v4");
const exec_1 = require("@actions/exec/lib/exec");
const assert_1 = require("assert");
class HTTPError extends Error {
constructor(httpStatusCode) {
super(`Unexpected HTTP response: ${httpStatusCode}`);
this.httpStatusCode = httpStatusCode;
Object.setPrototypeOf(this, new.target.prototype);
}
}
exports.HTTPError = HTTPError;
const IS_WINDOWS = process.platform === 'win32';
const userAgent = 'actions/tool-cache';
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
let cacheRoot = process.env['RUNNER_TOOLSDIRECTORY'] || '';
process.env['RUNNER_TEMPDIRECTORY'] = '';
process.env['RUNNER_TOOLSDIRECTORY'] = '';
// If directories not found, place them in common temp locations
if (!tempDirectory || !cacheRoot) {
let baseLocation;
if (IS_WINDOWS) {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
}
if (!tempDirectory) {
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
if (!cacheRoot) {
cacheRoot = path.join(baseLocation, 'actions', 'cache');
}
}
/**
* Download a tool from an url and stream it into a file
*
@ -27,14 +63,15 @@ const userAgent = 'actions/tool-cache';
*/
function downloadTool(url) {
return __awaiter(this, void 0, void 0, function* () {
// Wrap in a promise so that we can resolve from within stream callbacks
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
try {
const http = new httpm.HttpClient(userAgent, [], {
allowRetries: true,
maxRetries: 3
});
const destPath = path.join(_getAgentTemp(), uuidV4());
yield io.mkdirP(_getAgentTemp());
const destPath = path.join(tempDirectory, uuidV4());
yield io.mkdirP(tempDirectory);
core.debug(`Downloading ${url}`);
core.debug(`Downloading ${destPath}`);
if (fs.existsSync(destPath)) {
@ -42,7 +79,7 @@ function downloadTool(url) {
}
const response = yield http.get(url);
if (response.message.statusCode !== 200) {
const err = new Error(`Unexpected HTTP response: ${response.message.statusCode}`);
const err = new HTTPError(response.message.statusCode);
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
throw err;
}
@ -81,45 +118,33 @@ exports.downloadTool = downloadTool;
*/
function extract7z(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!IS_WINDOWS) {
throw new Error('extract7z() not supported on current OS');
}
if (!file) {
throw new Error("parameter 'file' is required");
}
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required');
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
const options = {
silent: true
};
try {
process.chdir(dest);
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const powershellPath = yield io.which('powershell', true);
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
const options = {
silent: true,
listeners: {
stdout: (data) => {
process.stdout.write(data);
},
stderr: (data) => {
process.stderr.write(data);
}
}
};
yield exec_1.exec(`"${powershellPath}"`, args, options);
}
finally {
@ -162,32 +187,42 @@ function extractZip(file, dest) {
}
dest = dest || (yield _createExtractFolder(dest));
if (IS_WINDOWS) {
// build the powershell command
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
// run powershell
const powershellPath = yield io.which('powershell');
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
yield exec_1.exec(`"${powershellPath}"`, args);
yield extractZipWin(file, dest);
}
else {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
yield extractZipNix(file, dest);
}
return dest;
});
}
exports.extractZip = extractZip;
function extractZipWin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
// build the powershell command
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
// run powershell
const powershellPath = yield io.which('powershell');
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
yield exec_1.exec(`"${powershellPath}"`, args);
});
}
function extractZipNix(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
/**
* Caches a directory and installs it into the tool cacheDir
*
@ -276,7 +311,6 @@ function find(toolName, versionSpec, arch) {
let toolPath = '';
if (versionSpec) {
versionSpec = semver.clean(versionSpec) || '';
const cacheRoot = _getCacheRoot();
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
core.debug(`checking cache: ${cachePath}`);
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
@ -294,31 +328,15 @@ function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!dest) {
// create a temp dir
dest = path.join(_getAgentTemp(), uuidV4());
dest = path.join(tempDirectory, uuidV4());
}
yield io.mkdirP(dest);
return dest;
});
}
function _getAgentTemp() {
// TODO - we need an actual protocol for this (this is just a placeholder)
const tempDirectory = process.env['Runner.TempDirectory'];
if (!tempDirectory) {
throw new Error('Runner.TempDirectory is not set');
}
return tempDirectory;
}
function _getCacheRoot() {
// TODO - we need an actual protocol for this (this is just a placeholder)
const cacheRoot = process.env['Runner.ToolsDirectory'];
if (!cacheRoot) {
throw new Error('Runner.ToolsDirectory is not set');
}
return cacheRoot;
}
function _createToolPath(tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () {
const folderPath = path.join(_getCacheRoot(), tool, semver.clean(version) || version, arch || '');
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
core.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
yield io.rmRF(folderPath);
@ -328,7 +346,7 @@ function _createToolPath(tool, version, arch) {
});
}
function _completeToolPath(tool, version, arch) {
const folderPath = path.join(_getCacheRoot(), tool, semver.clean(version) || version, arch || '');
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
const markerPath = `${folderPath}.complete`;
fs.writeFileSync(markerPath, '');
core.debug('finished caching tool');
@ -368,7 +386,7 @@ function _evaluateVersions(versions, versionSpec) {
function _findLocalToolVersions(toolName, arch) {
const versions = [];
arch = arch || os.arch();
const toolPath = path.join(_getCacheRoot(), toolName);
const toolPath = path.join(cacheRoot, toolName);
if (fs.existsSync(toolPath)) {
const children = fs.readdirSync(toolPath);
for (const child of children) {

File diff suppressed because one or more lines are too long

View File

@ -1,31 +1,28 @@
{
"_from": "file:toolkit/actions-tool-cache-1.0.0.tgz",
"_from": "file:toolkit\\actions-tool-cache-1.0.0.tgz",
"_id": "@actions/tool-cache@1.0.0",
"_inBundle": false,
"_integrity": "sha512-OfhQEpxnVfuaeBL2kbD+GfpoY1pOuBEIDKZowE/R0vPsJB/pML1VezhvBDbP8D8IBZA46aeQDA3l4iOsB69Hlw==",
"_integrity": "sha512-hx8Z1ip11aZVA47uSCIB7Y9ec4Ty9zNPUyFyBsr0YI5vJ64TR/JoySbr0ck7l2EI0zqYAdef11Ynwz/qUkXVyg==",
"_location": "/@actions/tool-cache",
"_phantomChildren": {},
"_requested": {
"type": "file",
"where": "/Users/bryan/Projects/setup-node",
"where": "C:\\Users\\damccorm\\Documents\\setup-node",
"raw": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
"name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache",
"scope": "@actions",
"rawSpec": "file:toolkit/actions-tool-cache-1.0.0.tgz",
"saveSpec": "file:toolkit/actions-tool-cache-1.0.0.tgz",
"fetchSpec": "/Users/bryan/Projects/setup-node/toolkit/actions-tool-cache-1.0.0.tgz"
"saveSpec": "file:toolkit\\actions-tool-cache-1.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz"
},
"_requiredBy": [
"/"
],
"_resolved": "/Users/bryan/Projects/setup-node/toolkit/actions-tool-cache-1.0.0.tgz",
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz",
"_shasum": "8650345f81eafb208916ec718e75188978d58567",
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
"_where": "/Users/bryan/Projects/setup-node",
"author": {
"name": "Danny McCormick",
"email": "damccorm@microsoft.com"
},
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},

27
node_modules/semver/package.json generated vendored
View File

@ -1,37 +1,40 @@
{
"_from": "semver",
"_args": [
[
"semver@6.1.1",
"C:\\Users\\damccorm\\Documents\\setup-node"
]
],
"_from": "semver@6.1.1",
"_id": "semver@6.1.1",
"_inBundle": false,
"_integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==",
"_location": "/semver",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"type": "version",
"registry": true,
"raw": "semver",
"raw": "semver@6.1.1",
"name": "semver",
"escapedName": "semver",
"rawSpec": "",
"rawSpec": "6.1.1",
"saveSpec": null,
"fetchSpec": "latest"
"fetchSpec": "6.1.1"
},
"_requiredBy": [
"#USER",
"/",
"/@actions/tool-cache"
"/@actions/tool-cache",
"/istanbul-lib-instrument"
],
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz",
"_shasum": "53f53da9b30b2103cd4f15eab3a18ecbcb210c9b",
"_spec": "semver",
"_where": "/Users/bryan/Projects/setup-node",
"_spec": "6.1.1",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"bin": {
"semver": "./bin/semver"
},
"bugs": {
"url": "https://github.com/npm/node-semver/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The semantic version parser used by npm.",
"devDependencies": {
"tap": "^14.1.6"

2
node_modules/tunnel/package.json generated vendored
View File

@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz",
"_shasum": "2d3785a158c174c9a16dc2c046ec5fc5f1742213",
"_spec": "tunnel@0.0.4",
"_where": "/Users/bryan/Projects/setup-node/node_modules/typed-rest-client",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node\\node_modules\\typed-rest-client",
"author": {
"name": "Koichi Kobayashi",
"email": "koichik@improvement.jp"

View File

@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.4.0.tgz",
"_shasum": "bf0f27684f8cbde05d32127ccb2cb8e0fe1a1b79",
"_spec": "typed-rest-client@^1.4.0",
"_where": "/Users/bryan/Projects/setup-node/toolkit/actions-tool-cache-1.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz",
"author": {
"name": "Microsoft Corporation"
},

View File

@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
"_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022",
"_spec": "underscore@1.8.3",
"_where": "/Users/bryan/Projects/setup-node/node_modules/typed-rest-client",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node\\node_modules\\typed-rest-client",
"author": {
"name": "Jeremy Ashkenas",
"email": "jeremy@documentcloud.org"

26
node_modules/uuid/package.json generated vendored
View File

@ -1,27 +1,33 @@
{
"_from": "uuid@^3.3.2",
"_args": [
[
"uuid@3.3.2",
"C:\\Users\\damccorm\\Documents\\setup-node"
]
],
"_from": "uuid@3.3.2",
"_id": "uuid@3.3.2",
"_inBundle": false,
"_integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
"_location": "/uuid",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "version",
"registry": true,
"raw": "uuid@^3.3.2",
"raw": "uuid@3.3.2",
"name": "uuid",
"escapedName": "uuid",
"rawSpec": "^3.3.2",
"rawSpec": "3.3.2",
"saveSpec": null,
"fetchSpec": "^3.3.2"
"fetchSpec": "3.3.2"
},
"_requiredBy": [
"/@actions/tool-cache"
"/@actions/tool-cache",
"/request"
],
"_resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"_shasum": "1b4af4955eb3077c501c23872fc6513811587131",
"_spec": "uuid@^3.3.2",
"_where": "/Users/bryan/Projects/setup-node/toolkit/actions-tool-cache-1.0.0.tgz",
"_spec": "3.3.2",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
"bin": {
"uuid": "./bin/uuid"
},
@ -33,7 +39,6 @@
"bugs": {
"url": "https://github.com/kelektiv/node-uuid/issues"
},
"bundleDependencies": false,
"commitlint": {
"extends": [
"@commitlint/config-conventional"
@ -61,7 +66,6 @@
"email": "shtylman@gmail.com"
}
],
"deprecated": false,
"description": "RFC4122 (v1, v4, and v5) UUIDs",
"devDependencies": {
"@commitlint/cli": "7.0.0",

12
package-lock.json generated
View File

@ -5,27 +5,27 @@
"requires": true,
"dependencies": {
"@actions/core": {
"version": "file:../../../bryan/Projects/setup-node/toolkit/actions-core-0.1.0.tgz",
"version": "file:toolkit/actions-core-0.1.0.tgz",
"integrity": "sha512-1I2vFY5r80QcbM1R8Ika5Ke9uWGrF8nl33oQuP3bXVG47wMIw1DdAVK0A17CHJe5ObHU4gpwTuQakUdZaOlg0w==",
"requires": {
"@actions/exit": "^0.0.0"
}
},
"@actions/exec": {
"version": "file:../../../bryan/Projects/setup-node/toolkit/actions-exec-1.0.0.tgz",
"version": "file:toolkit/actions-exec-1.0.0.tgz",
"integrity": "sha512-AxtupsjQceVIf6nEECts5a1pDpWO4r3yq5lpTA73g1FXA0awDdTW3r9NFn8NGF6UaydkIN0BEOasQlS5qS30zg=="
},
"@actions/exit": {
"version": "file:../../../bryan/Projects/setup-node/toolkit/actions-exit-0.0.0.tgz",
"version": "file:toolkit/actions-exit-0.0.0.tgz",
"integrity": "sha512-vQdxFWM0/AERkC79mQ886SqPmV4joWhrSF7hiSTiJoKkE9eTjrKV5WQtp7SXv6OntrQkKX+ZjgdGpv+0rvJRCw=="
},
"@actions/io": {
"version": "file:../../../bryan/Projects/setup-node/toolkit/actions-io-1.0.0.tgz",
"version": "file:toolkit/actions-io-1.0.0.tgz",
"integrity": "sha512-Dox3bRCdyxoG0o1mSHt/uINbyQ2SfbhtJmmMuUQny6ARB1hU8ZUi+XR0cHUfd/SrwdzLUrxX4dV8x8ylNSBQpA=="
},
"@actions/tool-cache": {
"version": "file:../../../bryan/Projects/setup-node/toolkit/actions-tool-cache-1.0.0.tgz",
"integrity": "sha512-OfhQEpxnVfuaeBL2kbD+GfpoY1pOuBEIDKZowE/R0vPsJB/pML1VezhvBDbP8D8IBZA46aeQDA3l4iOsB69Hlw==",
"version": "file:toolkit/actions-tool-cache-1.0.0.tgz",
"integrity": "sha512-hx8Z1ip11aZVA47uSCIB7Y9ec4Ty9zNPUyFyBsr0YI5vJ64TR/JoySbr0ck7l2EI0zqYAdef11Ynwz/qUkXVyg==",
"requires": {
"@actions/core": "^0.1.0",
"@actions/exec": "^1.0.0",

View File

@ -1,3 +1,5 @@
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as tc from '@actions/tool-cache';
@ -9,6 +11,21 @@ import * as semver from 'semver';
let osPlat: string = os.platform();
let osArch: string = os.arch();
if (!tempDirectory) {
let baseLocation;
if (process.platform === 'win32') {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
} else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
} else {
baseLocation = '/home';
}
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
//
// Node versions interface
// see https://nodejs.org/dist/index.json
@ -145,7 +162,7 @@ async function acquireNode(version: string): Promise<string> {
try {
downloadPath = await tc.downloadTool(downloadUrl);
} catch (err) {
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
return await acquireNodeFromFallbackLocation(version);
}
@ -188,7 +205,7 @@ async function acquireNodeFromFallbackLocation(
// Create temporary folder to download in to
let tempDownloadFolder: string =
'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(__dirname, tempDownloadFolder);
let tempDir: string = path.join(tempDirectory, tempDownloadFolder);
await io.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
@ -201,7 +218,7 @@ async function acquireNodeFromFallbackLocation(
const libPath = await tc.downloadTool(libUrl);
await io.mv(libPath, path.join(tempDir, 'node.lib'));
} catch (err) {
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;

Binary file not shown.