1
0
Fork 0
mirror of https://github.com/actions/setup-go synced 2024-12-22 14:22:41 +00:00

Merge branch 'master' into features/matcher

This commit is contained in:
Danny McCormick 2019-06-26 21:02:35 -04:00 committed by GitHub
commit 5331f86a70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 8225 additions and 7742 deletions

View file

@ -10,12 +10,65 @@ process.env['RUNNER_TOOLSDIRECTORY'] = toolDir;
process.env['RUNNER_TEMPDIRECTORY'] = tempDir; process.env['RUNNER_TEMPDIRECTORY'] = tempDir;
import * as installer from '../src/installer'; import * as installer from '../src/installer';
const IS_WINDOWS = process.platform === 'win32';
describe('installer tests', () => { describe('installer tests', () => {
beforeAll(() => {});
beforeAll(async () => { beforeAll(async () => {
await io.rmRF(toolDir); await io.rmRF(toolDir);
await io.rmRF(tempDir); await io.rmRF(tempDir);
}, 100000);
afterAll(async () => {
try {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
} catch {
console.log('Failed to remove test directories');
}
}, 100000);
it('Acquires version of go if no matching version is installed', async () => {
await installer.getGo('1.10');
const goDir = path.join(toolDir, 'go', '1.10.0', os.arch());
expect(fs.existsSync(`${goDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(goDir, 'bin', 'go.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(goDir, 'bin', 'go'))).toBe(true);
}
}, 100000);
it('Throws if no location contains correct go version', async () => {
let thrown = false;
try {
await installer.getGo('1000.0');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
}); });
it('TODO - Add tests', async () => {}); it('Uses version of go installed in cache', async () => {
const goDir: string = path.join(toolDir, 'go', '250.0.0', os.arch());
await io.mkdirP(goDir);
fs.writeFileSync(`${goDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getGo('250.0');
return;
});
it('Doesnt use version of go that was only partially installed in cache', async () => {
const goDir: string = path.join(toolDir, 'go', '251.0.0', os.arch());
await io.mkdirP(goDir);
let thrown = false;
try {
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getGo('251.0');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});
}); });

134
lib/installer.js Normal file
View file

@ -0,0 +1,134 @@
"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 });
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
const core = __importStar(require("@actions/core"));
const tc = __importStar(require("@actions/tool-cache"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const util = __importStar(require("util"));
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 getGo(version) {
return __awaiter(this, void 0, void 0, function* () {
// check cache
let toolPath;
toolPath = tc.find('go', normalizeVersion(version));
if (!toolPath) {
// download, extract, cache
toolPath = yield acquireGo(version);
core.debug('Go tool is cached under ' + toolPath);
}
setGoEnvironmentVariables(toolPath);
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
core.addPath(toolPath);
});
}
exports.getGo = getGo;
function acquireGo(version) {
return __awaiter(this, void 0, void 0, function* () {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
let fileName = getFileName(version);
let downloadUrl = getDownloadUrl(fileName);
let downloadPath = null;
try {
downloadPath = yield tc.downloadTool(downloadUrl);
}
catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Extract
//
let extPath = tempDirectory;
if (!extPath) {
throw new Error('Temp directory not set');
}
if (osPlat == 'win32') {
extPath = yield tc.extractZip(downloadPath);
}
else {
extPath = yield tc.extractTar(downloadPath);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
const toolRoot = path.join(extPath, 'go');
version = normalizeVersion(version);
return yield tc.cacheDir(toolRoot, 'go', version);
});
}
function getFileName(version) {
const platform = osPlat == 'win32' ? 'windows' : osPlat;
const arch = osArch == 'x64' ? 'amd64' : '386';
const ext = osPlat == 'win32' ? 'zip' : 'tar.gz';
const filename = util.format('go%s.%s-%s.%s', version, platform, arch, ext);
return filename;
}
function getDownloadUrl(filename) {
return util.format('https://storage.googleapis.com/golang/%s', filename);
}
function setGoEnvironmentVariables(goRoot) {
core.exportVariable('GOROOT', goRoot);
const goPath = process.env['GOPATH'] || '';
const goBin = process.env['GOBIN'] || '';
// set GOPATH and GOBIN as user value
if (goPath) {
core.exportVariable('GOPATH', goPath);
}
if (goBin) {
core.exportVariable('GOBIN', goBin);
}
}
// This function is required to convert the version 1.10 to 1.10.0.
// Because caching utility accept only sementic version,
// which have patch number as well.
function normalizeVersion(version) {
const versionPart = version.split('.');
if (versionPart[1] == null) {
//append minor and patch version if not available
return version.concat('.0.0');
}
else if (versionPart[2] == null) {
//append patch version if not available
return version.concat('.0');
}
return version;
}

14
node_modules/@actions/core/README.md generated vendored
View file

@ -1,7 +1,7 @@
# `@actions/core` # `@actions/core`
> Core functions for setting results, logging, registering secrets and exporting variables across actions > Core functions for setting results, logging, registering secrets and exporting variables across actions
## Usage ## Usage
See [src/core.ts](src/core.ts). See [src/core.ts](src/core.ts).

View file

@ -1,16 +1,16 @@
interface CommandProperties { interface CommandProperties {
[key: string]: string; [key: string]: string;
} }
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definatelyNotAPassword!
*/ */
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void; export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
export declare function issue(name: string, message: string): void; export declare function issue(name: string, message: string): void;
export {}; export {};

View file

@ -1,66 +1,66 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os"); const os = require("os");
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definatelyNotAPassword!
*/ */
function issueCommand(command, properties, message) { function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message); const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL); process.stdout.write(cmd.toString() + os.EOL);
} }
exports.issueCommand = issueCommand; exports.issueCommand = issueCommand;
function issue(name, message) { function issue(name, message) {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;
const CMD_PREFIX = '##['; const CMD_PREFIX = '##[';
class Command { class Command {
constructor(command, properties, message) { constructor(command, properties, message) {
if (!command) { if (!command) {
command = 'missing.command'; command = 'missing.command';
} }
this.command = command; this.command = command;
this.properties = properties; this.properties = properties;
this.message = message; this.message = message;
} }
toString() { toString() {
let cmdStr = CMD_PREFIX + this.command; let cmdStr = CMD_PREFIX + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
for (const key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)};`; cmdStr += `${key}=${escape(`${val || ''}`)};`;
} }
} }
} }
} }
cmdStr += ']'; cmdStr += ']';
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
const message = `${this.message || ''}`; const message = `${this.message || ''}`;
cmdStr += escapeData(message); cmdStr += escapeData(message);
return cmdStr; return cmdStr;
} }
} }
function escapeData(s) { function escapeData(s) {
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
} }
function escape(s) { function escape(s) {
return s return s
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
.replace(/]/g, '%5D') .replace(/]/g, '%5D')
.replace(/;/g, '%3B'); .replace(/;/g, '%3B');
} }
//# sourceMappingURL=command.js.map //# sourceMappingURL=command.js.map

View file

@ -1,57 +1,57 @@
/** /**
* Interface for getInput options * Interface for getInput options
*/ */
export interface InputOptions { export interface InputOptions {
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ /** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean; required?: boolean;
} }
/** /**
* sets env variable for this action and future actions in the job * sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable
*/ */
export declare function exportVariable(name: string, val: string): void; export declare function exportVariable(name: string, val: string): void;
/** /**
* exports the variable and registers a secret which will get masked from logs * exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val value of the secret * @param val value of the secret
*/ */
export declare function exportSecret(name: string, val: string): void; export declare function exportSecret(name: string, val: string): void;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath * @param inputPath
*/ */
export declare function addPath(inputPath: string): void; export declare function addPath(inputPath: string): void;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input. The value is also trimmed.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
* @returns string * @returns string
*/ */
export declare function getInput(name: string, options?: InputOptions): string; export declare function getInput(name: string, options?: InputOptions): string;
/** /**
* Sets the action status to neutral * Sets the action status to neutral
*/ */
export declare function setNeutral(): void; export declare function setNeutral(): void;
/** /**
* Sets the action status to failed. * Sets the action status to failed.
* When the action exits it will be with an exit code of 1 * When the action exits it will be with an exit code of 1
* @param message add error issue message * @param message add error issue message
*/ */
export declare function setFailed(message: string): void; export declare function setFailed(message: string): void;
/** /**
* Writes debug message to user log * Writes debug message to user log
* @param message debug message * @param message debug message
*/ */
export declare function debug(message: string): void; export declare function debug(message: string): void;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message * @param message error issue message
*/ */
export declare function error(message: string): void; export declare function error(message: string): void;
/** /**
* Adds an warning issue * Adds an warning issue
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;

View file

@ -1,100 +1,100 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const exit_1 = require("@actions/exit"); const exit_1 = require("@actions/exit");
const command_1 = require("./command"); const command_1 = require("./command");
const path = require("path"); const path = require("path");
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Variables // Variables
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* sets env variable for this action and future actions in the job * sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable
*/ */
function exportVariable(name, val) { function exportVariable(name, val) {
process.env[name] = val; process.env[name] = val;
command_1.issueCommand('set-env', { name }, val); command_1.issueCommand('set-env', { name }, val);
} }
exports.exportVariable = exportVariable; exports.exportVariable = exportVariable;
/** /**
* exports the variable and registers a secret which will get masked from logs * exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val value of the secret * @param val value of the secret
*/ */
function exportSecret(name, val) { function exportSecret(name, val) {
exportVariable(name, val); exportVariable(name, val);
command_1.issueCommand('set-secret', {}, val); command_1.issueCommand('set-secret', {}, val);
} }
exports.exportSecret = exportSecret; exports.exportSecret = exportSecret;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath * @param inputPath
*/ */
function addPath(inputPath) { function addPath(inputPath) {
command_1.issueCommand('add-path', {}, inputPath); command_1.issueCommand('add-path', {}, inputPath);
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
} }
exports.addPath = addPath; exports.addPath = addPath;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input. The value is also trimmed.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
* @returns string * @returns string
*/ */
function getInput(name, options) { function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
return val.trim(); return val.trim();
} }
exports.getInput = getInput; exports.getInput = getInput;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Results // Results
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Sets the action status to neutral * Sets the action status to neutral
*/ */
function setNeutral() { function setNeutral() {
process.exitCode = exit_1.ExitCode.Neutral; process.exitCode = exit_1.ExitCode.Neutral;
} }
exports.setNeutral = setNeutral; exports.setNeutral = setNeutral;
/** /**
* Sets the action status to failed. * Sets the action status to failed.
* When the action exits it will be with an exit code of 1 * When the action exits it will be with an exit code of 1
* @param message add error issue message * @param message add error issue message
*/ */
function setFailed(message) { function setFailed(message) {
process.exitCode = exit_1.ExitCode.Failure; process.exitCode = exit_1.ExitCode.Failure;
error(message); error(message);
} }
exports.setFailed = setFailed; exports.setFailed = setFailed;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Logging Commands // Logging Commands
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Writes debug message to user log * Writes debug message to user log
* @param message debug message * @param message debug message
*/ */
function debug(message) { function debug(message) {
command_1.issueCommand('debug', {}, message); command_1.issueCommand('debug', {}, message);
} }
exports.debug = debug; exports.debug = debug;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message * @param message error issue message
*/ */
function error(message) { function error(message) {
command_1.issue('error', message); command_1.issue('error', message);
} }
exports.error = error; exports.error = error;
/** /**
* Adds an warning issue * Adds an warning issue
* @param message warning issue message * @param message warning issue message
*/ */
function warning(message) { function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message);
} }
exports.warning = warning; exports.warning = warning;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

View file

@ -1,33 +1,29 @@
{ {
"_from": "file:toolkit\\actions-core-0.1.0.tgz", "_from": "file:toolkit\\actions-core-0.0.0.tgz",
"_id": "@actions/core@0.1.0", "_id": "@actions/core@0.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-1I2vFY5r80QcbM1R8Ika5Ke9uWGrF8nl33oQuP3bXVG47wMIw1DdAVK0A17CHJe5ObHU4gpwTuQakUdZaOlg0w==", "_integrity": "sha512-58ituSV1rzBMmmsWoFDnrnsT+Wm4kD/u9NgAGbPvZ7rQHWluYtD5bDbIsjDC6rKFuhqytkxDJPsF/TWBdgc/nA==",
"_location": "/@actions/core", "_location": "/@actions/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "file",
"where": "C:\\Users\\damccorm\\Documents\\setup-node", "where": "C:\\Users\\damccorm\\Documents\\setup-go",
"raw": "@actions/core@file:toolkit/actions-core-0.1.0.tgz", "raw": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
"name": "@actions/core", "name": "@actions/core",
"escapedName": "@actions%2fcore", "escapedName": "@actions%2fcore",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-core-0.1.0.tgz", "rawSpec": "file:toolkit/actions-core-0.0.0.tgz",
"saveSpec": "file:toolkit\\actions-core-0.1.0.tgz", "saveSpec": "file:toolkit\\actions-core-0.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-core-0.1.0.tgz" "fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-core-0.0.0.tgz"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-core-0.1.0.tgz", "_resolved": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-core-0.0.0.tgz",
"_shasum": "a2d7cc689a05e28a677af34e2d69826d2029232c", "_shasum": "346d90a534fa6c5021bc2e1b732574fd2c66fc35",
"_spec": "@actions/core@file:toolkit/actions-core-0.1.0.tgz", "_spec": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"author": {
"name": "Bryan MacFarlane",
"email": "bryanmac@microsoft.com"
},
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
@ -66,5 +62,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "0.1.0" "version": "0.0.0"
} }

12
node_modules/@actions/exec/README.md generated vendored
View file

@ -1,7 +1,7 @@
# `@actions/exec` # `@actions/exec`
> Functions necessary for running tools on the command line > Functions necessary for running tools on the command line
## Usage ## Usage
See [src/exec.ts](src/exec.ts). See [src/exec.ts](src/exec.ts).

View file

@ -1,12 +1,12 @@
import * as im from './interfaces'; import * as im from './interfaces';
/** /**
* Exec a command. * Exec a command.
* Output will be streamed to the live console. * Output will be streamed to the live console.
* Returns promise with return code * Returns promise with return code
* *
* @param commandLine command to execute (can include additional args). Must be correctly escaped. * @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib. * @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions * @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code * @returns Promise<number> exit code
*/ */
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>; export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;

View file

@ -1,36 +1,36 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const tr = require("./toolrunner"); const tr = require("./toolrunner");
/** /**
* Exec a command. * Exec a command.
* Output will be streamed to the live console. * Output will be streamed to the live console.
* Returns promise with return code * Returns promise with return code
* *
* @param commandLine command to execute (can include additional args). Must be correctly escaped. * @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib. * @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions * @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code * @returns Promise<number> exit code
*/ */
function exec(commandLine, args, options) { function exec(commandLine, args, options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const commandArgs = tr.argStringToArray(commandLine); const commandArgs = tr.argStringToArray(commandLine);
if (commandArgs.length === 0) { if (commandArgs.length === 0) {
throw new Error(`Parameter 'commandLine' cannot be null or empty.`); throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
} }
// Path to tool to execute should be first arg // Path to tool to execute should be first arg
const toolPath = commandArgs[0]; const toolPath = commandArgs[0];
args = commandArgs.slice(1).concat(args || []); args = commandArgs.slice(1).concat(args || []);
const runner = new tr.ToolRunner(toolPath, args, options); const runner = new tr.ToolRunner(toolPath, args, options);
return runner.exec(); return runner.exec();
}); });
} }
exports.exec = exec; exports.exec = exec;
//# sourceMappingURL=exec.js.map //# sourceMappingURL=exec.js.map

View file

@ -1,35 +1,35 @@
/// <reference types="node" /> /// <reference types="node" />
import * as stream from 'stream'; import * as stream from 'stream';
/** /**
* Interface for exec options * Interface for exec options
*/ */
export interface ExecOptions { export interface ExecOptions {
/** optional working directory. defaults to current */ /** optional working directory. defaults to current */
cwd?: string; cwd?: string;
/** optional envvar dictionary. defaults to current process's env */ /** optional envvar dictionary. defaults to current process's env */
env?: { env?: {
[key: string]: string; [key: string]: string;
}; };
/** optional. defaults to false */ /** optional. defaults to false */
silent?: boolean; silent?: boolean;
/** optional out stream to use. Defaults to process.stdout */ /** optional out stream to use. Defaults to process.stdout */
outStream?: stream.Writable; outStream?: stream.Writable;
/** optional err stream to use. Defaults to process.stderr */ /** optional err stream to use. Defaults to process.stderr */
errStream?: stream.Writable; errStream?: stream.Writable;
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */ /** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
windowsVerbatimArguments?: boolean; windowsVerbatimArguments?: boolean;
/** optional. whether to fail if output to stderr. defaults to false */ /** optional. whether to fail if output to stderr. defaults to false */
failOnStdErr?: boolean; failOnStdErr?: boolean;
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */ /** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
ignoreReturnCode?: boolean; ignoreReturnCode?: boolean;
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */ /** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
delay?: number; delay?: number;
/** optional. Listeners for output. Callback functions that will be called on these events */ /** optional. Listeners for output. Callback functions that will be called on these events */
listeners?: { listeners?: {
stdout?: (data: Buffer) => void; stdout?: (data: Buffer) => void;
stderr?: (data: Buffer) => void; stderr?: (data: Buffer) => void;
stdline?: (data: string) => void; stdline?: (data: string) => void;
errline?: (data: string) => void; errline?: (data: string) => void;
debug?: (data: string) => void; debug?: (data: string) => void;
}; };
} }

View file

@ -1,3 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map //# sourceMappingURL=interfaces.js.map

View file

@ -1,37 +1,37 @@
/// <reference types="node" /> /// <reference types="node" />
import * as events from 'events'; import * as events from 'events';
import * as im from './interfaces'; import * as im from './interfaces';
export declare class ToolRunner extends events.EventEmitter { export declare class ToolRunner extends events.EventEmitter {
constructor(toolPath: string, args?: string[], options?: im.ExecOptions); constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
private toolPath; private toolPath;
private args; private args;
private options; private options;
private _debug; private _debug;
private _getCommandString; private _getCommandString;
private _processLineBuffer; private _processLineBuffer;
private _getSpawnFileName; private _getSpawnFileName;
private _getSpawnArgs; private _getSpawnArgs;
private _endsWith; private _endsWith;
private _isCmdFile; private _isCmdFile;
private _windowsQuoteCmdArg; private _windowsQuoteCmdArg;
private _uvQuoteCmdArg; private _uvQuoteCmdArg;
private _cloneExecOptions; private _cloneExecOptions;
private _getSpawnOptions; private _getSpawnOptions;
/** /**
* Exec a tool. * Exec a tool.
* Output will be streamed to the live console. * Output will be streamed to the live console.
* Returns promise with return code * Returns promise with return code
* *
* @param tool path to tool to exec * @param tool path to tool to exec
* @param options optional exec options. See ExecOptions * @param options optional exec options. See ExecOptions
* @returns number * @returns number
*/ */
exec(): Promise<number>; exec(): Promise<number>;
} }
/** /**
* Convert an arg string to an array of args. Handles escaping * Convert an arg string to an array of args. Handles escaping
* *
* @param argString string of arguments * @param argString string of arguments
* @returns string[] array of arguments * @returns string[] array of arguments
*/ */
export declare function argStringToArray(argString: string): string[]; export declare function argStringToArray(argString: string): string[];

File diff suppressed because it is too large Load diff

View file

@ -1,33 +1,29 @@
{ {
"_from": "file:toolkit\\actions-exec-1.0.0.tgz", "_from": "file:toolkit\\actions-exec-0.0.0.tgz",
"_id": "@actions/exec@1.0.0", "_id": "@actions/exec@0.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-AxtupsjQceVIf6nEECts5a1pDpWO4r3yq5lpTA73g1FXA0awDdTW3r9NFn8NGF6UaydkIN0BEOasQlS5qS30zg==", "_integrity": "sha512-HHObusC4p1RElxIlrrN0sY/cweBYl+jKm3J/XWHPQZMipgJXB/dkVhUfl4KqH3Vim7oM2KjCGSfn+vTYrqVH3A==",
"_location": "/@actions/exec", "_location": "/@actions/exec",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "file",
"where": "C:\\Users\\damccorm\\Documents\\setup-node", "where": "C:\\Users\\damccorm\\Documents\\setup-go",
"raw": "@actions/exec@file:toolkit/actions-exec-1.0.0.tgz", "raw": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
"name": "@actions/exec", "name": "@actions/exec",
"escapedName": "@actions%2fexec", "escapedName": "@actions%2fexec",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-exec-1.0.0.tgz", "rawSpec": "file:toolkit/actions-exec-0.0.0.tgz",
"saveSpec": "file:toolkit\\actions-exec-1.0.0.tgz", "saveSpec": "file:toolkit\\actions-exec-0.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exec-1.0.0.tgz" "fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-exec-0.0.0.tgz"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exec-1.0.0.tgz", "_resolved": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-exec-0.0.0.tgz",
"_shasum": "6845691df4b14de24cf3b0a45c847070db8f9b6d", "_shasum": "341d868fe6c4123ded20db9c2106b7b8c16e1d73",
"_spec": "@actions/exec@file:toolkit/actions-exec-1.0.0.tgz", "_spec": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"author": {
"name": "Bryan MacFarlane",
"email": "bryanmac@microsoft.com"
},
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
@ -35,7 +31,7 @@
"deprecated": false, "deprecated": false,
"description": "Actions exec lib", "description": "Actions exec lib",
"devDependencies": { "devDependencies": {
"@actions/io": "^1.0.0" "@actions/io": "^0.0.0"
}, },
"directories": { "directories": {
"lib": "lib", "lib": "lib",
@ -63,5 +59,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "0.0.0"
} }

View file

@ -1,7 +1,7 @@
Copyright 2019 GitHub Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12
node_modules/@actions/exit/README.md generated vendored
View file

@ -1,7 +1,7 @@
# `@actions/exit` # `@actions/exit`
> TODO: description > TODO: description
## Usage ## Usage
See [src/exit.ts](src/exit.ts). See [src/exit.ts](src/exit.ts).

View file

@ -1,29 +1,29 @@
/** /**
* The code to exit an action * The code to exit an action
*/ */
export declare enum ExitCode { export declare enum ExitCode {
/** /**
* A code indicating that the action was successful * A code indicating that the action was successful
*/ */
Success = 0, Success = 0,
/** /**
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
Failure = 1, Failure = 1,
/** /**
* A code indicating that the action is complete, but neither succeeded nor failed * A code indicating that the action is complete, but neither succeeded nor failed
*/ */
Neutral = 78 Neutral = 78
} }
/** /**
* Exit the action as a success. * Exit the action as a success.
*/ */
export declare function success(): void; export declare function success(): void;
/** /**
* Exit the action as a failure. * Exit the action as a failure.
*/ */
export declare function failure(): void; export declare function failure(): void;
/** /**
* Exit the action neither a success or a failure * Exit the action neither a success or a failure
*/ */
export declare function neutral(): void; export declare function neutral(): void;

View file

@ -1,44 +1,44 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
/** /**
* The code to exit an action * The code to exit an action
*/ */
var ExitCode; var ExitCode;
(function (ExitCode) { (function (ExitCode) {
/** /**
* A code indicating that the action was successful * A code indicating that the action was successful
*/ */
ExitCode[ExitCode["Success"] = 0] = "Success"; ExitCode[ExitCode["Success"] = 0] = "Success";
/** /**
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
ExitCode[ExitCode["Failure"] = 1] = "Failure"; ExitCode[ExitCode["Failure"] = 1] = "Failure";
/** /**
* A code indicating that the action is complete, but neither succeeded nor failed * A code indicating that the action is complete, but neither succeeded nor failed
*/ */
ExitCode[ExitCode["Neutral"] = 78] = "Neutral"; ExitCode[ExitCode["Neutral"] = 78] = "Neutral";
})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
// TODO: These exit codes may not behave as expected on the new runtime, due to // TODO: These exit codes may not behave as expected on the new runtime, due to
// complexities of async logging and sync exiting. // complexities of async logging and sync exiting.
/** /**
* Exit the action as a success. * Exit the action as a success.
*/ */
function success() { function success() {
process.exit(ExitCode.Success); process.exit(ExitCode.Success);
} }
exports.success = success; exports.success = success;
/** /**
* Exit the action as a failure. * Exit the action as a failure.
*/ */
function failure() { function failure() {
process.exit(ExitCode.Failure); process.exit(ExitCode.Failure);
} }
exports.failure = failure; exports.failure = failure;
/** /**
* Exit the action neither a success or a failure * Exit the action neither a success or a failure
*/ */
function neutral() { function neutral() {
process.exit(ExitCode.Neutral); process.exit(ExitCode.Neutral);
} }
exports.neutral = neutral; exports.neutral = neutral;
//# sourceMappingURL=exit.js.map //# sourceMappingURL=exit.js.map

View file

@ -7,23 +7,23 @@
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "file",
"where": "C:\\Users\\damccorm\\Documents\\setup-node", "where": "C:\\Users\\damccorm\\Documents\\setup-go",
"raw": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz", "raw": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
"name": "@actions/exit", "name": "@actions/exit",
"escapedName": "@actions%2fexit", "escapedName": "@actions%2fexit",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-exit-0.0.0.tgz", "rawSpec": "file:toolkit/actions-exit-0.0.0.tgz",
"saveSpec": "file: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" "fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-exit-0.0.0.tgz"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/core" "/@actions/core"
], ],
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-exit-0.0.0.tgz", "_resolved": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-exit-0.0.0.tgz",
"_shasum": "d47c8c61b45750ae49fea3061e3419a547b2a48f", "_shasum": "d47c8c61b45750ae49fea3061e3419a547b2a48f",
"_spec": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz", "_spec": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },

96
node_modules/@actions/io/README.md generated vendored
View file

@ -1,49 +1,49 @@
# `@actions/io` # `@actions/io`
> Core functions for cli filesystem scenarios > Core functions for cli filesystem scenarios
## Usage ## Usage
``` ```
/** /**
* Copies a file or folder. * Copies a file or folder.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void> export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
/** /**
* Remove a path recursively with force * Remove a path recursively with force
* *
* @param path path to remove * @param path path to remove
*/ */
export function rmRF(path: string): Promise<void> export function rmRF(path: string): Promise<void>
/** /**
* Make a directory. Creates the full path with folders in between * Make a directory. Creates the full path with folders in between
* *
* @param p path to create * @param p path to create
* @returns Promise<void> * @returns Promise<void>
*/ */
export function mkdirP(p: string): Promise<void> export function mkdirP(p: string): Promise<void>
/** /**
* Moves a path. * Moves a path.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void> export function mv(source: string, dest: string, options?: CopyOptions): Promise<void>
/** /**
* Returns path of a tool had the tool actually been invoked. Resolves via paths. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
* *
* @param tool name of the tool * @param tool name of the tool
* @param options optional. See WhichOptions. * @param options optional. See WhichOptions.
* @returns Promise<string> path to tool * @returns Promise<string> path to tool
*/ */
export function which(tool: string, options?: WhichOptions): Promise<string> export function which(tool: string, options?: WhichOptions): Promise<string>
``` ```

View file

@ -1,29 +1,29 @@
/// <reference types="node" /> /// <reference types="node" />
import * as fs from 'fs'; import * as fs from 'fs';
export declare const copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, unlink: typeof fs.promises.unlink; export declare const copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, unlink: typeof fs.promises.unlink;
export declare const IS_WINDOWS: boolean; export declare const IS_WINDOWS: boolean;
export declare function exists(fsPath: string): Promise<boolean>; export declare function exists(fsPath: string): Promise<boolean>;
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>; export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
/** /**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
*/ */
export declare function isRooted(p: string): boolean; export declare function isRooted(p: string): boolean;
/** /**
* Recursively create a directory at `fsPath`. * Recursively create a directory at `fsPath`.
* *
* This implementation is optimistic, meaning it attempts to create the full * This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there. * path first, and backs up the path stack from there.
* *
* @param fsPath The path to create * @param fsPath The path to create
* @param maxDepth The maximum recursion depth * @param maxDepth The maximum recursion depth
* @param depth The current recursion depth * @param depth The current recursion depth
*/ */
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>; export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
/** /**
* Best effort attempt to determine whether a file exists and is executable. * Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check * @param filePath file path to check
* @param extensions additional file extensions to try * @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string. * @return if file exists and is executable, returns the file path. otherwise empty string.
*/ */
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>; export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;

View file

@ -1,194 +1,194 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("assert"); const assert_1 = require("assert");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
_a = fs.promises, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.unlink = _a.unlink; _a = fs.promises, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.unlink = _a.unlink;
exports.IS_WINDOWS = process.platform === 'win32'; exports.IS_WINDOWS = process.platform === 'win32';
function exists(fsPath) { function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
yield exports.stat(fsPath); yield exports.stat(fsPath);
} }
catch (err) { catch (err) {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
return false; return false;
} }
throw err; throw err;
} }
return true; return true;
}); });
} }
exports.exists = exists; exports.exists = exists;
function isDirectory(fsPath, useStat = false) { function isDirectory(fsPath, useStat = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
return stats.isDirectory(); return stats.isDirectory();
}); });
} }
exports.isDirectory = isDirectory; exports.isDirectory = isDirectory;
/** /**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
*/ */
function isRooted(p) { function isRooted(p) {
p = normalizeSeparators(p); p = normalizeSeparators(p);
if (!p) { if (!p) {
throw new Error('isRooted() parameter "p" cannot be empty'); throw new Error('isRooted() parameter "p" cannot be empty');
} }
if (exports.IS_WINDOWS) { if (exports.IS_WINDOWS) {
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
); // e.g. C: or C:\hello ); // e.g. C: or C:\hello
} }
return p.startsWith('/'); return p.startsWith('/');
} }
exports.isRooted = isRooted; exports.isRooted = isRooted;
/** /**
* Recursively create a directory at `fsPath`. * Recursively create a directory at `fsPath`.
* *
* This implementation is optimistic, meaning it attempts to create the full * This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there. * path first, and backs up the path stack from there.
* *
* @param fsPath The path to create * @param fsPath The path to create
* @param maxDepth The maximum recursion depth * @param maxDepth The maximum recursion depth
* @param depth The current recursion depth * @param depth The current recursion depth
*/ */
function mkdirP(fsPath, maxDepth = 1000, depth = 1) { function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(fsPath, 'a path argument must be provided'); assert_1.ok(fsPath, 'a path argument must be provided');
fsPath = path.resolve(fsPath); fsPath = path.resolve(fsPath);
if (depth >= maxDepth) if (depth >= maxDepth)
return exports.mkdir(fsPath); return exports.mkdir(fsPath);
try { try {
yield exports.mkdir(fsPath); yield exports.mkdir(fsPath);
return; return;
} }
catch (err) { catch (err) {
switch (err.code) { switch (err.code) {
case 'ENOENT': { case 'ENOENT': {
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
yield exports.mkdir(fsPath); yield exports.mkdir(fsPath);
return; return;
} }
default: { default: {
let stats; let stats;
try { try {
stats = yield exports.stat(fsPath); stats = yield exports.stat(fsPath);
} }
catch (err2) { catch (err2) {
throw err; throw err;
} }
if (!stats.isDirectory()) if (!stats.isDirectory())
throw err; throw err;
} }
} }
} }
}); });
} }
exports.mkdirP = mkdirP; exports.mkdirP = mkdirP;
/** /**
* Best effort attempt to determine whether a file exists and is executable. * Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check * @param filePath file path to check
* @param extensions additional file extensions to try * @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string. * @return if file exists and is executable, returns the file path. otherwise empty string.
*/ */
function tryGetExecutablePath(filePath, extensions) { function tryGetExecutablePath(filePath, extensions) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let stats = undefined; let stats = undefined;
try { try {
// test file exists // test file exists
stats = yield exports.stat(filePath); stats = yield exports.stat(filePath);
} }
catch (err) { catch (err) {
if (err.code !== 'ENOENT') { if (err.code !== 'ENOENT') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
} }
} }
if (stats && stats.isFile()) { if (stats && stats.isFile()) {
if (exports.IS_WINDOWS) { if (exports.IS_WINDOWS) {
// on Windows, test for valid extension // on Windows, test for valid extension
const upperExt = path.extname(filePath).toUpperCase(); const upperExt = path.extname(filePath).toUpperCase();
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
return filePath; return filePath;
} }
} }
else { else {
if (isUnixExecutable(stats)) { if (isUnixExecutable(stats)) {
return filePath; return filePath;
} }
} }
} }
// try each extension // try each extension
const originalFilePath = filePath; const originalFilePath = filePath;
for (const extension of extensions) { for (const extension of extensions) {
filePath = originalFilePath + extension; filePath = originalFilePath + extension;
stats = undefined; stats = undefined;
try { try {
stats = yield exports.stat(filePath); stats = yield exports.stat(filePath);
} }
catch (err) { catch (err) {
if (err.code !== 'ENOENT') { if (err.code !== 'ENOENT') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
} }
} }
if (stats && stats.isFile()) { if (stats && stats.isFile()) {
if (exports.IS_WINDOWS) { if (exports.IS_WINDOWS) {
// preserve the case of the actual file (since an extension was appended) // preserve the case of the actual file (since an extension was appended)
try { try {
const directory = path.dirname(filePath); const directory = path.dirname(filePath);
const upperName = path.basename(filePath).toUpperCase(); const upperName = path.basename(filePath).toUpperCase();
for (const actualName of yield exports.readdir(directory)) { for (const actualName of yield exports.readdir(directory)) {
if (upperName === actualName.toUpperCase()) { if (upperName === actualName.toUpperCase()) {
filePath = path.join(directory, actualName); filePath = path.join(directory, actualName);
break; break;
} }
} }
} }
catch (err) { catch (err) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
} }
return filePath; return filePath;
} }
else { else {
if (isUnixExecutable(stats)) { if (isUnixExecutable(stats)) {
return filePath; return filePath;
} }
} }
} }
} }
return ''; return '';
}); });
} }
exports.tryGetExecutablePath = tryGetExecutablePath; exports.tryGetExecutablePath = tryGetExecutablePath;
function normalizeSeparators(p) { function normalizeSeparators(p) {
p = p || ''; p = p || '';
if (exports.IS_WINDOWS) { if (exports.IS_WINDOWS) {
// convert slashes on Windows // convert slashes on Windows
p = p.replace(/\//g, '\\'); p = p.replace(/\//g, '\\');
// remove redundant slashes // remove redundant slashes
return p.replace(/\\\\+/g, '\\'); return p.replace(/\\\\+/g, '\\');
} }
// remove redundant slashes // remove redundant slashes
return p.replace(/\/\/+/g, '/'); return p.replace(/\/\/+/g, '/');
} }
// on Mac/Linux, test the execute bit // on Mac/Linux, test the execute bit
// R W X R W X R W X // R W X R W X R W X
// 256 128 64 32 16 8 4 2 1 // 256 128 64 32 16 8 4 2 1
function isUnixExecutable(stats) { function isUnixExecutable(stats) {
return ((stats.mode & 1) > 0 || return ((stats.mode & 1) > 0 ||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) || ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
((stats.mode & 64) > 0 && stats.uid === process.getuid())); ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
} }
//# sourceMappingURL=io-util.js.map //# sourceMappingURL=io-util.js.map

96
node_modules/@actions/io/lib/io.d.ts generated vendored
View file

@ -1,48 +1,48 @@
/** /**
* Interface for cp/mv options * Interface for cp/mv options
*/ */
export interface CopyOptions { export interface CopyOptions {
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */ /** Optional. Whether to recursively copy all subdirectories. Defaults to false */
recursive?: boolean; recursive?: boolean;
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */ /** Optional. Whether to overwrite existing files in the destination. Defaults to true */
force?: boolean; force?: boolean;
} }
/** /**
* Copies a file or folder. * Copies a file or folder.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>; export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
/** /**
* Moves a path. * Moves a path.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
export declare function mv(source: string, dest: string, options?: CopyOptions): Promise<void>; export declare function mv(source: string, dest: string, options?: CopyOptions): Promise<void>;
/** /**
* Remove a path recursively with force * Remove a path recursively with force
* *
* @param inputPath path to remove * @param inputPath path to remove
*/ */
export declare function rmRF(inputPath: string): Promise<void>; export declare function rmRF(inputPath: string): Promise<void>;
/** /**
* Make a directory. Creates the full path with folders in between * Make a directory. Creates the full path with folders in between
* Will throw if it fails * Will throw if it fails
* *
* @param fsPath path to create * @param fsPath path to create
* @returns Promise<void> * @returns Promise<void>
*/ */
export declare function mkdirP(fsPath: string): Promise<void>; export declare function mkdirP(fsPath: string): Promise<void>;
/** /**
* Returns path of a tool had the tool actually been invoked. Resolves via paths. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw. * If you check and the tool does not exist, it will throw.
* *
* @param tool name of the tool * @param tool name of the tool
* @param check whether to check if tool exists * @param check whether to check if tool exists
* @returns Promise<string> path to tool * @returns Promise<string> path to tool
*/ */
export declare function which(tool: string, check?: boolean): Promise<string>; export declare function which(tool: string, check?: boolean): Promise<string>;

522
node_modules/@actions/io/lib/io.js generated vendored
View file

@ -1,262 +1,262 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const childProcess = require("child_process"); const childProcess = require("child_process");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const util_1 = require("util"); const util_1 = require("util");
const ioUtil = require("./io-util"); const ioUtil = require("./io-util");
const exec = util_1.promisify(childProcess.exec); const exec = util_1.promisify(childProcess.exec);
/** /**
* Copies a file or folder. * Copies a file or folder.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
function cp(source, dest, options = {}) { function cp(source, dest, options = {}) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield move(source, dest, options, { deleteOriginal: false }); yield move(source, dest, options, { deleteOriginal: false });
}); });
} }
exports.cp = cp; exports.cp = cp;
/** /**
* Moves a path. * Moves a path.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
function mv(source, dest, options = {}) { function mv(source, dest, options = {}) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield move(source, dest, options, { deleteOriginal: true }); yield move(source, dest, options, { deleteOriginal: true });
}); });
} }
exports.mv = mv; exports.mv = mv;
/** /**
* Remove a path recursively with force * Remove a path recursively with force
* *
* @param inputPath path to remove * @param inputPath path to remove
*/ */
function rmRF(inputPath) { function rmRF(inputPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (ioUtil.IS_WINDOWS) { if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
try { try {
if (yield ioUtil.isDirectory(inputPath, true)) { if (yield ioUtil.isDirectory(inputPath, true)) {
yield exec(`rd /s /q "${inputPath}"`); yield exec(`rd /s /q "${inputPath}"`);
} }
else { else {
yield exec(`del /f /a "${inputPath}"`); yield exec(`del /f /a "${inputPath}"`);
} }
} }
catch (err) { catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved // if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid // other errors are valid
if (err.code !== 'ENOENT') if (err.code !== 'ENOENT')
throw err; throw err;
} }
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try { try {
yield ioUtil.unlink(inputPath); yield ioUtil.unlink(inputPath);
} }
catch (err) { catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved // if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid // other errors are valid
if (err.code !== 'ENOENT') if (err.code !== 'ENOENT')
throw err; throw err;
} }
} }
else { else {
let isDir = false; let isDir = false;
try { try {
isDir = yield ioUtil.isDirectory(inputPath); isDir = yield ioUtil.isDirectory(inputPath);
} }
catch (err) { catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved // if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid // other errors are valid
if (err.code !== 'ENOENT') if (err.code !== 'ENOENT')
throw err; throw err;
return; return;
} }
if (isDir) { if (isDir) {
yield exec(`rm -rf "${inputPath}"`); yield exec(`rm -rf "${inputPath}"`);
} }
else { else {
yield ioUtil.unlink(inputPath); yield ioUtil.unlink(inputPath);
} }
} }
}); });
} }
exports.rmRF = rmRF; exports.rmRF = rmRF;
/** /**
* Make a directory. Creates the full path with folders in between * Make a directory. Creates the full path with folders in between
* Will throw if it fails * Will throw if it fails
* *
* @param fsPath path to create * @param fsPath path to create
* @returns Promise<void> * @returns Promise<void>
*/ */
function mkdirP(fsPath) { function mkdirP(fsPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield ioUtil.mkdirP(fsPath); yield ioUtil.mkdirP(fsPath);
}); });
} }
exports.mkdirP = mkdirP; exports.mkdirP = mkdirP;
/** /**
* Returns path of a tool had the tool actually been invoked. Resolves via paths. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw. * If you check and the tool does not exist, it will throw.
* *
* @param tool name of the tool * @param tool name of the tool
* @param check whether to check if tool exists * @param check whether to check if tool exists
* @returns Promise<string> path to tool * @returns Promise<string> path to tool
*/ */
function which(tool, check) { function which(tool, check) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!tool) { if (!tool) {
throw new Error("parameter 'tool' is required"); throw new Error("parameter 'tool' is required");
} }
// recursive when check=true // recursive when check=true
if (check) { if (check) {
const result = yield which(tool, false); const result = yield which(tool, false);
if (!result) { if (!result) {
if (ioUtil.IS_WINDOWS) { if (ioUtil.IS_WINDOWS) {
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
} }
else { else {
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
} }
} }
} }
try { try {
// build the list of extensions to try // build the list of extensions to try
const extensions = []; const extensions = [];
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
for (const extension of process.env.PATHEXT.split(path.delimiter)) { for (const extension of process.env.PATHEXT.split(path.delimiter)) {
if (extension) { if (extension) {
extensions.push(extension); extensions.push(extension);
} }
} }
} }
// if it's rooted, return it if exists. otherwise return empty. // if it's rooted, return it if exists. otherwise return empty.
if (ioUtil.isRooted(tool)) { if (ioUtil.isRooted(tool)) {
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
if (filePath) { if (filePath) {
return filePath; return filePath;
} }
return ''; return '';
} }
// if any path separators, return empty // if any path separators, return empty
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
return ''; return '';
} }
// build the list of directories // build the list of directories
// //
// Note, technically "where" checks the current directory on Windows. From a task lib perspective, // Note, technically "where" checks the current directory on Windows. From a task lib perspective,
// it feels like we should not do this. Checking the current directory seems like more of a use // it feels like we should not do this. Checking the current directory seems like more of a use
// case of a shell, and the which() function exposed by the task lib should strive for consistency // case of a shell, and the which() function exposed by the task lib should strive for consistency
// across platforms. // across platforms.
const directories = []; const directories = [];
if (process.env.PATH) { if (process.env.PATH) {
for (const p of process.env.PATH.split(path.delimiter)) { for (const p of process.env.PATH.split(path.delimiter)) {
if (p) { if (p) {
directories.push(p); directories.push(p);
} }
} }
} }
// return the first match // return the first match
for (const directory of directories) { for (const directory of directories) {
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
if (filePath) { if (filePath) {
return filePath; return filePath;
} }
} }
return ''; return '';
} }
catch (err) { catch (err) {
throw new Error(`which failed with message ${err.message}`); throw new Error(`which failed with message ${err.message}`);
} }
}); });
} }
exports.which = which; exports.which = which;
// Copies contents of source into dest, making any necessary folders along the way. // Copies contents of source into dest, making any necessary folders along the way.
// Deletes the original copy if deleteOriginal is true // Deletes the original copy if deleteOriginal is true
function copyDirectoryContents(source, dest, force, deleteOriginal = false) { function copyDirectoryContents(source, dest, force, deleteOriginal = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (yield ioUtil.isDirectory(source)) { if (yield ioUtil.isDirectory(source)) {
if (yield ioUtil.exists(dest)) { if (yield ioUtil.exists(dest)) {
if (!(yield ioUtil.isDirectory(dest))) { if (!(yield ioUtil.isDirectory(dest))) {
throw new Error(`${dest} is not a directory`); throw new Error(`${dest} is not a directory`);
} }
} }
else { else {
yield mkdirP(dest); yield mkdirP(dest);
} }
// Copy all child files, and directories recursively // Copy all child files, and directories recursively
const sourceChildren = yield ioUtil.readdir(source); const sourceChildren = yield ioUtil.readdir(source);
for (const newSource of sourceChildren) { for (const newSource of sourceChildren) {
const newDest = path.join(dest, path.basename(newSource)); const newDest = path.join(dest, path.basename(newSource));
yield copyDirectoryContents(path.resolve(source, newSource), newDest, force, deleteOriginal); yield copyDirectoryContents(path.resolve(source, newSource), newDest, force, deleteOriginal);
} }
if (deleteOriginal) { if (deleteOriginal) {
yield ioUtil.rmdir(source); yield ioUtil.rmdir(source);
} }
} }
else { else {
if (force) { if (force) {
yield ioUtil.copyFile(source, dest); yield ioUtil.copyFile(source, dest);
} }
else { else {
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL); yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
} }
if (deleteOriginal) { if (deleteOriginal) {
yield ioUtil.unlink(source); yield ioUtil.unlink(source);
} }
} }
}); });
} }
function move(source, dest, options = {}, moveOptions) { function move(source, dest, options = {}, moveOptions) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { force, recursive } = readCopyOptions(options); const { force, recursive } = readCopyOptions(options);
if (yield ioUtil.isDirectory(source)) { if (yield ioUtil.isDirectory(source)) {
if (!recursive) { if (!recursive) {
throw new Error(`non-recursive cp failed, ${source} is a directory`); throw new Error(`non-recursive cp failed, ${source} is a directory`);
} }
// If directory exists, move source inside it. Otherwise, create it and move contents of source inside. // If directory exists, move source inside it. Otherwise, create it and move contents of source inside.
if (yield ioUtil.exists(dest)) { if (yield ioUtil.exists(dest)) {
if (!(yield ioUtil.isDirectory(dest))) { if (!(yield ioUtil.isDirectory(dest))) {
throw new Error(`${dest} is not a directory`); throw new Error(`${dest} is not a directory`);
} }
dest = path.join(dest, path.basename(source)); dest = path.join(dest, path.basename(source));
} }
yield copyDirectoryContents(source, dest, force, moveOptions.deleteOriginal); yield copyDirectoryContents(source, dest, force, moveOptions.deleteOriginal);
} }
else { else {
if ((yield ioUtil.exists(dest)) && (yield ioUtil.isDirectory(dest))) { if ((yield ioUtil.exists(dest)) && (yield ioUtil.isDirectory(dest))) {
dest = path.join(dest, path.basename(source)); dest = path.join(dest, path.basename(source));
} }
if (force) { if (force) {
yield ioUtil.copyFile(source, dest); yield ioUtil.copyFile(source, dest);
} }
else { else {
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL); yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
} }
if (moveOptions.deleteOriginal) { if (moveOptions.deleteOriginal) {
yield ioUtil.unlink(source); yield ioUtil.unlink(source);
} }
} }
}); });
} }
function readCopyOptions(options) { function readCopyOptions(options) {
const force = options.force == null ? true : options.force; const force = options.force == null ? true : options.force;
const recursive = Boolean(options.recursive); const recursive = Boolean(options.recursive);
return { force, recursive }; return { force, recursive };
} }
//# sourceMappingURL=io.js.map //# sourceMappingURL=io.js.map

View file

@ -1,33 +1,29 @@
{ {
"_from": "file:toolkit\\actions-io-1.0.0.tgz", "_from": "file:toolkit\\actions-io-0.0.0.tgz",
"_id": "@actions/io@1.0.0", "_id": "@actions/io@0.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-Dox3bRCdyxoG0o1mSHt/uINbyQ2SfbhtJmmMuUQny6ARB1hU8ZUi+XR0cHUfd/SrwdzLUrxX4dV8x8ylNSBQpA==", "_integrity": "sha512-BArfobXB/b6RjR4i/+P4UcdaqR2tPjEb2WzZf9GdKiSARQn7d301pKOZAqxA+0N11X07Lk46t/txeUBcrCNbeg==",
"_location": "/@actions/io", "_location": "/@actions/io",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "file",
"where": "C:\\Users\\damccorm\\Documents\\setup-node", "where": "C:\\Users\\damccorm\\Documents\\setup-go",
"raw": "@actions/io@file:toolkit/actions-io-1.0.0.tgz", "raw": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
"name": "@actions/io", "name": "@actions/io",
"escapedName": "@actions%2fio", "escapedName": "@actions%2fio",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-io-1.0.0.tgz", "rawSpec": "file:toolkit/actions-io-0.0.0.tgz",
"saveSpec": "file:toolkit\\actions-io-1.0.0.tgz", "saveSpec": "file:toolkit\\actions-io-0.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-io-1.0.0.tgz" "fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-io-0.0.0.tgz"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-io-1.0.0.tgz", "_resolved": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-io-0.0.0.tgz",
"_shasum": "a395423c226d068e7caced224d51356ad15c41a7", "_shasum": "1e8f0faca6b39215bebacedf473e5bb0716e39bf",
"_spec": "@actions/io@file:toolkit/actions-io-1.0.0.tgz", "_spec": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"author": {
"name": "Danny McCormick",
"email": "damccorm@microsoft.com"
},
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
@ -60,5 +56,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "0.0.0"
} }

View file

@ -1,7 +1,7 @@
# `@actions/tool-cache` # `@actions/tool-cache`
> Functions necessary for downloading and caching tools. > Functions necessary for downloading and caching tools.
## Usage ## Usage
See [src/tool-cache.ts](src/tool-cache.ts). See [src/tool-cache.ts](src/tool-cache.ts).

View file

@ -1,71 +1,78 @@
export declare class HTTPError extends Error { export declare class HTTPError extends Error {
readonly httpStatusCode: number | undefined; readonly httpStatusCode: number | undefined;
constructor(httpStatusCode: number | undefined); constructor(httpStatusCode: number | undefined);
} }
/** /**
* Download a tool from an url and stream it into a file * Download a tool from an url and stream it into a file
* *
* @param url url of tool to download * @param url url of tool to download
* @returns path to downloaded tool * @returns path to downloaded tool
*/ */
export declare function downloadTool(url: string): Promise<string>; export declare function downloadTool(url: string): Promise<string>;
/** /**
* Extract a .7z file * Extract a .7z file
* *
* @param file path to the .7z file * @param file path to the .7z file
* @param dest destination directory. Optional. * @param dest destination directory. Optional.
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
* interface, it is smaller than the full command line interface, and it does support long paths. At the * interface, it is smaller than the full command line interface, and it does support long paths. At the
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
* to 7zr.exe can be pass to this function. * to 7zr.exe can be pass to this function.
* @returns path to the destination directory * @returns path to the destination directory
*/ */
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>; export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
/** /**
* Extract a tar * Extract a tar
* *
* @param file path to the tar * @param file path to the tar
* @param dest destination directory. Optional. * @param dest destination directory. Optional.
* @returns path to the destination directory * @returns path to the destination directory
*/ */
export declare function extractTar(file: string, dest?: string): Promise<string>; export declare function extractTar(file: string, dest?: string): Promise<string>;
/** /**
* Extract a zip * Extract a zip
* *
* @param file path to the zip * @param file path to the zip
* @param dest destination directory. Optional. * @param dest destination directory. Optional.
* @returns path to the destination directory * @returns path to the destination directory
*/ */
export declare function extractZip(file: string, dest?: string): Promise<string>; export declare function extractZip(file: string, dest?: string): Promise<string>;
/** /**
* Caches a directory and installs it into the tool cacheDir * Caches a directory and installs it into the tool cacheDir
* *
* @param sourceDir the directory to cache into tools * @param sourceDir the directory to cache into tools
* @param tool tool name * @param tool tool name
* @param version version of the tool. semver format * @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture * @param arch architecture of the tool. Optional. Defaults to machine architecture
*/ */
export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>; export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
/** /**
* Caches a downloaded file (GUID) and installs it * Caches a downloaded file (GUID) and installs it
* into the tool cache with a given targetName * into the tool cache with a given targetName
* *
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
* @param targetFile the name of the file name in the tools directory * @param targetFile the name of the file name in the tools directory
* @param tool tool name * @param tool tool name
* @param version version of the tool. semver format * @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture * @param arch architecture of the tool. Optional. Defaults to machine architecture
*/ */
export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>; export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>;
/** /**
* finds the path to a tool in the local installed tool cache * Finds the path to a tool version in the local installed tool cache
* *
* @param toolName name of the tool * @param toolName name of the tool
* @param versionSpec version of the tool * @param versionSpec version of the tool
* @param arch optional arch. defaults to arch of computer * @param arch optional arch. defaults to arch of computer
*/ */
export declare function find(toolName: string, versionSpec: string, arch?: string): string; export declare function find(toolName: string, versionSpec: string, arch?: string): string;
/**
* Finds the paths to all versions of a tool that are installed in the local tool cache
*
* @param toolName name of the tool
* @param arch optional arch. defaults to arch of computer
*/
export declare function findAllVersions(toolName: string, arch?: string): string[];

View file

@ -1,431 +1,436 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = require("@actions/core"); const core = require("@actions/core");
const io = require("@actions/io"); const io = require("@actions/io");
const fs = require("fs"); const fs = require("fs");
const os = require("os"); const os = require("os");
const path = require("path"); const path = require("path");
const httpm = require("typed-rest-client/HttpClient"); const httpm = require("typed-rest-client/HttpClient");
const semver = require("semver"); const semver = require("semver");
const uuidV4 = require("uuid/v4"); const uuidV4 = require("uuid/v4");
const exec_1 = require("@actions/exec/lib/exec"); const exec_1 = require("@actions/exec/lib/exec");
const assert_1 = require("assert"); const assert_1 = require("assert");
class HTTPError extends Error { class HTTPError extends Error {
constructor(httpStatusCode) { constructor(httpStatusCode) {
super(`Unexpected HTTP response: ${httpStatusCode}`); super(`Unexpected HTTP response: ${httpStatusCode}`);
this.httpStatusCode = httpStatusCode; this.httpStatusCode = httpStatusCode;
Object.setPrototypeOf(this, new.target.prototype); Object.setPrototypeOf(this, new.target.prototype);
} }
} }
exports.HTTPError = HTTPError; exports.HTTPError = HTTPError;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const userAgent = 'actions/tool-cache'; 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) // 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 tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
let cacheRoot = process.env['RUNNER_TOOLSDIRECTORY'] || ''; let cacheRoot = process.env['RUNNER_TOOLSDIRECTORY'] || '';
process.env['RUNNER_TEMPDIRECTORY'] = ''; // If directories not found, place them in common temp locations
process.env['RUNNER_TOOLSDIRECTORY'] = ''; if (!tempDirectory || !cacheRoot) {
// If directories not found, place them in common temp locations let baseLocation;
if (!tempDirectory || !cacheRoot) { if (IS_WINDOWS) {
let baseLocation; // On windows use the USERPROFILE env variable
if (IS_WINDOWS) { baseLocation = process.env['USERPROFILE'] || 'C:\\';
// On windows use the USERPROFILE env variable }
baseLocation = process.env['USERPROFILE'] || 'C:\\'; else {
} if (process.platform === 'darwin') {
else { baseLocation = '/Users';
if (process.platform === 'darwin') { }
baseLocation = '/Users'; else {
} baseLocation = '/home';
else { }
baseLocation = '/home'; }
} if (!tempDirectory) {
} tempDirectory = path.join(baseLocation, 'actions', 'temp');
if (!tempDirectory) { }
tempDirectory = path.join(baseLocation, 'actions', 'temp'); if (!cacheRoot) {
} cacheRoot = path.join(baseLocation, 'actions', 'cache');
if (!cacheRoot) { }
cacheRoot = path.join(baseLocation, 'actions', 'cache'); }
} /**
} * Download a tool from an url and stream it into a file
/** *
* Download a tool from an url and stream it into a file * @param url url of tool to download
* * @returns path to downloaded tool
* @param url url of tool to download */
* @returns path to downloaded tool function downloadTool(url) {
*/ return __awaiter(this, void 0, void 0, function* () {
function downloadTool(url) { // Wrap in a promise so that we can resolve from within stream callbacks
return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
// Wrap in a promise so that we can resolve from within stream callbacks try {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { const http = new httpm.HttpClient(userAgent, [], {
try { allowRetries: true,
const http = new httpm.HttpClient(userAgent, [], { maxRetries: 3
allowRetries: true, });
maxRetries: 3 const destPath = path.join(tempDirectory, uuidV4());
}); yield io.mkdirP(tempDirectory);
const destPath = path.join(tempDirectory, uuidV4()); core.debug(`Downloading ${url}`);
yield io.mkdirP(tempDirectory); core.debug(`Downloading ${destPath}`);
core.debug(`Downloading ${url}`); if (fs.existsSync(destPath)) {
core.debug(`Downloading ${destPath}`); throw new Error(`Destination file path ${destPath} already exists`);
if (fs.existsSync(destPath)) { }
throw new Error(`Destination file path ${destPath} already exists`); const response = yield http.get(url);
} if (response.message.statusCode !== 200) {
const response = yield http.get(url); const err = new HTTPError(response.message.statusCode);
if (response.message.statusCode !== 200) { core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
const err = new HTTPError(response.message.statusCode); throw err;
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); }
throw err; const file = fs.createWriteStream(destPath);
} file.on('open', () => __awaiter(this, void 0, void 0, function* () {
const file = fs.createWriteStream(destPath); try {
file.on('open', () => __awaiter(this, void 0, void 0, function* () { const stream = response.message.pipe(file);
try { stream.on('close', () => {
const stream = response.message.pipe(file); core.debug('download complete');
stream.on('close', () => { resolve(destPath);
core.debug('download complete'); });
resolve(destPath); }
}); catch (err) {
} core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
catch (err) { reject(err);
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); }
reject(err); }));
} file.on('error', err => {
})); file.end();
file.on('error', err => { reject(err);
file.end(); });
reject(err); }
}); catch (err) {
} reject(err);
catch (err) { }
reject(err); }));
} });
})); }
}); exports.downloadTool = downloadTool;
} /**
exports.downloadTool = downloadTool; * Extract a .7z file
/** *
* Extract a .7z file * @param file path to the .7z file
* * @param dest destination directory. Optional.
* @param file path to the .7z file * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
* @param dest destination directory. Optional. * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is * interface, it is smaller than the full command line interface, and it does support long paths. At the
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
* interface, it is smaller than the full command line interface, and it does support long paths. At the * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. * to 7zr.exe can be pass to this function.
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path * @returns path to the destination directory
* to 7zr.exe can be pass to this function. */
* @returns path to the destination directory function extract7z(file, dest, _7zPath) {
*/ return __awaiter(this, void 0, void 0, function* () {
function extract7z(file, dest, _7zPath) { assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
return __awaiter(this, void 0, void 0, function* () { assert_1.ok(file, 'parameter "file" is required');
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); dest = dest || (yield _createExtractFolder(dest));
assert_1.ok(file, 'parameter "file" is required'); const originalCwd = process.cwd();
dest = dest || (yield _createExtractFolder(dest)); process.chdir(dest);
const originalCwd = process.cwd(); if (_7zPath) {
process.chdir(dest); try {
if (_7zPath) { const args = [
try { 'x',
const args = [ '-bb1',
'x', '-bd',
'-bb1', '-sccUTF-8',
'-bd', file
'-sccUTF-8', ];
file const options = {
]; silent: true
const options = { };
silent: true yield exec_1.exec(`"${_7zPath}"`, args, options);
}; }
yield exec_1.exec(`"${_7zPath}"`, args, options); finally {
} process.chdir(originalCwd);
finally { }
process.chdir(originalCwd); }
} else {
} const escapedScript = path
else { .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
const escapedScript = path .replace(/'/g, "''")
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
.replace(/'/g, "''") const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); const args = [
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; '-NoLogo',
const args = [ '-Sta',
'-NoLogo', '-NoProfile',
'-Sta', '-NonInteractive',
'-NoProfile', '-ExecutionPolicy',
'-NonInteractive', 'Unrestricted',
'-ExecutionPolicy', '-Command',
'Unrestricted', command
'-Command', ];
command const options = {
]; silent: true
const options = { };
silent: true try {
}; const powershellPath = yield io.which('powershell', true);
try { yield exec_1.exec(`"${powershellPath}"`, args, options);
const powershellPath = yield io.which('powershell', true); }
yield exec_1.exec(`"${powershellPath}"`, args, options); finally {
} process.chdir(originalCwd);
finally { }
process.chdir(originalCwd); }
} return dest;
} });
return dest; }
}); exports.extract7z = extract7z;
} /**
exports.extract7z = extract7z; * Extract a tar
/** *
* Extract a tar * @param file path to the tar
* * @param dest destination directory. Optional.
* @param file path to the tar * @returns path to the destination directory
* @param dest destination directory. Optional. */
* @returns path to the destination directory function extractTar(file, dest) {
*/ return __awaiter(this, void 0, void 0, function* () {
function extractTar(file, dest) { if (!file) {
return __awaiter(this, void 0, void 0, function* () { throw new Error("parameter 'file' is required");
if (!file) { }
throw new Error("parameter 'file' is required"); dest = dest || (yield _createExtractFolder(dest));
} const tarPath = yield io.which('tar', true);
dest = dest || (yield _createExtractFolder(dest)); yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]);
const tarPath = yield io.which('tar', true); return dest;
yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]); });
return dest; }
}); exports.extractTar = extractTar;
} /**
exports.extractTar = extractTar; * Extract a zip
/** *
* Extract a zip * @param file path to the zip
* * @param dest destination directory. Optional.
* @param file path to the zip * @returns path to the destination directory
* @param dest destination directory. Optional. */
* @returns path to the destination directory function extractZip(file, dest) {
*/ return __awaiter(this, void 0, void 0, function* () {
function extractZip(file, dest) { if (!file) {
return __awaiter(this, void 0, void 0, function* () { throw new Error("parameter 'file' is required");
if (!file) { }
throw new Error("parameter 'file' is required"); dest = dest || (yield _createExtractFolder(dest));
} if (IS_WINDOWS) {
dest = dest || (yield _createExtractFolder(dest)); yield extractZipWin(file, dest);
if (IS_WINDOWS) { }
yield extractZipWin(file, dest); else {
} yield extractZipNix(file, dest);
else { }
yield extractZipNix(file, dest); return dest;
} });
return dest; }
}); exports.extractZip = extractZip;
} function extractZipWin(file, dest) {
exports.extractZip = extractZip; return __awaiter(this, void 0, void 0, function* () {
function extractZipWin(file, dest) { // build the powershell command
return __awaiter(this, void 0, void 0, function* () { const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
// build the powershell command const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // run powershell
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; const powershellPath = yield io.which('powershell');
// run powershell const args = [
const powershellPath = yield io.which('powershell'); '-NoLogo',
const args = [ '-Sta',
'-NoLogo', '-NoProfile',
'-Sta', '-NonInteractive',
'-NoProfile', '-ExecutionPolicy',
'-NonInteractive', 'Unrestricted',
'-ExecutionPolicy', '-Command',
'Unrestricted', command
'-Command', ];
command yield exec_1.exec(`"${powershellPath}"`, args);
]; });
yield exec_1.exec(`"${powershellPath}"`, args); }
}); function extractZipNix(file, dest) {
} return __awaiter(this, void 0, void 0, function* () {
function extractZipNix(file, dest) { const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
return __awaiter(this, void 0, void 0, function* () { yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
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
/** *
* Caches a directory and installs it into the tool cacheDir * @param sourceDir the directory to cache into tools
* * @param tool tool name
* @param sourceDir the directory to cache into tools * @param version version of the tool. semver format
* @param tool tool name * @param arch architecture of the tool. Optional. Defaults to machine architecture
* @param version version of the tool. semver format */
* @param arch architecture of the tool. Optional. Defaults to machine architecture function cacheDir(sourceDir, tool, version, arch) {
*/ return __awaiter(this, void 0, void 0, function* () {
function cacheDir(sourceDir, tool, version, arch) { version = semver.clean(version) || version;
return __awaiter(this, void 0, void 0, function* () { arch = arch || os.arch();
version = semver.clean(version) || version; core.debug(`Caching tool ${tool} ${version} ${arch}`);
arch = arch || os.arch(); core.debug(`source dir: ${sourceDir}`);
core.debug(`Caching tool ${tool} ${version} ${arch}`); if (!fs.statSync(sourceDir).isDirectory()) {
core.debug(`source dir: ${sourceDir}`); throw new Error('sourceDir is not a directory');
if (!fs.statSync(sourceDir).isDirectory()) { }
throw new Error('sourceDir is not a directory'); // Create the tool dir
} const destPath = yield _createToolPath(tool, version, arch);
// Create the tool dir // copy each child item. do not move. move can fail on Windows
const destPath = yield _createToolPath(tool, version, arch); // due to anti-virus software having an open handle on a file.
// copy each child item. do not move. move can fail on Windows for (const itemName of fs.readdirSync(sourceDir)) {
// due to anti-virus software having an open handle on a file. const s = path.join(sourceDir, itemName);
for (const itemName of fs.readdirSync(sourceDir)) { yield io.cp(s, destPath, { recursive: true });
const s = path.join(sourceDir, itemName); }
yield io.cp(s, destPath, { recursive: true }); // write .complete
} _completeToolPath(tool, version, arch);
// write .complete return destPath;
_completeToolPath(tool, version, arch); });
return destPath; }
}); exports.cacheDir = cacheDir;
} /**
exports.cacheDir = cacheDir; * Caches a downloaded file (GUID) and installs it
/** * into the tool cache with a given targetName
* Caches a downloaded file (GUID) and installs it *
* into the tool cache with a given targetName * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
* * @param targetFile the name of the file name in the tools directory
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. * @param tool tool name
* @param targetFile the name of the file name in the tools directory * @param version version of the tool. semver format
* @param tool tool name * @param arch architecture of the tool. Optional. Defaults to machine architecture
* @param version version of the tool. semver format */
* @param arch architecture of the tool. Optional. Defaults to machine architecture function cacheFile(sourceFile, targetFile, tool, version, arch) {
*/ return __awaiter(this, void 0, void 0, function* () {
function cacheFile(sourceFile, targetFile, tool, version, arch) { version = semver.clean(version) || version;
return __awaiter(this, void 0, void 0, function* () { arch = arch || os.arch();
version = semver.clean(version) || version; core.debug(`Caching tool ${tool} ${version} ${arch}`);
arch = arch || os.arch(); core.debug(`source file: ${sourceFile}`);
core.debug(`Caching tool ${tool} ${version} ${arch}`); if (!fs.statSync(sourceFile).isFile()) {
core.debug(`source file: ${sourceFile}`); throw new Error('sourceFile is not a file');
if (!fs.statSync(sourceFile).isFile()) { }
throw new Error('sourceFile is not a file'); // create the tool dir
} const destFolder = yield _createToolPath(tool, version, arch);
// create the tool dir // copy instead of move. move can fail on Windows due to
const destFolder = yield _createToolPath(tool, version, arch); // anti-virus software having an open handle on a file.
// copy instead of move. move can fail on Windows due to const destPath = path.join(destFolder, targetFile);
// anti-virus software having an open handle on a file. core.debug(`destination file ${destPath}`);
const destPath = path.join(destFolder, targetFile); yield io.cp(sourceFile, destPath);
core.debug(`destination file ${destPath}`); // write .complete
yield io.cp(sourceFile, destPath); _completeToolPath(tool, version, arch);
// write .complete return destFolder;
_completeToolPath(tool, version, arch); });
return destFolder; }
}); exports.cacheFile = cacheFile;
} /**
exports.cacheFile = cacheFile; * Finds the path to a tool version in the local installed tool cache
/** *
* finds the path to a tool in the local installed tool cache * @param toolName name of the tool
* * @param versionSpec version of the tool
* @param toolName name of the tool * @param arch optional arch. defaults to arch of computer
* @param versionSpec version of the tool */
* @param arch optional arch. defaults to arch of computer function find(toolName, versionSpec, arch) {
*/ if (!toolName) {
function find(toolName, versionSpec, arch) { throw new Error('toolName parameter is required');
if (!toolName) { }
throw new Error('toolName parameter is required'); if (!versionSpec) {
} throw new Error('versionSpec parameter is required');
if (!versionSpec) { }
throw new Error('versionSpec parameter is required'); arch = arch || os.arch();
} // attempt to resolve an explicit version
arch = arch || os.arch(); if (!_isExplicitVersion(versionSpec)) {
// attempt to resolve an explicit version const localVersions = findAllVersions(toolName, arch);
if (!_isExplicitVersion(versionSpec)) { const match = _evaluateVersions(localVersions, versionSpec);
const localVersions = _findLocalToolVersions(toolName, arch); versionSpec = match;
const match = _evaluateVersions(localVersions, versionSpec); }
versionSpec = match; // check for the explicit version in the cache
} let toolPath = '';
// check for the explicit version in the cache if (versionSpec) {
let toolPath = ''; versionSpec = semver.clean(versionSpec) || '';
if (versionSpec) { const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
versionSpec = semver.clean(versionSpec) || ''; core.debug(`checking cache: ${cachePath}`);
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch); if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
core.debug(`checking cache: ${cachePath}`); core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { toolPath = cachePath;
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); }
toolPath = cachePath; else {
} core.debug('not found');
else { }
core.debug('not found'); }
} return toolPath;
} }
return toolPath; exports.find = find;
} /**
exports.find = find; * Finds the paths to all versions of a tool that are installed in the local tool cache
function _createExtractFolder(dest) { *
return __awaiter(this, void 0, void 0, function* () { * @param toolName name of the tool
if (!dest) { * @param arch optional arch. defaults to arch of computer
// create a temp dir */
dest = path.join(tempDirectory, uuidV4()); function findAllVersions(toolName, arch) {
} const versions = [];
yield io.mkdirP(dest); arch = arch || os.arch();
return dest; const toolPath = path.join(cacheRoot, toolName);
}); if (fs.existsSync(toolPath)) {
} const children = fs.readdirSync(toolPath);
function _createToolPath(tool, version, arch) { for (const child of children) {
return __awaiter(this, void 0, void 0, function* () { if (_isExplicitVersion(child)) {
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); const fullPath = path.join(toolPath, child, arch || '');
core.debug(`destination ${folderPath}`); if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
const markerPath = `${folderPath}.complete`; versions.push(child);
yield io.rmRF(folderPath); }
yield io.rmRF(markerPath); }
yield io.mkdirP(folderPath); }
return folderPath; }
}); return versions;
} }
function _completeToolPath(tool, version, arch) { exports.findAllVersions = findAllVersions;
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); function _createExtractFolder(dest) {
const markerPath = `${folderPath}.complete`; return __awaiter(this, void 0, void 0, function* () {
fs.writeFileSync(markerPath, ''); if (!dest) {
core.debug('finished caching tool'); // create a temp dir
} dest = path.join(tempDirectory, uuidV4());
function _isExplicitVersion(versionSpec) { }
const c = semver.clean(versionSpec) || ''; yield io.mkdirP(dest);
core.debug(`isExplicit: ${c}`); return dest;
const valid = semver.valid(c) != null; });
core.debug(`explicit? ${valid}`); }
return valid; function _createToolPath(tool, version, arch) {
} return __awaiter(this, void 0, void 0, function* () {
function _evaluateVersions(versions, versionSpec) { const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
let version = ''; core.debug(`destination ${folderPath}`);
core.debug(`evaluating ${versions.length} versions`); const markerPath = `${folderPath}.complete`;
versions = versions.sort((a, b) => { yield io.rmRF(folderPath);
if (semver.gt(a, b)) { yield io.rmRF(markerPath);
return 1; yield io.mkdirP(folderPath);
} return folderPath;
return -1; });
}); }
for (let i = versions.length - 1; i >= 0; i--) { function _completeToolPath(tool, version, arch) {
const potential = versions[i]; const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
const satisfied = semver.satisfies(potential, versionSpec); const markerPath = `${folderPath}.complete`;
if (satisfied) { fs.writeFileSync(markerPath, '');
version = potential; core.debug('finished caching tool');
break; }
} function _isExplicitVersion(versionSpec) {
} const c = semver.clean(versionSpec) || '';
if (version) { core.debug(`isExplicit: ${c}`);
core.debug(`matched: ${version}`); const valid = semver.valid(c) != null;
} core.debug(`explicit? ${valid}`);
else { return valid;
core.debug('match not found'); }
} function _evaluateVersions(versions, versionSpec) {
return version; let version = '';
} core.debug(`evaluating ${versions.length} versions`);
function _findLocalToolVersions(toolName, arch) { versions = versions.sort((a, b) => {
const versions = []; if (semver.gt(a, b)) {
arch = arch || os.arch(); return 1;
const toolPath = path.join(cacheRoot, toolName); }
if (fs.existsSync(toolPath)) { return -1;
const children = fs.readdirSync(toolPath); });
for (const child of children) { for (let i = versions.length - 1; i >= 0; i--) {
if (_isExplicitVersion(child)) { const potential = versions[i];
const fullPath = path.join(toolPath, child, arch || ''); const satisfied = semver.satisfies(potential, versionSpec);
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { if (satisfied) {
versions.push(child); version = potential;
} break;
} }
} }
} if (version) {
return versions; core.debug(`matched: ${version}`);
} }
else {
core.debug('match not found');
}
return version;
}
//# sourceMappingURL=tool-cache.js.map //# sourceMappingURL=tool-cache.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,44 +1,41 @@
{ {
"_args": [ "_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
[ "_id": "@actions/tool-cache@0.0.0",
"@actions/tool-cache@file:toolkit\\actions-tool-cache-1.0.0.tgz",
"C:\\Users\\damccorm\\Documents\\setup-node"
]
],
"_from": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
"_id": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-hx8Z1ip11aZVA47uSCIB7Y9ec4Ty9zNPUyFyBsr0YI5vJ64TR/JoySbr0ck7l2EI0zqYAdef11Ynwz/qUkXVyg==", "_integrity": "sha512-NavDg5VFXDfbe9TpFuj+uOHacjg1bT3Wmo3DQuul3gsGRBEXyzhh2MWKnBZs/Zh7FE3prLmIqpbtymafNBFkIA==",
"_location": "/@actions/tool-cache", "_location": "/@actions/tool-cache",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "file",
"where": "C:\\Users\\damccorm\\Documents\\setup-node", "where": "C:\\Users\\damccorm\\Documents\\setup-go",
"raw": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz", "raw": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
"name": "@actions/tool-cache", "name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache", "escapedName": "@actions%2ftool-cache",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-tool-cache-1.0.0.tgz", "rawSpec": "file:toolkit/actions-tool-cache-0.0.0.tgz",
"saveSpec": "file:toolkit\\actions-tool-cache-1.0.0.tgz", "saveSpec": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz" "fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-tool-cache-0.0.0.tgz"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": false, "_resolved": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-tool-cache-0.0.0.tgz",
"_spec": "file:toolkit/actions-tool-cache-1.0.0.tgz", "_shasum": "fa216c10f724010a74602fd14881f25f5b008070",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
"_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@actions/core": "^0.1.0", "@actions/core": "^0.0.0",
"@actions/exec": "^1.0.0", "@actions/exec": "^0.0.0",
"@actions/io": "^1.0.0", "@actions/io": "^0.0.0",
"semver": "^6.1.0", "semver": "^6.1.0",
"typed-rest-client": "^1.4.0", "typed-rest-client": "^1.4.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"deprecated": false,
"description": "Actions tool-cache lib", "description": "Actions tool-cache lib",
"devDependencies": { "devDependencies": {
"@types/nock": "^10.0.3", "@types/nock": "^10.0.3",
@ -73,5 +70,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "0.0.0"
} }

View file

@ -1,60 +1,60 @@
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$Source, [string]$Source,
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$Target) [string]$Target)
# This script translates the output from 7zdec into UTF8. Node has limited # This script translates the output from 7zdec into UTF8. Node has limited
# built-in support for encodings. # built-in support for encodings.
# #
# 7zdec uses the system default code page. The system default code page varies # 7zdec uses the system default code page. The system default code page varies
# depending on the locale configuration. On an en-US box, the system default code # depending on the locale configuration. On an en-US box, the system default code
# page is Windows-1252. # page is Windows-1252.
# #
# Note, on a typical en-US box, testing with the 'ç' character is a good way to # Note, on a typical en-US box, testing with the 'ç' character is a good way to
# determine whether data is passed correctly between processes. This is because # determine whether data is passed correctly between processes. This is because
# the 'ç' character has a different code point across each of the common encodings # the 'ç' character has a different code point across each of the common encodings
# on a typical en-US box, i.e. # on a typical en-US box, i.e.
# 1) the default console-output code page (IBM437) # 1) the default console-output code page (IBM437)
# 2) the system default code page (i.e. CP_ACP) (Windows-1252) # 2) the system default code page (i.e. CP_ACP) (Windows-1252)
# 3) UTF8 # 3) UTF8
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default. # Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
$stdout = [System.Console]::OpenStandardOutput() $stdout = [System.Console]::OpenStandardOutput()
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM $utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM
$writer = New-Object System.IO.StreamWriter($stdout, $utf8) $writer = New-Object System.IO.StreamWriter($stdout, $utf8)
[System.Console]::SetOut($writer) [System.Console]::SetOut($writer)
# All subsequent output must be written using [System.Console]::WriteLine(). In # All subsequent output must be written using [System.Console]::WriteLine(). In
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer. # PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
Set-Location -LiteralPath $Target Set-Location -LiteralPath $Target
# Print the ##command. # Print the ##command.
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe" $_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"") [System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
# The $OutputEncoding variable instructs PowerShell how to interpret the output # The $OutputEncoding variable instructs PowerShell how to interpret the output
# from the external command. # from the external command.
$OutputEncoding = [System.Text.Encoding]::Default $OutputEncoding = [System.Text.Encoding]::Default
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe # Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe
# will launch the external command in such a way that it inherits the streams. # will launch the external command in such a way that it inherits the streams.
& $_7zdec x $Source 2>&1 | & $_7zdec x $Source 2>&1 |
ForEach-Object { ForEach-Object {
if ($_ -is [System.Management.Automation.ErrorRecord]) { if ($_ -is [System.Management.Automation.ErrorRecord]) {
[System.Console]::WriteLine($_.Exception.Message) [System.Console]::WriteLine($_.Exception.Message)
} }
else { else {
[System.Console]::WriteLine($_) [System.Console]::WriteLine($_)
} }
} }
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'") [System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'")
[System.Console]::Out.Flush() [System.Console]::Out.Flush()
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE exit $LASTEXITCODE
} }

31
node_modules/semver/package.json generated vendored
View file

@ -1,40 +1,37 @@
{ {
"_args": [ "_from": "semver@^6.1.1",
[ "_id": "semver@6.1.2",
"semver@6.1.1",
"C:\\Users\\damccorm\\Documents\\setup-node"
]
],
"_from": "semver@6.1.1",
"_id": "semver@6.1.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", "_integrity": "sha512-z4PqiCpomGtWj8633oeAdXm1Kn1W++3T8epkZYnwiVgIYIJ0QHszhInYSJTYxebByQH7KVCEAn8R9duzZW2PhQ==",
"_location": "/semver", "_location": "/semver",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "semver@6.1.1", "raw": "semver@^6.1.1",
"name": "semver", "name": "semver",
"escapedName": "semver", "escapedName": "semver",
"rawSpec": "6.1.1", "rawSpec": "^6.1.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "6.1.1" "fetchSpec": "^6.1.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache", "/@actions/tool-cache",
"/istanbul-lib-instrument" "/istanbul-lib-instrument"
], ],
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", "_resolved": "https://registry.npmjs.org/semver/-/semver-6.1.2.tgz",
"_spec": "6.1.1", "_shasum": "079960381376a3db62eb2edc8a3bfb10c7cfe318",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node", "_spec": "semver@^6.1.1",
"_where": "C:\\Users\\damccorm\\Documents\\setup-go",
"bin": { "bin": {
"semver": "./bin/semver" "semver": "./bin/semver"
}, },
"bugs": { "bugs": {
"url": "https://github.com/npm/node-semver/issues" "url": "https://github.com/npm/node-semver/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "The semantic version parser used by npm.", "description": "The semantic version parser used by npm.",
"devDependencies": { "devDependencies": {
"tap": "^14.1.6" "tap": "^14.1.6"
@ -61,5 +58,5 @@
"tap": { "tap": {
"check-coverage": true "check-coverage": true
}, },
"version": "6.1.1" "version": "6.1.2"
} }

12
node_modules/semver/semver.js generated vendored
View file

@ -810,7 +810,11 @@ Comparator.prototype.test = function (version) {
} }
if (typeof version === 'string') { if (typeof version === 'string') {
version = new SemVer(version, this.options) try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
} }
return cmp(version, this.operator, this.semver, this.options) return cmp(version, this.operator, this.semver, this.options)
@ -1261,7 +1265,11 @@ Range.prototype.test = function (version) {
} }
if (typeof version === 'string') { if (typeof version === 'string') {
version = new SemVer(version, this.options) try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
} }
for (var i = 0; i < this.set.length; i++) { for (var i = 0; i < this.set.length; i++) {

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", "_resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz",
"_shasum": "2d3785a158c174c9a16dc2c046ec5fc5f1742213", "_shasum": "2d3785a158c174c9a16dc2c046ec5fc5f1742213",
"_spec": "tunnel@0.0.4", "_spec": "tunnel@0.0.4",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node\\node_modules\\typed-rest-client", "_where": "C:\\Users\\damccorm\\Documents\\setup-go\\node_modules\\typed-rest-client",
"author": { "author": {
"name": "Koichi Kobayashi", "name": "Koichi Kobayashi",
"email": "koichik@improvement.jp" "email": "koichik@improvement.jp"

View file

@ -13,8 +13,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
const url = require("url"); const url = require("url");
const http = require("http"); const http = require("http");
const https = require("https"); const https = require("https");
const tunnel = require("tunnel"); let fs;
const fs = require("fs"); let tunnel;
var HttpCodes; var HttpCodes;
(function (HttpCodes) { (function (HttpCodes) {
HttpCodes[HttpCodes["OK"] = 200] = "OK"; HttpCodes[HttpCodes["OK"] = 200] = "OK";
@ -101,15 +101,19 @@ class HttpClient {
}); });
} }
this._certConfig = requestOptions.cert; this._certConfig = requestOptions.cert;
// cache the cert content into memory, so we don't have to read it from disk every time if (this._certConfig) {
if (this._certConfig && this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) { // If using cert, need fs
this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8'); fs = require('fs');
} // cache the cert content into memory, so we don't have to read it from disk every time
if (this._certConfig && this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) { if (this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) {
this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8'); this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8');
} }
if (this._certConfig && this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) { if (this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) {
this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8'); this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8');
}
if (this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) {
this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8');
}
} }
if (requestOptions.allowRedirects != null) { if (requestOptions.allowRedirects != null) {
this._allowRedirects = requestOptions.allowRedirects; this._allowRedirects = requestOptions.allowRedirects;
@ -354,6 +358,10 @@ class HttpClient {
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
} }
if (useProxy) { if (useProxy) {
// If using proxy, need tunnel
if (!tunnel) {
tunnel = require('tunnel');
}
const agentOptions = { const agentOptions = {
maxSockets: maxSockets, maxSockets: maxSockets,
keepAlive: this._keepAlive, keepAlive: this._keepAlive,

View file

@ -1,8 +1,8 @@
{ {
"_from": "typed-rest-client@^1.4.0", "_from": "typed-rest-client@^1.4.0",
"_id": "typed-rest-client@1.4.0", "_id": "typed-rest-client@1.5.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-f+3+X13CIpkv0WvFERkXq4aH5BYzyeYclf8t+X7oa/YaE80EjYW12kphY0aEQBaL9RzChP0MSbsVhB4X+bzyDw==", "_integrity": "sha512-DVZRlmsfnTjp6ZJaatcdyvvwYwbWvR4YDNFDqb+qdTxpvaVP99YCpBkA8rxsLtAPjBVoDe4fNsnMIdZTiPuKWg==",
"_location": "/typed-rest-client", "_location": "/typed-rest-client",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
@ -18,10 +18,10 @@
"_requiredBy": [ "_requiredBy": [
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.4.0.tgz", "_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.5.0.tgz",
"_shasum": "bf0f27684f8cbde05d32127ccb2cb8e0fe1a1b79", "_shasum": "c0dda6e775b942fd46a2d99f2160a94953206fc2",
"_spec": "typed-rest-client@^1.4.0", "_spec": "typed-rest-client@^1.4.0",
"_where": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz", "_where": "C:\\Users\\damccorm\\Documents\\setup-go\\toolkit\\actions-tool-cache-0.0.0.tgz",
"author": { "author": {
"name": "Microsoft Corporation" "name": "Microsoft Corporation"
}, },
@ -69,5 +69,5 @@
"units": "node make.js units", "units": "node make.js units",
"validate": "node make.js validate" "validate": "node make.js validate"
}, },
"version": "1.4.0" "version": "1.5.0"
} }

View file

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

23
node_modules/uuid/package.json generated vendored
View file

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

10939
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,49 +1,49 @@
{ {
"name": "setup-go", "name": "setup-go",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"description": "setup go action", "description": "setup go action",
"main": "lib/setup-go.js", "main": "lib/setup-go.js",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"test": "jest" "test": "jest"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/actions/setup-go.git" "url": "git+https://github.com/actions/setup-go.git"
}, },
"keywords": [ "keywords": [
"actions", "actions",
"go", "go",
"setup" "setup"
], ],
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "file:toolkit/actions-core-0.1.0.tgz", "@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
"@actions/exec": "file:toolkit/actions-exec-1.0.0.tgz", "@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
"@actions/exit": "file:toolkit/actions-exit-0.0.0.tgz", "@actions/exit": "file:toolkit/actions-exit-0.0.0.tgz",
"@actions/io": "file:toolkit/actions-io-1.0.0.tgz", "@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
"@actions/tool-cache": "file:toolkit/actions-tool-cache-1.0.0.tgz", "@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz",
"semver": "^6.1.1" "semver": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^24.0.13", "@types/jest": "^24.0.13",
"@types/node": "^12.0.4", "@types/node": "^12.0.4",
"@types/semver": "^6.0.0", "@types/semver": "^6.0.0",
"husky": "^2.3.0", "husky": "^2.3.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.7.1",
"prettier": "^1.17.1", "prettier": "^1.17.1",
"ts-jest": "^24.0.2", "ts-jest": "^24.0.2",
"typescript": "^3.5.1" "typescript": "^3.5.1"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,
"hooks": { "hooks": {
"pre-commit": "npm run build && npm run format && npm prune --production && git add node_modules/*" "pre-commit": "npm run build && npm run format && npm prune --production && git add node_modules/*"
} }
} }
} }

130
src/installer.ts Normal file
View file

@ -0,0 +1,130 @@
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as os from 'os';
import * as path from 'path';
import * as util from 'util';
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');
}
export async function getGo(version: string) {
// check cache
let toolPath: string;
toolPath = tc.find('go', normalizeVersion(version));
if (!toolPath) {
// download, extract, cache
toolPath = await acquireGo(version);
core.debug('Go tool is cached under ' + toolPath);
}
setGoEnvironmentVariables(toolPath);
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
core.addPath(toolPath);
}
async function acquireGo(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
let fileName: string = getFileName(version);
let downloadUrl: string = getDownloadUrl(fileName);
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Extract
//
let extPath: string = tempDirectory;
if (!extPath) {
throw new Error('Temp directory not set');
}
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
} else {
extPath = await tc.extractTar(downloadPath);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
const toolRoot = path.join(extPath, 'go');
version = normalizeVersion(version);
return await tc.cacheDir(toolRoot, 'go', version);
}
function getFileName(version: string): string {
const platform: string = osPlat == 'win32' ? 'windows' : osPlat;
const arch: string = osArch == 'x64' ? 'amd64' : '386';
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
const filename: string = util.format(
'go%s.%s-%s.%s',
version,
platform,
arch,
ext
);
return filename;
}
function getDownloadUrl(filename: string): string {
return util.format('https://storage.googleapis.com/golang/%s', filename);
}
function setGoEnvironmentVariables(goRoot: string) {
core.exportVariable('GOROOT', goRoot);
const goPath: string = process.env['GOPATH'] || '';
const goBin: string = process.env['GOBIN'] || '';
// set GOPATH and GOBIN as user value
if (goPath) {
core.exportVariable('GOPATH', goPath);
}
if (goBin) {
core.exportVariable('GOBIN', goBin);
}
}
// This function is required to convert the version 1.10 to 1.10.0.
// Because caching utility accept only sementic version,
// which have patch number as well.
function normalizeVersion(version: string): string {
const versionPart = version.split('.');
if (versionPart[1] == null) {
//append minor and patch version if not available
return version.concat('.0.0');
} else if (versionPart[2] == null) {
//append patch version if not available
return version.concat('.0');
}
return version;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.