powerplatform-actions/dist/actions/actions-install/index.js

3605 строки
132 KiB
JavaScript

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/@actions/core/lib/utils.js
var require_utils = __commonJS({
"node_modules/@actions/core/lib/utils.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.toCommandProperties = exports2.toCommandValue = void 0;
function toCommandValue(input) {
if (input === null || input === void 0) {
return "";
} else if (typeof input === "string" || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports2.toCommandValue = toCommandValue;
function toCommandProperties(annotationProperties) {
if (!Object.keys(annotationProperties).length) {
return {};
}
return {
title: annotationProperties.title,
file: annotationProperties.file,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
endColumn: annotationProperties.endColumn
};
}
exports2.toCommandProperties = toCommandProperties;
}
});
// node_modules/@actions/core/lib/command.js
var require_command = __commonJS({
"node_modules/@actions/core/lib/command.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.issue = exports2.issueCommand = void 0;
var os2 = __importStar(require("os"));
var utils_1 = require_utils();
function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os2.EOL);
}
exports2.issueCommand = issueCommand;
function issue(name, message = "") {
issueCommand(name, {}, message);
}
exports2.issue = issue;
var CMD_STRING = "::";
var Command = class {
constructor(command, properties, message) {
if (!command) {
command = "missing.command";
}
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += " ";
let first = true;
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key];
if (val) {
if (first) {
first = false;
} else {
cmdStr += ",";
}
cmdStr += `${key}=${escapeProperty(val)}`;
}
}
}
}
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
return cmdStr;
}
};
function escapeData(s) {
return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
}
function escapeProperty(s) {
return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");
}
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/rng.js
function rng() {
if (poolPtr > rnds8Pool.length - 16) {
import_crypto.default.randomFillSync(rnds8Pool);
poolPtr = 0;
}
return rnds8Pool.slice(poolPtr, poolPtr += 16);
}
var import_crypto, rnds8Pool, poolPtr;
var init_rng = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/rng.js"() {
import_crypto = __toESM(require("crypto"));
rnds8Pool = new Uint8Array(256);
poolPtr = rnds8Pool.length;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/regex.js
var regex_default;
var init_regex = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/regex.js"() {
regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/validate.js
function validate(uuid) {
return typeof uuid === "string" && regex_default.test(uuid);
}
var validate_default;
var init_validate = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/validate.js"() {
init_regex();
validate_default = validate;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/stringify.js
function stringify(arr, offset = 0) {
const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
if (!validate_default(uuid)) {
throw TypeError("Stringified UUID is invalid");
}
return uuid;
}
var byteToHex, stringify_default;
var init_stringify = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/stringify.js"() {
init_validate();
byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).substr(1));
}
stringify_default = stringify;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/v1.js
function v1(options, buf, offset) {
let i = buf && offset || 0;
const b = buf || new Array(16);
options = options || {};
let node = options.node || _nodeId;
let clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
if (node == null || clockseq == null) {
const seedBytes = options.random || (options.rng || rng)();
if (node == null) {
node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
}
if (clockseq == null) {
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
}
}
let msecs = options.msecs !== void 0 ? options.msecs : Date.now();
let nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
if (dt < 0 && options.clockseq === void 0) {
clockseq = clockseq + 1 & 16383;
}
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) {
nsecs = 0;
}
if (nsecs >= 1e4) {
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq;
msecs += 122192928e5;
const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
b[i++] = tl >>> 24 & 255;
b[i++] = tl >>> 16 & 255;
b[i++] = tl >>> 8 & 255;
b[i++] = tl & 255;
const tmh = msecs / 4294967296 * 1e4 & 268435455;
b[i++] = tmh >>> 8 & 255;
b[i++] = tmh & 255;
b[i++] = tmh >>> 24 & 15 | 16;
b[i++] = tmh >>> 16 & 255;
b[i++] = clockseq >>> 8 | 128;
b[i++] = clockseq & 255;
for (let n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf || stringify_default(b);
}
var _nodeId, _clockseq, _lastMSecs, _lastNSecs, v1_default;
var init_v1 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/v1.js"() {
init_rng();
init_stringify();
_lastMSecs = 0;
_lastNSecs = 0;
v1_default = v1;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/parse.js
function parse(uuid) {
if (!validate_default(uuid)) {
throw TypeError("Invalid UUID");
}
let v;
const arr = new Uint8Array(16);
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
arr[1] = v >>> 16 & 255;
arr[2] = v >>> 8 & 255;
arr[3] = v & 255;
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
arr[5] = v & 255;
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
arr[7] = v & 255;
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
arr[9] = v & 255;
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
arr[11] = v / 4294967296 & 255;
arr[12] = v >>> 24 & 255;
arr[13] = v >>> 16 & 255;
arr[14] = v >>> 8 & 255;
arr[15] = v & 255;
return arr;
}
var parse_default;
var init_parse = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/parse.js"() {
init_validate();
parse_default = parse;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/v35.js
function stringToBytes(str) {
str = unescape(encodeURIComponent(str));
const bytes = [];
for (let i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i));
}
return bytes;
}
function v35_default(name, version2, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
if (typeof value === "string") {
value = stringToBytes(value);
}
if (typeof namespace === "string") {
namespace = parse_default(namespace);
}
if (namespace.length !== 16) {
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
}
let bytes = new Uint8Array(16 + value.length);
bytes.set(namespace);
bytes.set(value, namespace.length);
bytes = hashfunc(bytes);
bytes[6] = bytes[6] & 15 | version2;
bytes[8] = bytes[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = bytes[i];
}
return buf;
}
return stringify_default(bytes);
}
try {
generateUUID.name = name;
} catch (err) {
}
generateUUID.DNS = DNS;
generateUUID.URL = URL2;
return generateUUID;
}
var DNS, URL2;
var init_v35 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/v35.js"() {
init_stringify();
init_parse();
DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/md5.js
function md5(bytes) {
if (Array.isArray(bytes)) {
bytes = Buffer.from(bytes);
} else if (typeof bytes === "string") {
bytes = Buffer.from(bytes, "utf8");
}
return import_crypto2.default.createHash("md5").update(bytes).digest();
}
var import_crypto2, md5_default;
var init_md5 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/md5.js"() {
import_crypto2 = __toESM(require("crypto"));
md5_default = md5;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/v3.js
var v3, v3_default;
var init_v3 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/v3.js"() {
init_v35();
init_md5();
v3 = v35_default("v3", 48, md5_default);
v3_default = v3;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/v4.js
function v4(options, buf, offset) {
options = options || {};
const rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return stringify_default(rnds);
}
var v4_default;
var init_v4 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/v4.js"() {
init_rng();
init_stringify();
v4_default = v4;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/sha1.js
function sha1(bytes) {
if (Array.isArray(bytes)) {
bytes = Buffer.from(bytes);
} else if (typeof bytes === "string") {
bytes = Buffer.from(bytes, "utf8");
}
return import_crypto3.default.createHash("sha1").update(bytes).digest();
}
var import_crypto3, sha1_default;
var init_sha1 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/sha1.js"() {
import_crypto3 = __toESM(require("crypto"));
sha1_default = sha1;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/v5.js
var v5, v5_default;
var init_v5 = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/v5.js"() {
init_v35();
init_sha1();
v5 = v35_default("v5", 80, sha1_default);
v5_default = v5;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/nil.js
var nil_default;
var init_nil = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/nil.js"() {
nil_default = "00000000-0000-0000-0000-000000000000";
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/version.js
function version(uuid) {
if (!validate_default(uuid)) {
throw TypeError("Invalid UUID");
}
return parseInt(uuid.substr(14, 1), 16);
}
var version_default;
var init_version = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/version.js"() {
init_validate();
version_default = version;
}
});
// node_modules/@actions/core/node_modules/uuid/dist/esm-node/index.js
var esm_node_exports = {};
__export(esm_node_exports, {
NIL: () => nil_default,
parse: () => parse_default,
stringify: () => stringify_default,
v1: () => v1_default,
v3: () => v3_default,
v4: () => v4_default,
v5: () => v5_default,
validate: () => validate_default,
version: () => version_default
});
var init_esm_node = __esm({
"node_modules/@actions/core/node_modules/uuid/dist/esm-node/index.js"() {
init_v1();
init_v3();
init_v4();
init_v5();
init_nil();
init_version();
init_validate();
init_stringify();
init_parse();
}
});
// node_modules/@actions/core/lib/file-command.js
var require_file_command = __commonJS({
"node_modules/@actions/core/lib/file-command.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.prepareKeyValueMessage = exports2.issueFileCommand = void 0;
var fs2 = __importStar(require("fs"));
var os2 = __importStar(require("os"));
var uuid_1 = (init_esm_node(), __toCommonJS(esm_node_exports));
var utils_1 = require_utils();
function issueFileCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs2.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs2.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os2.EOL}`, {
encoding: "utf8"
});
}
exports2.issueFileCommand = issueFileCommand;
function prepareKeyValueMessage(key, value) {
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
const convertedValue = utils_1.toCommandValue(value);
if (key.includes(delimiter)) {
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
}
if (convertedValue.includes(delimiter)) {
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
}
return `${key}<<${delimiter}${os2.EOL}${convertedValue}${os2.EOL}${delimiter}`;
}
exports2.prepareKeyValueMessage = prepareKeyValueMessage;
}
});
// node_modules/@actions/http-client/lib/proxy.js
var require_proxy = __commonJS({
"node_modules/@actions/http-client/lib/proxy.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.checkBypass = exports2.getProxyUrl = void 0;
function getProxyUrl(reqUrl) {
const usingSsl = reqUrl.protocol === "https:";
if (checkBypass(reqUrl)) {
return void 0;
}
const proxyVar = (() => {
if (usingSsl) {
return process.env["https_proxy"] || process.env["HTTPS_PROXY"];
} else {
return process.env["http_proxy"] || process.env["HTTP_PROXY"];
}
})();
if (proxyVar) {
return new URL(proxyVar);
} else {
return void 0;
}
}
exports2.getProxyUrl = getProxyUrl;
function checkBypass(reqUrl) {
if (!reqUrl.hostname) {
return false;
}
const noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || "";
if (!noProxy) {
return false;
}
let reqPort;
if (reqUrl.port) {
reqPort = Number(reqUrl.port);
} else if (reqUrl.protocol === "http:") {
reqPort = 80;
} else if (reqUrl.protocol === "https:") {
reqPort = 443;
}
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
if (typeof reqPort === "number") {
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
}
for (const upperNoProxyItem of noProxy.split(",").map((x) => x.trim().toUpperCase()).filter((x) => x)) {
if (upperReqHosts.some((x) => x === upperNoProxyItem)) {
return true;
}
}
return false;
}
exports2.checkBypass = checkBypass;
}
});
// node_modules/tunnel/lib/tunnel.js
var require_tunnel = __commonJS({
"node_modules/tunnel/lib/tunnel.js"(exports2) {
"use strict";
var net = require("net");
var tls = require("tls");
var http = require("http");
var https = require("https");
var events = require("events");
var assert = require("assert");
var util = require("util");
exports2.httpOverHttp = httpOverHttp;
exports2.httpsOverHttp = httpsOverHttp;
exports2.httpOverHttps = httpOverHttps;
exports2.httpsOverHttps = httpsOverHttps;
function httpOverHttp(options) {
var agent = new TunnelingAgent(options);
agent.request = http.request;
return agent;
}
function httpsOverHttp(options) {
var agent = new TunnelingAgent(options);
agent.request = http.request;
agent.createSocket = createSecureSocket;
agent.defaultPort = 443;
return agent;
}
function httpOverHttps(options) {
var agent = new TunnelingAgent(options);
agent.request = https.request;
return agent;
}
function httpsOverHttps(options) {
var agent = new TunnelingAgent(options);
agent.request = https.request;
agent.createSocket = createSecureSocket;
agent.defaultPort = 443;
return agent;
}
function TunnelingAgent(options) {
var self = this;
self.options = options || {};
self.proxyOptions = self.options.proxy || {};
self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
self.requests = [];
self.sockets = [];
self.on("free", function onFree(socket, host, port, localAddress) {
var options2 = toOptions(host, port, localAddress);
for (var i = 0, len = self.requests.length; i < len; ++i) {
var pending = self.requests[i];
if (pending.host === options2.host && pending.port === options2.port) {
self.requests.splice(i, 1);
pending.request.onSocket(socket);
return;
}
}
socket.destroy();
self.removeSocket(socket);
});
}
util.inherits(TunnelingAgent, events.EventEmitter);
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {
var self = this;
var options = mergeOptions({ request: req }, self.options, toOptions(host, port, localAddress));
if (self.sockets.length >= this.maxSockets) {
self.requests.push(options);
return;
}
self.createSocket(options, function(socket) {
socket.on("free", onFree);
socket.on("close", onCloseOrRemove);
socket.on("agentRemove", onCloseOrRemove);
req.onSocket(socket);
function onFree() {
self.emit("free", socket, options);
}
function onCloseOrRemove(err) {
self.removeSocket(socket);
socket.removeListener("free", onFree);
socket.removeListener("close", onCloseOrRemove);
socket.removeListener("agentRemove", onCloseOrRemove);
}
});
};
TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
var self = this;
var placeholder = {};
self.sockets.push(placeholder);
var connectOptions = mergeOptions({}, self.proxyOptions, {
method: "CONNECT",
path: options.host + ":" + options.port,
agent: false,
headers: {
host: options.host + ":" + options.port
}
});
if (options.localAddress) {
connectOptions.localAddress = options.localAddress;
}
if (connectOptions.proxyAuth) {
connectOptions.headers = connectOptions.headers || {};
connectOptions.headers["Proxy-Authorization"] = "Basic " + new Buffer(connectOptions.proxyAuth).toString("base64");
}
debug("making CONNECT request");
var connectReq = self.request(connectOptions);
connectReq.useChunkedEncodingByDefault = false;
connectReq.once("response", onResponse);
connectReq.once("upgrade", onUpgrade);
connectReq.once("connect", onConnect);
connectReq.once("error", onError);
connectReq.end();
function onResponse(res) {
res.upgrade = true;
}
function onUpgrade(res, socket, head) {
process.nextTick(function() {
onConnect(res, socket, head);
});
}
function onConnect(res, socket, head) {
connectReq.removeAllListeners();
socket.removeAllListeners();
if (res.statusCode !== 200) {
debug(
"tunneling socket could not be established, statusCode=%d",
res.statusCode
);
socket.destroy();
var error = new Error("tunneling socket could not be established, statusCode=" + res.statusCode);
error.code = "ECONNRESET";
options.request.emit("error", error);
self.removeSocket(placeholder);
return;
}
if (head.length > 0) {
debug("got illegal response body from proxy");
socket.destroy();
var error = new Error("got illegal response body from proxy");
error.code = "ECONNRESET";
options.request.emit("error", error);
self.removeSocket(placeholder);
return;
}
debug("tunneling connection has established");
self.sockets[self.sockets.indexOf(placeholder)] = socket;
return cb(socket);
}
function onError(cause) {
connectReq.removeAllListeners();
debug(
"tunneling socket could not be established, cause=%s\n",
cause.message,
cause.stack
);
var error = new Error("tunneling socket could not be established, cause=" + cause.message);
error.code = "ECONNRESET";
options.request.emit("error", error);
self.removeSocket(placeholder);
}
};
TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
var pos = this.sockets.indexOf(socket);
if (pos === -1) {
return;
}
this.sockets.splice(pos, 1);
var pending = this.requests.shift();
if (pending) {
this.createSocket(pending, function(socket2) {
pending.request.onSocket(socket2);
});
}
};
function createSecureSocket(options, cb) {
var self = this;
TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
var hostHeader = options.request.getHeader("host");
var tlsOptions = mergeOptions({}, self.options, {
socket,
servername: hostHeader ? hostHeader.replace(/:.*$/, "") : options.host
});
var secureSocket = tls.connect(0, tlsOptions);
self.sockets[self.sockets.indexOf(socket)] = secureSocket;
cb(secureSocket);
});
}
function toOptions(host, port, localAddress) {
if (typeof host === "string") {
return {
host,
port,
localAddress
};
}
return host;
}
function mergeOptions(target) {
for (var i = 1, len = arguments.length; i < len; ++i) {
var overrides = arguments[i];
if (typeof overrides === "object") {
var keys = Object.keys(overrides);
for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
var k = keys[j];
if (overrides[k] !== void 0) {
target[k] = overrides[k];
}
}
}
}
return target;
}
var debug;
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
debug = function() {
var args2 = Array.prototype.slice.call(arguments);
if (typeof args2[0] === "string") {
args2[0] = "TUNNEL: " + args2[0];
} else {
args2.unshift("TUNNEL:");
}
console.error.apply(console, args2);
};
} else {
debug = function() {
};
}
exports2.debug = debug;
}
});
// node_modules/tunnel/index.js
var require_tunnel2 = __commonJS({
"node_modules/tunnel/index.js"(exports2, module2) {
module2.exports = require_tunnel();
}
});
// node_modules/@actions/http-client/lib/index.js
var require_lib = __commonJS({
"node_modules/@actions/http-client/lib/index.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.HttpClient = exports2.isHttps = exports2.HttpClientResponse = exports2.HttpClientError = exports2.getProxyUrl = exports2.MediaTypes = exports2.Headers = exports2.HttpCodes = void 0;
var http = __importStar(require("http"));
var https = __importStar(require("https"));
var pm = __importStar(require_proxy());
var tunnel = __importStar(require_tunnel2());
var HttpCodes;
(function(HttpCodes2) {
HttpCodes2[HttpCodes2["OK"] = 200] = "OK";
HttpCodes2[HttpCodes2["MultipleChoices"] = 300] = "MultipleChoices";
HttpCodes2[HttpCodes2["MovedPermanently"] = 301] = "MovedPermanently";
HttpCodes2[HttpCodes2["ResourceMoved"] = 302] = "ResourceMoved";
HttpCodes2[HttpCodes2["SeeOther"] = 303] = "SeeOther";
HttpCodes2[HttpCodes2["NotModified"] = 304] = "NotModified";
HttpCodes2[HttpCodes2["UseProxy"] = 305] = "UseProxy";
HttpCodes2[HttpCodes2["SwitchProxy"] = 306] = "SwitchProxy";
HttpCodes2[HttpCodes2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
HttpCodes2[HttpCodes2["PermanentRedirect"] = 308] = "PermanentRedirect";
HttpCodes2[HttpCodes2["BadRequest"] = 400] = "BadRequest";
HttpCodes2[HttpCodes2["Unauthorized"] = 401] = "Unauthorized";
HttpCodes2[HttpCodes2["PaymentRequired"] = 402] = "PaymentRequired";
HttpCodes2[HttpCodes2["Forbidden"] = 403] = "Forbidden";
HttpCodes2[HttpCodes2["NotFound"] = 404] = "NotFound";
HttpCodes2[HttpCodes2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
HttpCodes2[HttpCodes2["NotAcceptable"] = 406] = "NotAcceptable";
HttpCodes2[HttpCodes2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
HttpCodes2[HttpCodes2["RequestTimeout"] = 408] = "RequestTimeout";
HttpCodes2[HttpCodes2["Conflict"] = 409] = "Conflict";
HttpCodes2[HttpCodes2["Gone"] = 410] = "Gone";
HttpCodes2[HttpCodes2["TooManyRequests"] = 429] = "TooManyRequests";
HttpCodes2[HttpCodes2["InternalServerError"] = 500] = "InternalServerError";
HttpCodes2[HttpCodes2["NotImplemented"] = 501] = "NotImplemented";
HttpCodes2[HttpCodes2["BadGateway"] = 502] = "BadGateway";
HttpCodes2[HttpCodes2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
HttpCodes2[HttpCodes2["GatewayTimeout"] = 504] = "GatewayTimeout";
})(HttpCodes = exports2.HttpCodes || (exports2.HttpCodes = {}));
var Headers;
(function(Headers2) {
Headers2["Accept"] = "accept";
Headers2["ContentType"] = "content-type";
})(Headers = exports2.Headers || (exports2.Headers = {}));
var MediaTypes;
(function(MediaTypes2) {
MediaTypes2["ApplicationJson"] = "application/json";
})(MediaTypes = exports2.MediaTypes || (exports2.MediaTypes = {}));
function getProxyUrl(serverUrl) {
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
return proxyUrl ? proxyUrl.href : "";
}
exports2.getProxyUrl = getProxyUrl;
var HttpRedirectCodes = [
HttpCodes.MovedPermanently,
HttpCodes.ResourceMoved,
HttpCodes.SeeOther,
HttpCodes.TemporaryRedirect,
HttpCodes.PermanentRedirect
];
var HttpResponseRetryCodes = [
HttpCodes.BadGateway,
HttpCodes.ServiceUnavailable,
HttpCodes.GatewayTimeout
];
var RetryableHttpVerbs = ["OPTIONS", "GET", "DELETE", "HEAD"];
var ExponentialBackoffCeiling = 10;
var ExponentialBackoffTimeSlice = 5;
var HttpClientError = class _HttpClientError extends Error {
constructor(message, statusCode) {
super(message);
this.name = "HttpClientError";
this.statusCode = statusCode;
Object.setPrototypeOf(this, _HttpClientError.prototype);
}
};
exports2.HttpClientError = HttpClientError;
var HttpClientResponse = class {
constructor(message) {
this.message = message;
}
readBody() {
return __awaiter2(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter2(this, void 0, void 0, function* () {
let output = Buffer.alloc(0);
this.message.on("data", (chunk) => {
output = Buffer.concat([output, chunk]);
});
this.message.on("end", () => {
resolve(output.toString());
});
}));
});
}
};
exports2.HttpClientResponse = HttpClientResponse;
function isHttps(requestUrl) {
const parsedUrl = new URL(requestUrl);
return parsedUrl.protocol === "https:";
}
exports2.isHttps = isHttps;
var HttpClient = class {
constructor(userAgent, handlers, requestOptions) {
this._ignoreSslError = false;
this._allowRedirects = true;
this._allowRedirectDowngrade = false;
this._maxRedirects = 50;
this._allowRetries = false;
this._maxRetries = 1;
this._keepAlive = false;
this._disposed = false;
this.userAgent = userAgent;
this.handlers = handlers || [];
this.requestOptions = requestOptions;
if (requestOptions) {
if (requestOptions.ignoreSslError != null) {
this._ignoreSslError = requestOptions.ignoreSslError;
}
this._socketTimeout = requestOptions.socketTimeout;
if (requestOptions.allowRedirects != null) {
this._allowRedirects = requestOptions.allowRedirects;
}
if (requestOptions.allowRedirectDowngrade != null) {
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
}
if (requestOptions.maxRedirects != null) {
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
}
if (requestOptions.keepAlive != null) {
this._keepAlive = requestOptions.keepAlive;
}
if (requestOptions.allowRetries != null) {
this._allowRetries = requestOptions.allowRetries;
}
if (requestOptions.maxRetries != null) {
this._maxRetries = requestOptions.maxRetries;
}
}
}
options(requestUrl, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("OPTIONS", requestUrl, null, additionalHeaders || {});
});
}
get(requestUrl, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("GET", requestUrl, null, additionalHeaders || {});
});
}
del(requestUrl, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("DELETE", requestUrl, null, additionalHeaders || {});
});
}
post(requestUrl, data, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("POST", requestUrl, data, additionalHeaders || {});
});
}
patch(requestUrl, data, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("PATCH", requestUrl, data, additionalHeaders || {});
});
}
put(requestUrl, data, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("PUT", requestUrl, data, additionalHeaders || {});
});
}
head(requestUrl, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request("HEAD", requestUrl, null, additionalHeaders || {});
});
}
sendStream(verb, requestUrl, stream, additionalHeaders) {
return __awaiter2(this, void 0, void 0, function* () {
return this.request(verb, requestUrl, stream, additionalHeaders);
});
}
/**
* Gets a typed object from an endpoint
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
*/
getJson(requestUrl, additionalHeaders = {}) {
return __awaiter2(this, void 0, void 0, function* () {
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
const res = yield this.get(requestUrl, additionalHeaders);
return this._processResponse(res, this.requestOptions);
});
}
postJson(requestUrl, obj, additionalHeaders = {}) {
return __awaiter2(this, void 0, void 0, function* () {
const data = JSON.stringify(obj, null, 2);
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
const res = yield this.post(requestUrl, data, additionalHeaders);
return this._processResponse(res, this.requestOptions);
});
}
putJson(requestUrl, obj, additionalHeaders = {}) {
return __awaiter2(this, void 0, void 0, function* () {
const data = JSON.stringify(obj, null, 2);
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
const res = yield this.put(requestUrl, data, additionalHeaders);
return this._processResponse(res, this.requestOptions);
});
}
patchJson(requestUrl, obj, additionalHeaders = {}) {
return __awaiter2(this, void 0, void 0, function* () {
const data = JSON.stringify(obj, null, 2);
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
const res = yield this.patch(requestUrl, data, additionalHeaders);
return this._processResponse(res, this.requestOptions);
});
}
/**
* Makes a raw http request.
* All other methods such as get, post, patch, and request ultimately call this.
* Prefer get, del, post and patch
*/
request(verb, requestUrl, data, headers) {
return __awaiter2(this, void 0, void 0, function* () {
if (this._disposed) {
throw new Error("Client has already been disposed.");
}
const parsedUrl = new URL(requestUrl);
let info = this._prepareRequest(verb, parsedUrl, headers);
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1;
let numTries = 0;
let response;
do {
response = yield this.requestRaw(info, data);
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
let authenticationHandler;
for (const handler of this.handlers) {
if (handler.canHandleAuthentication(response)) {
authenticationHandler = handler;
break;
}
}
if (authenticationHandler) {
return authenticationHandler.handleAuthentication(this, info, data);
} else {
return response;
}
}
let redirectsRemaining = this._maxRedirects;
while (response.message.statusCode && HttpRedirectCodes.includes(response.message.statusCode) && this._allowRedirects && redirectsRemaining > 0) {
const redirectUrl = response.message.headers["location"];
if (!redirectUrl) {
break;
}
const parsedRedirectUrl = new URL(redirectUrl);
if (parsedUrl.protocol === "https:" && parsedUrl.protocol !== parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
}
yield response.readBody();
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
for (const header in headers) {
if (header.toLowerCase() === "authorization") {
delete headers[header];
}
}
}
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
response = yield this.requestRaw(info, data);
redirectsRemaining--;
}
if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) {
return response;
}
numTries += 1;
if (numTries < maxTries) {
yield response.readBody();
yield this._performExponentialBackoff(numTries);
}
} while (numTries < maxTries);
return response;
});
}
/**
* Needs to be called if keepAlive is set to true in request options.
*/
dispose() {
if (this._agent) {
this._agent.destroy();
}
this._disposed = true;
}
/**
* Raw request.
* @param info
* @param data
*/
requestRaw(info, data) {
return __awaiter2(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
function callbackForResult(err, res) {
if (err) {
reject(err);
} else if (!res) {
reject(new Error("Unknown error"));
} else {
resolve(res);
}
}
this.requestRawWithCallback(info, data, callbackForResult);
});
});
}
/**
* Raw request with callback.
* @param info
* @param data
* @param onResult
*/
requestRawWithCallback(info, data, onResult) {
if (typeof data === "string") {
if (!info.options.headers) {
info.options.headers = {};
}
info.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8");
}
let callbackCalled = false;
function handleResult(err, res) {
if (!callbackCalled) {
callbackCalled = true;
onResult(err, res);
}
}
const req = info.httpModule.request(info.options, (msg) => {
const res = new HttpClientResponse(msg);
handleResult(void 0, res);
});
let socket;
req.on("socket", (sock) => {
socket = sock;
});
req.setTimeout(this._socketTimeout || 3 * 6e4, () => {
if (socket) {
socket.end();
}
handleResult(new Error(`Request timeout: ${info.options.path}`));
});
req.on("error", function(err) {
handleResult(err);
});
if (data && typeof data === "string") {
req.write(data, "utf8");
}
if (data && typeof data !== "string") {
data.on("close", function() {
req.end();
});
data.pipe(req);
} else {
req.end();
}
}
/**
* Gets an http agent. This function is useful when you need an http agent that handles
* routing through a proxy server - depending upon the url and proxy environment variables.
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
*/
getAgent(serverUrl) {
const parsedUrl = new URL(serverUrl);
return this._getAgent(parsedUrl);
}
_prepareRequest(method, requestUrl, headers) {
const info = {};
info.parsedUrl = requestUrl;
const usingSsl = info.parsedUrl.protocol === "https:";
info.httpModule = usingSsl ? https : http;
const defaultPort = usingSsl ? 443 : 80;
info.options = {};
info.options.host = info.parsedUrl.hostname;
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
info.options.path = (info.parsedUrl.pathname || "") + (info.parsedUrl.search || "");
info.options.method = method;
info.options.headers = this._mergeHeaders(headers);
if (this.userAgent != null) {
info.options.headers["user-agent"] = this.userAgent;
}
info.options.agent = this._getAgent(info.parsedUrl);
if (this.handlers) {
for (const handler of this.handlers) {
handler.prepareRequest(info.options);
}
}
return info;
}
_mergeHeaders(headers) {
if (this.requestOptions && this.requestOptions.headers) {
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
}
return lowercaseKeys(headers || {});
}
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
let clientHeader;
if (this.requestOptions && this.requestOptions.headers) {
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
}
return additionalHeaders[header] || clientHeader || _default;
}
_getAgent(parsedUrl) {
let agent;
const proxyUrl = pm.getProxyUrl(parsedUrl);
const useProxy = proxyUrl && proxyUrl.hostname;
if (this._keepAlive && useProxy) {
agent = this._proxyAgent;
}
if (this._keepAlive && !useProxy) {
agent = this._agent;
}
if (agent) {
return agent;
}
const usingSsl = parsedUrl.protocol === "https:";
let maxSockets = 100;
if (this.requestOptions) {
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
}
if (proxyUrl && proxyUrl.hostname) {
const agentOptions = {
maxSockets,
keepAlive: this._keepAlive,
proxy: Object.assign(Object.assign({}, (proxyUrl.username || proxyUrl.password) && {
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
}), { host: proxyUrl.hostname, port: proxyUrl.port })
};
let tunnelAgent;
const overHttps = proxyUrl.protocol === "https:";
if (usingSsl) {
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
} else {
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
}
agent = tunnelAgent(agentOptions);
this._proxyAgent = agent;
}
if (this._keepAlive && !agent) {
const options = { keepAlive: this._keepAlive, maxSockets };
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
this._agent = agent;
}
if (!agent) {
agent = usingSsl ? https.globalAgent : http.globalAgent;
}
if (usingSsl && this._ignoreSslError) {
agent.options = Object.assign(agent.options || {}, {
rejectUnauthorized: false
});
}
return agent;
}
_performExponentialBackoff(retryNumber) {
return __awaiter2(this, void 0, void 0, function* () {
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
return new Promise((resolve) => setTimeout(() => resolve(), ms));
});
}
_processResponse(res, options) {
return __awaiter2(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => __awaiter2(this, void 0, void 0, function* () {
const statusCode = res.message.statusCode || 0;
const response = {
statusCode,
result: null,
headers: {}
};
if (statusCode === HttpCodes.NotFound) {
resolve(response);
}
function dateTimeDeserializer(key, value) {
if (typeof value === "string") {
const a = new Date(value);
if (!isNaN(a.valueOf())) {
return a;
}
}
return value;
}
let obj;
let contents;
try {
contents = yield res.readBody();
if (contents && contents.length > 0) {
if (options && options.deserializeDates) {
obj = JSON.parse(contents, dateTimeDeserializer);
} else {
obj = JSON.parse(contents);
}
response.result = obj;
}
response.headers = res.message.headers;
} catch (err) {
}
if (statusCode > 299) {
let msg;
if (obj && obj.message) {
msg = obj.message;
} else if (contents && contents.length > 0) {
msg = contents;
} else {
msg = `Failed request: (${statusCode})`;
}
const err = new HttpClientError(msg, statusCode);
err.result = response.result;
reject(err);
} else {
resolve(response);
}
}));
});
}
};
exports2.HttpClient = HttpClient;
var lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
}
});
// node_modules/@actions/http-client/lib/auth.js
var require_auth = __commonJS({
"node_modules/@actions/http-client/lib/auth.js"(exports2) {
"use strict";
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.PersonalAccessTokenCredentialHandler = exports2.BearerCredentialHandler = exports2.BasicCredentialHandler = void 0;
var BasicCredentialHandler = class {
constructor(username, password) {
this.username = username;
this.password = password;
}
prepareRequest(options) {
if (!options.headers) {
throw Error("The request has no headers");
}
options.headers["Authorization"] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`;
}
// This handler cannot handle 401
canHandleAuthentication() {
return false;
}
handleAuthentication() {
return __awaiter2(this, void 0, void 0, function* () {
throw new Error("not implemented");
});
}
};
exports2.BasicCredentialHandler = BasicCredentialHandler;
var BearerCredentialHandler = class {
constructor(token) {
this.token = token;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options) {
if (!options.headers) {
throw Error("The request has no headers");
}
options.headers["Authorization"] = `Bearer ${this.token}`;
}
// This handler cannot handle 401
canHandleAuthentication() {
return false;
}
handleAuthentication() {
return __awaiter2(this, void 0, void 0, function* () {
throw new Error("not implemented");
});
}
};
exports2.BearerCredentialHandler = BearerCredentialHandler;
var PersonalAccessTokenCredentialHandler = class {
constructor(token) {
this.token = token;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options) {
if (!options.headers) {
throw Error("The request has no headers");
}
options.headers["Authorization"] = `Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`;
}
// This handler cannot handle 401
canHandleAuthentication() {
return false;
}
handleAuthentication() {
return __awaiter2(this, void 0, void 0, function* () {
throw new Error("not implemented");
});
}
};
exports2.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
}
});
// node_modules/@actions/core/lib/oidc-utils.js
var require_oidc_utils = __commonJS({
"node_modules/@actions/core/lib/oidc-utils.js"(exports2) {
"use strict";
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.OidcClient = void 0;
var http_client_1 = require_lib();
var auth_1 = require_auth();
var core_1 = require_core();
var OidcClient = class _OidcClient {
static createHttpClient(allowRetry = true, maxRetry = 10) {
const requestOptions = {
allowRetries: allowRetry,
maxRetries: maxRetry
};
return new http_client_1.HttpClient("actions/oidc-client", [new auth_1.BearerCredentialHandler(_OidcClient.getRequestToken())], requestOptions);
}
static getRequestToken() {
const token = process.env["ACTIONS_ID_TOKEN_REQUEST_TOKEN"];
if (!token) {
throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable");
}
return token;
}
static getIDTokenUrl() {
const runtimeUrl = process.env["ACTIONS_ID_TOKEN_REQUEST_URL"];
if (!runtimeUrl) {
throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable");
}
return runtimeUrl;
}
static getCall(id_token_url) {
var _a;
return __awaiter2(this, void 0, void 0, function* () {
const httpclient = _OidcClient.createHttpClient();
const res = yield httpclient.getJson(id_token_url).catch((error) => {
throw new Error(`Failed to get ID Token.
Error Code : ${error.statusCode}
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
throw new Error("Response json body do not have ID Token field");
}
return id_token;
});
}
static getIDToken(audience) {
return __awaiter2(this, void 0, void 0, function* () {
try {
let id_token_url = _OidcClient.getIDTokenUrl();
if (audience) {
const encodedAudience = encodeURIComponent(audience);
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
}
core_1.debug(`ID token url is ${id_token_url}`);
const id_token = yield _OidcClient.getCall(id_token_url);
core_1.setSecret(id_token);
return id_token;
} catch (error) {
throw new Error(`Error message: ${error.message}`);
}
});
}
};
exports2.OidcClient = OidcClient;
}
});
// node_modules/@actions/core/lib/summary.js
var require_summary = __commonJS({
"node_modules/@actions/core/lib/summary.js"(exports2) {
"use strict";
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.summary = exports2.markdownSummary = exports2.SUMMARY_DOCS_URL = exports2.SUMMARY_ENV_VAR = void 0;
var os_1 = require("os");
var fs_1 = require("fs");
var { access, appendFile, writeFile } = fs_1.promises;
exports2.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
exports2.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
var Summary = class {
constructor() {
this._buffer = "";
}
/**
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
* Also checks r/w permissions.
*
* @returns step summary file path
*/
filePath() {
return __awaiter2(this, void 0, void 0, function* () {
if (this._filePath) {
return this._filePath;
}
const pathFromEnv = process.env[exports2.SUMMARY_ENV_VAR];
if (!pathFromEnv) {
throw new Error(`Unable to find environment variable for $${exports2.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
}
try {
yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
} catch (_a) {
throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
}
this._filePath = pathFromEnv;
return this._filePath;
});
}
/**
* Wraps content in an HTML tag, adding any HTML attributes
*
* @param {string} tag HTML tag to wrap
* @param {string | null} content content within the tag
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
*
* @returns {string} content wrapped in HTML element
*/
wrap(tag, content, attrs = {}) {
const htmlAttrs = Object.entries(attrs).map(([key, value]) => ` ${key}="${value}"`).join("");
if (!content) {
return `<${tag}${htmlAttrs}>`;
}
return `<${tag}${htmlAttrs}>${content}</${tag}>`;
}
/**
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
*
* @param {SummaryWriteOptions} [options] (optional) options for write operation
*
* @returns {Promise<Summary>} summary instance
*/
write(options) {
return __awaiter2(this, void 0, void 0, function* () {
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
const filePath = yield this.filePath();
const writeFunc = overwrite ? writeFile : appendFile;
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
return this.emptyBuffer();
});
}
/**
* Clears the summary buffer and wipes the summary file
*
* @returns {Summary} summary instance
*/
clear() {
return __awaiter2(this, void 0, void 0, function* () {
return this.emptyBuffer().write({ overwrite: true });
});
}
/**
* Returns the current summary buffer as a string
*
* @returns {string} string of summary buffer
*/
stringify() {
return this._buffer;
}
/**
* If the summary buffer is empty
*
* @returns {boolen} true if the buffer is empty
*/
isEmptyBuffer() {
return this._buffer.length === 0;
}
/**
* Resets the summary buffer without writing to summary file
*
* @returns {Summary} summary instance
*/
emptyBuffer() {
this._buffer = "";
return this;
}
/**
* Adds raw text to the summary buffer
*
* @param {string} text content to add
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
*
* @returns {Summary} summary instance
*/
addRaw(text, addEOL = false) {
this._buffer += text;
return addEOL ? this.addEOL() : this;
}
/**
* Adds the operating system-specific end-of-line marker to the buffer
*
* @returns {Summary} summary instance
*/
addEOL() {
return this.addRaw(os_1.EOL);
}
/**
* Adds an HTML codeblock to the summary buffer
*
* @param {string} code content to render within fenced code block
* @param {string} lang (optional) language to syntax highlight code
*
* @returns {Summary} summary instance
*/
addCodeBlock(code, lang) {
const attrs = Object.assign({}, lang && { lang });
const element = this.wrap("pre", this.wrap("code", code), attrs);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML list to the summary buffer
*
* @param {string[]} items list of items to render
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
*
* @returns {Summary} summary instance
*/
addList(items, ordered = false) {
const tag = ordered ? "ol" : "ul";
const listItems = items.map((item) => this.wrap("li", item)).join("");
const element = this.wrap(tag, listItems);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML table to the summary buffer
*
* @param {SummaryTableCell[]} rows table rows
*
* @returns {Summary} summary instance
*/
addTable(rows) {
const tableBody = rows.map((row) => {
const cells = row.map((cell) => {
if (typeof cell === "string") {
return this.wrap("td", cell);
}
const { header, data, colspan, rowspan } = cell;
const tag = header ? "th" : "td";
const attrs = Object.assign(Object.assign({}, colspan && { colspan }), rowspan && { rowspan });
return this.wrap(tag, data, attrs);
}).join("");
return this.wrap("tr", cells);
}).join("");
const element = this.wrap("table", tableBody);
return this.addRaw(element).addEOL();
}
/**
* Adds a collapsable HTML details element to the summary buffer
*
* @param {string} label text for the closed state
* @param {string} content collapsable content
*
* @returns {Summary} summary instance
*/
addDetails(label, content) {
const element = this.wrap("details", this.wrap("summary", label) + content);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML image tag to the summary buffer
*
* @param {string} src path to the image you to embed
* @param {string} alt text description of the image
* @param {SummaryImageOptions} options (optional) addition image attributes
*
* @returns {Summary} summary instance
*/
addImage(src, alt, options) {
const { width, height } = options || {};
const attrs = Object.assign(Object.assign({}, width && { width }), height && { height });
const element = this.wrap("img", null, Object.assign({ src, alt }, attrs));
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML section heading element
*
* @param {string} text heading text
* @param {number | string} [level=1] (optional) the heading level, default: 1
*
* @returns {Summary} summary instance
*/
addHeading(text, level) {
const tag = `h${level}`;
const allowedTag = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(tag) ? tag : "h1";
const element = this.wrap(allowedTag, text);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML thematic break (<hr>) to the summary buffer
*
* @returns {Summary} summary instance
*/
addSeparator() {
const element = this.wrap("hr", null);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML line break (<br>) to the summary buffer
*
* @returns {Summary} summary instance
*/
addBreak() {
const element = this.wrap("br", null);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML blockquote to the summary buffer
*
* @param {string} text quote text
* @param {string} cite (optional) citation url
*
* @returns {Summary} summary instance
*/
addQuote(text, cite) {
const attrs = Object.assign({}, cite && { cite });
const element = this.wrap("blockquote", text, attrs);
return this.addRaw(element).addEOL();
}
/**
* Adds an HTML anchor tag to the summary buffer
*
* @param {string} text link text/content
* @param {string} href hyperlink
*
* @returns {Summary} summary instance
*/
addLink(text, href) {
const element = this.wrap("a", text, { href });
return this.addRaw(element).addEOL();
}
};
var _summary = new Summary();
exports2.markdownSummary = _summary;
exports2.summary = _summary;
}
});
// node_modules/@actions/core/lib/path-utils.js
var require_path_utils = __commonJS({
"node_modules/@actions/core/lib/path-utils.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = void 0;
var path2 = __importStar(require("path"));
function toPosixPath(pth) {
return pth.replace(/[\\]/g, "/");
}
exports2.toPosixPath = toPosixPath;
function toWin32Path(pth) {
return pth.replace(/[/]/g, "\\");
}
exports2.toWin32Path = toWin32Path;
function toPlatformPath(pth) {
return pth.replace(/[/\\]/g, path2.sep);
}
exports2.toPlatformPath = toPlatformPath;
}
});
// node_modules/@actions/core/lib/core.js
var require_core = __commonJS({
"node_modules/@actions/core/lib/core.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.getIDToken = exports2.getState = exports2.saveState = exports2.group = exports2.endGroup = exports2.startGroup = exports2.info = exports2.notice = exports2.warning = exports2.error = exports2.debug = exports2.isDebug = exports2.setFailed = exports2.setCommandEcho = exports2.setOutput = exports2.getBooleanInput = exports2.getMultilineInput = exports2.getInput = exports2.addPath = exports2.setSecret = exports2.exportVariable = exports2.ExitCode = void 0;
var command_1 = require_command();
var file_command_1 = require_file_command();
var utils_1 = require_utils();
var os2 = __importStar(require("os"));
var path2 = __importStar(require("path"));
var oidc_utils_1 = require_oidc_utils();
var ExitCode;
(function(ExitCode2) {
ExitCode2[ExitCode2["Success"] = 0] = "Success";
ExitCode2[ExitCode2["Failure"] = 1] = "Failure";
})(ExitCode = exports2.ExitCode || (exports2.ExitCode = {}));
function exportVariable(name, val) {
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
const filePath = process.env["GITHUB_ENV"] || "";
if (filePath) {
return file_command_1.issueFileCommand("ENV", file_command_1.prepareKeyValueMessage(name, val));
}
command_1.issueCommand("set-env", { name }, convertedVal);
}
exports2.exportVariable = exportVariable;
function setSecret(secret) {
command_1.issueCommand("add-mask", {}, secret);
}
exports2.setSecret = setSecret;
function addPath(inputPath) {
const filePath = process.env["GITHUB_PATH"] || "";
if (filePath) {
file_command_1.issueFileCommand("PATH", inputPath);
} else {
command_1.issueCommand("add-path", {}, inputPath);
}
process.env["PATH"] = `${inputPath}${path2.delimiter}${process.env["PATH"]}`;
}
exports2.addPath = addPath;
function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || "";
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim();
}
exports2.getInput = getInput;
function getMultilineInput(name, options) {
const inputs = getInput(name, options).split("\n").filter((x) => x !== "");
if (options && options.trimWhitespace === false) {
return inputs;
}
return inputs.map((input) => input.trim());
}
exports2.getMultilineInput = getMultilineInput;
function getBooleanInput(name, options) {
const trueValue = ["true", "True", "TRUE"];
const falseValue = ["false", "False", "FALSE"];
const val = getInput(name, options);
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports2.getBooleanInput = getBooleanInput;
function setOutput(name, value) {
const filePath = process.env["GITHUB_OUTPUT"] || "";
if (filePath) {
return file_command_1.issueFileCommand("OUTPUT", file_command_1.prepareKeyValueMessage(name, value));
}
process.stdout.write(os2.EOL);
command_1.issueCommand("set-output", { name }, utils_1.toCommandValue(value));
}
exports2.setOutput = setOutput;
function setCommandEcho(enabled) {
command_1.issue("echo", enabled ? "on" : "off");
}
exports2.setCommandEcho = setCommandEcho;
function setFailed(message) {
process.exitCode = ExitCode.Failure;
error(message);
}
exports2.setFailed = setFailed;
function isDebug() {
return process.env["RUNNER_DEBUG"] === "1";
}
exports2.isDebug = isDebug;
function debug(message) {
command_1.issueCommand("debug", {}, message);
}
exports2.debug = debug;
function error(message, properties = {}) {
command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports2.error = error;
function warning(message, properties = {}) {
command_1.issueCommand("warning", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports2.warning = warning;
function notice(message, properties = {}) {
command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports2.notice = notice;
function info(message) {
process.stdout.write(message + os2.EOL);
}
exports2.info = info;
function startGroup(name) {
command_1.issue("group", name);
}
exports2.startGroup = startGroup;
function endGroup() {
command_1.issue("endgroup");
}
exports2.endGroup = endGroup;
function group(name, fn) {
return __awaiter2(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
} finally {
endGroup();
}
return result;
});
}
exports2.group = group;
function saveState(name, value) {
const filePath = process.env["GITHUB_STATE"] || "";
if (filePath) {
return file_command_1.issueFileCommand("STATE", file_command_1.prepareKeyValueMessage(name, value));
}
command_1.issueCommand("save-state", { name }, utils_1.toCommandValue(value));
}
exports2.saveState = saveState;
function getState(name) {
return process.env[`STATE_${name}`] || "";
}
exports2.getState = getState;
function getIDToken(aud) {
return __awaiter2(this, void 0, void 0, function* () {
return yield oidc_utils_1.OidcClient.getIDToken(aud);
});
}
exports2.getIDToken = getIDToken;
var summary_1 = require_summary();
Object.defineProperty(exports2, "summary", { enumerable: true, get: function() {
return summary_1.summary;
} });
var summary_2 = require_summary();
Object.defineProperty(exports2, "markdownSummary", { enumerable: true, get: function() {
return summary_2.markdownSummary;
} });
var path_utils_1 = require_path_utils();
Object.defineProperty(exports2, "toPosixPath", { enumerable: true, get: function() {
return path_utils_1.toPosixPath;
} });
Object.defineProperty(exports2, "toWin32Path", { enumerable: true, get: function() {
return path_utils_1.toWin32Path;
} });
Object.defineProperty(exports2, "toPlatformPath", { enumerable: true, get: function() {
return path_utils_1.toPlatformPath;
} });
}
});
// node_modules/@actions/io/lib/io-util.js
var require_io_util = __commonJS({
"node_modules/@actions/io/lib/io-util.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var _a;
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.getCmdPath = exports2.tryGetExecutablePath = exports2.isRooted = exports2.isDirectory = exports2.exists = exports2.READONLY = exports2.UV_FS_O_EXLOCK = exports2.IS_WINDOWS = exports2.unlink = exports2.symlink = exports2.stat = exports2.rmdir = exports2.rm = exports2.rename = exports2.readlink = exports2.readdir = exports2.open = exports2.mkdir = exports2.lstat = exports2.copyFile = exports2.chmod = void 0;
var fs2 = __importStar(require("fs"));
var path2 = __importStar(require("path"));
_a = fs2.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.readlink = _a.readlink, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
exports2.IS_WINDOWS = process.platform === "win32";
exports2.UV_FS_O_EXLOCK = 268435456;
exports2.READONLY = fs2.constants.O_RDONLY;
function exists(fsPath) {
return __awaiter2(this, void 0, void 0, function* () {
try {
yield exports2.stat(fsPath);
} catch (err) {
if (err.code === "ENOENT") {
return false;
}
throw err;
}
return true;
});
}
exports2.exists = exists;
function isDirectory(fsPath, useStat = false) {
return __awaiter2(this, void 0, void 0, function* () {
const stats = useStat ? yield exports2.stat(fsPath) : yield exports2.lstat(fsPath);
return stats.isDirectory();
});
}
exports2.isDirectory = isDirectory;
function isRooted(p) {
p = normalizeSeparators(p);
if (!p) {
throw new Error('isRooted() parameter "p" cannot be empty');
}
if (exports2.IS_WINDOWS) {
return p.startsWith("\\") || /^[A-Z]:/i.test(p);
}
return p.startsWith("/");
}
exports2.isRooted = isRooted;
function tryGetExecutablePath(filePath, extensions) {
return __awaiter2(this, void 0, void 0, function* () {
let stats = void 0;
try {
stats = yield exports2.stat(filePath);
} catch (err) {
if (err.code !== "ENOENT") {
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
}
}
if (stats && stats.isFile()) {
if (exports2.IS_WINDOWS) {
const upperExt = path2.extname(filePath).toUpperCase();
if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) {
return filePath;
}
} else {
if (isUnixExecutable(stats)) {
return filePath;
}
}
}
const originalFilePath = filePath;
for (const extension of extensions) {
filePath = originalFilePath + extension;
stats = void 0;
try {
stats = yield exports2.stat(filePath);
} catch (err) {
if (err.code !== "ENOENT") {
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
}
}
if (stats && stats.isFile()) {
if (exports2.IS_WINDOWS) {
try {
const directory = path2.dirname(filePath);
const upperName = path2.basename(filePath).toUpperCase();
for (const actualName of yield exports2.readdir(directory)) {
if (upperName === actualName.toUpperCase()) {
filePath = path2.join(directory, actualName);
break;
}
}
} catch (err) {
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
}
return filePath;
} else {
if (isUnixExecutable(stats)) {
return filePath;
}
}
}
}
return "";
});
}
exports2.tryGetExecutablePath = tryGetExecutablePath;
function normalizeSeparators(p) {
p = p || "";
if (exports2.IS_WINDOWS) {
p = p.replace(/\//g, "\\");
return p.replace(/\\\\+/g, "\\");
}
return p.replace(/\/\/+/g, "/");
}
function isUnixExecutable(stats) {
return (stats.mode & 1) > 0 || (stats.mode & 8) > 0 && stats.gid === process.getgid() || (stats.mode & 64) > 0 && stats.uid === process.getuid();
}
function getCmdPath() {
var _a2;
return (_a2 = process.env["COMSPEC"]) !== null && _a2 !== void 0 ? _a2 : `cmd.exe`;
}
exports2.getCmdPath = getCmdPath;
}
});
// node_modules/@actions/io/lib/io.js
var require_io = __commonJS({
"node_modules/@actions/io/lib/io.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.findInPath = exports2.which = exports2.mkdirP = exports2.rmRF = exports2.mv = exports2.cp = void 0;
var assert_1 = require("assert");
var path2 = __importStar(require("path"));
var ioUtil = __importStar(require_io_util());
function cp(source, dest, options = {}) {
return __awaiter2(this, void 0, void 0, function* () {
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
if (destStat && destStat.isFile() && !force) {
return;
}
const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path2.join(dest, path2.basename(source)) : dest;
if (!(yield ioUtil.exists(source))) {
throw new Error(`no such file or directory: ${source}`);
}
const sourceStat = yield ioUtil.stat(source);
if (sourceStat.isDirectory()) {
if (!recursive) {
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
} else {
yield cpDirRecursive(source, newDest, 0, force);
}
} else {
if (path2.relative(source, newDest) === "") {
throw new Error(`'${newDest}' and '${source}' are the same file`);
}
yield copyFile(source, newDest, force);
}
});
}
exports2.cp = cp;
function mv(source, dest, options = {}) {
return __awaiter2(this, void 0, void 0, function* () {
if (yield ioUtil.exists(dest)) {
let destExists = true;
if (yield ioUtil.isDirectory(dest)) {
dest = path2.join(dest, path2.basename(source));
destExists = yield ioUtil.exists(dest);
}
if (destExists) {
if (options.force == null || options.force) {
yield rmRF(dest);
} else {
throw new Error("Destination already exists");
}
}
}
yield mkdirP(path2.dirname(dest));
yield ioUtil.rename(source, dest);
});
}
exports2.mv = mv;
function rmRF(inputPath) {
return __awaiter2(this, void 0, void 0, function* () {
if (ioUtil.IS_WINDOWS) {
if (/[*"<>|]/.test(inputPath)) {
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
}
}
try {
yield ioUtil.rm(inputPath, {
force: true,
maxRetries: 3,
recursive: true,
retryDelay: 300
});
} catch (err) {
throw new Error(`File was unable to be removed ${err}`);
}
});
}
exports2.rmRF = rmRF;
function mkdirP(fsPath) {
return __awaiter2(this, void 0, void 0, function* () {
assert_1.ok(fsPath, "a path argument must be provided");
yield ioUtil.mkdir(fsPath, { recursive: true });
});
}
exports2.mkdirP = mkdirP;
function which(tool, check) {
return __awaiter2(this, void 0, void 0, function* () {
if (!tool) {
throw new Error("parameter 'tool' is required");
}
if (check) {
const result = yield which(tool, false);
if (!result) {
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.`);
} 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.`);
}
}
return result;
}
const matches = yield findInPath(tool);
if (matches && matches.length > 0) {
return matches[0];
}
return "";
});
}
exports2.which = which;
function findInPath(tool) {
return __awaiter2(this, void 0, void 0, function* () {
if (!tool) {
throw new Error("parameter 'tool' is required");
}
const extensions = [];
if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) {
for (const extension of process.env["PATHEXT"].split(path2.delimiter)) {
if (extension) {
extensions.push(extension);
}
}
}
if (ioUtil.isRooted(tool)) {
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
if (filePath) {
return [filePath];
}
return [];
}
if (tool.includes(path2.sep)) {
return [];
}
const directories = [];
if (process.env.PATH) {
for (const p of process.env.PATH.split(path2.delimiter)) {
if (p) {
directories.push(p);
}
}
}
const matches = [];
for (const directory of directories) {
const filePath = yield ioUtil.tryGetExecutablePath(path2.join(directory, tool), extensions);
if (filePath) {
matches.push(filePath);
}
}
return matches;
});
}
exports2.findInPath = findInPath;
function readCopyOptions(options) {
const force = options.force == null ? true : options.force;
const recursive = Boolean(options.recursive);
const copySourceDirectory = options.copySourceDirectory == null ? true : Boolean(options.copySourceDirectory);
return { force, recursive, copySourceDirectory };
}
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
return __awaiter2(this, void 0, void 0, function* () {
if (currentDepth >= 255)
return;
currentDepth++;
yield mkdirP(destDir);
const files = yield ioUtil.readdir(sourceDir);
for (const fileName of files) {
const srcFile = `${sourceDir}/${fileName}`;
const destFile = `${destDir}/${fileName}`;
const srcFileStat = yield ioUtil.lstat(srcFile);
if (srcFileStat.isDirectory()) {
yield cpDirRecursive(srcFile, destFile, currentDepth, force);
} else {
yield copyFile(srcFile, destFile, force);
}
}
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
});
}
function copyFile(srcFile, destFile, force) {
return __awaiter2(this, void 0, void 0, function* () {
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
try {
yield ioUtil.lstat(destFile);
yield ioUtil.unlink(destFile);
} catch (e) {
if (e.code === "EPERM") {
yield ioUtil.chmod(destFile, "0666");
yield ioUtil.unlink(destFile);
}
}
const symlinkFull = yield ioUtil.readlink(srcFile);
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? "junction" : null);
} else if (!(yield ioUtil.exists(destFile)) || force) {
yield ioUtil.copyFile(srcFile, destFile);
}
});
}
}
});
// node_modules/@actions/exec/lib/toolrunner.js
var require_toolrunner = __commonJS({
"node_modules/@actions/exec/lib/toolrunner.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.argStringToArray = exports2.ToolRunner = void 0;
var os2 = __importStar(require("os"));
var events = __importStar(require("events"));
var child = __importStar(require("child_process"));
var path2 = __importStar(require("path"));
var io2 = __importStar(require_io());
var ioUtil = __importStar(require_io_util());
var timers_1 = require("timers");
var IS_WINDOWS = process.platform === "win32";
var ToolRunner = class extends events.EventEmitter {
constructor(toolPath, args2, options) {
super();
if (!toolPath) {
throw new Error("Parameter 'toolPath' cannot be null or empty.");
}
this.toolPath = toolPath;
this.args = args2 || [];
this.options = options || {};
}
_debug(message) {
if (this.options.listeners && this.options.listeners.debug) {
this.options.listeners.debug(message);
}
}
_getCommandString(options, noPrefix) {
const toolPath = this._getSpawnFileName();
const args2 = this._getSpawnArgs(options);
let cmd = noPrefix ? "" : "[command]";
if (IS_WINDOWS) {
if (this._isCmdFile()) {
cmd += toolPath;
for (const a of args2) {
cmd += ` ${a}`;
}
} else if (options.windowsVerbatimArguments) {
cmd += `"${toolPath}"`;
for (const a of args2) {
cmd += ` ${a}`;
}
} else {
cmd += this._windowsQuoteCmdArg(toolPath);
for (const a of args2) {
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
}
}
} else {
cmd += toolPath;
for (const a of args2) {
cmd += ` ${a}`;
}
}
return cmd;
}
_processLineBuffer(data, strBuffer, onLine) {
try {
let s = strBuffer + data.toString();
let n = s.indexOf(os2.EOL);
while (n > -1) {
const line = s.substring(0, n);
onLine(line);
s = s.substring(n + os2.EOL.length);
n = s.indexOf(os2.EOL);
}
return s;
} catch (err) {
this._debug(`error processing line. Failed with error ${err}`);
return "";
}
}
_getSpawnFileName() {
if (IS_WINDOWS) {
if (this._isCmdFile()) {
return process.env["COMSPEC"] || "cmd.exe";
}
}
return this.toolPath;
}
_getSpawnArgs(options) {
if (IS_WINDOWS) {
if (this._isCmdFile()) {
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
for (const a of this.args) {
argline += " ";
argline += options.windowsVerbatimArguments ? a : this._windowsQuoteCmdArg(a);
}
argline += '"';
return [argline];
}
}
return this.args;
}
_endsWith(str, end) {
return str.endsWith(end);
}
_isCmdFile() {
const upperToolPath = this.toolPath.toUpperCase();
return this._endsWith(upperToolPath, ".CMD") || this._endsWith(upperToolPath, ".BAT");
}
_windowsQuoteCmdArg(arg) {
if (!this._isCmdFile()) {
return this._uvQuoteCmdArg(arg);
}
if (!arg) {
return '""';
}
const cmdSpecialChars = [
" ",
" ",
"&",
"(",
")",
"[",
"]",
"{",
"}",
"^",
"=",
";",
"!",
"'",
"+",
",",
"`",
"~",
"|",
"<",
">",
'"'
];
let needsQuotes = false;
for (const char of arg) {
if (cmdSpecialChars.some((x) => x === char)) {
needsQuotes = true;
break;
}
}
if (!needsQuotes) {
return arg;
}
let reverse = '"';
let quoteHit = true;
for (let i = arg.length; i > 0; i--) {
reverse += arg[i - 1];
if (quoteHit && arg[i - 1] === "\\") {
reverse += "\\";
} else if (arg[i - 1] === '"') {
quoteHit = true;
reverse += '"';
} else {
quoteHit = false;
}
}
reverse += '"';
return reverse.split("").reverse().join("");
}
_uvQuoteCmdArg(arg) {
if (!arg) {
return '""';
}
if (!arg.includes(" ") && !arg.includes(" ") && !arg.includes('"')) {
return arg;
}
if (!arg.includes('"') && !arg.includes("\\")) {
return `"${arg}"`;
}
let reverse = '"';
let quoteHit = true;
for (let i = arg.length; i > 0; i--) {
reverse += arg[i - 1];
if (quoteHit && arg[i - 1] === "\\") {
reverse += "\\";
} else if (arg[i - 1] === '"') {
quoteHit = true;
reverse += "\\";
} else {
quoteHit = false;
}
}
reverse += '"';
return reverse.split("").reverse().join("");
}
_cloneExecOptions(options) {
options = options || {};
const result = {
cwd: options.cwd || process.cwd(),
env: options.env || process.env,
silent: options.silent || false,
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
failOnStdErr: options.failOnStdErr || false,
ignoreReturnCode: options.ignoreReturnCode || false,
delay: options.delay || 1e4
};
result.outStream = options.outStream || process.stdout;
result.errStream = options.errStream || process.stderr;
return result;
}
_getSpawnOptions(options, toolPath) {
options = options || {};
const result = {};
result.cwd = options.cwd;
result.env = options.env;
result["windowsVerbatimArguments"] = options.windowsVerbatimArguments || this._isCmdFile();
if (options.windowsVerbatimArguments) {
result.argv0 = `"${toolPath}"`;
}
return result;
}
/**
* Exec a tool.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param tool path to tool to exec
* @param options optional exec options. See ExecOptions
* @returns number
*/
exec() {
return __awaiter2(this, void 0, void 0, function* () {
if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) {
this.toolPath = path2.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
}
this.toolPath = yield io2.which(this.toolPath, true);
return new Promise((resolve, reject) => __awaiter2(this, void 0, void 0, function* () {
this._debug(`exec tool: ${this.toolPath}`);
this._debug("arguments:");
for (const arg of this.args) {
this._debug(` ${arg}`);
}
const optionsNonNull = this._cloneExecOptions(this.options);
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os2.EOL);
}
const state = new ExecState(optionsNonNull, this.toolPath);
state.on("debug", (message) => {
this._debug(message);
});
if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
}
const fileName = this._getSpawnFileName();
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
let stdbuffer = "";
if (cp.stdout) {
cp.stdout.on("data", (data) => {
if (this.options.listeners && this.options.listeners.stdout) {
this.options.listeners.stdout(data);
}
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(data);
}
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
if (this.options.listeners && this.options.listeners.stdline) {
this.options.listeners.stdline(line);
}
});
});
}
let errbuffer = "";
if (cp.stderr) {
cp.stderr.on("data", (data) => {
state.processStderr = true;
if (this.options.listeners && this.options.listeners.stderr) {
this.options.listeners.stderr(data);
}
if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) {
const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
s.write(data);
}
errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
if (this.options.listeners && this.options.listeners.errline) {
this.options.listeners.errline(line);
}
});
});
}
cp.on("error", (err) => {
state.processError = err.message;
state.processExited = true;
state.processClosed = true;
state.CheckComplete();
});
cp.on("exit", (code) => {
state.processExitCode = code;
state.processExited = true;
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
state.CheckComplete();
});
cp.on("close", (code) => {
state.processExitCode = code;
state.processExited = true;
state.processClosed = true;
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
state.CheckComplete();
});
state.on("done", (error, exitCode) => {
if (stdbuffer.length > 0) {
this.emit("stdline", stdbuffer);
}
if (errbuffer.length > 0) {
this.emit("errline", errbuffer);
}
cp.removeAllListeners();
if (error) {
reject(error);
} else {
resolve(exitCode);
}
});
if (this.options.input) {
if (!cp.stdin) {
throw new Error("child process missing stdin");
}
cp.stdin.end(this.options.input);
}
}));
});
}
};
exports2.ToolRunner = ToolRunner;
function argStringToArray(argString) {
const args2 = [];
let inQuotes = false;
let escaped = false;
let arg = "";
function append(c) {
if (escaped && c !== '"') {
arg += "\\";
}
arg += c;
escaped = false;
}
for (let i = 0; i < argString.length; i++) {
const c = argString.charAt(i);
if (c === '"') {
if (!escaped) {
inQuotes = !inQuotes;
} else {
append(c);
}
continue;
}
if (c === "\\" && escaped) {
append(c);
continue;
}
if (c === "\\" && inQuotes) {
escaped = true;
continue;
}
if (c === " " && !inQuotes) {
if (arg.length > 0) {
args2.push(arg);
arg = "";
}
continue;
}
append(c);
}
if (arg.length > 0) {
args2.push(arg.trim());
}
return args2;
}
exports2.argStringToArray = argStringToArray;
var ExecState = class _ExecState extends events.EventEmitter {
constructor(options, toolPath) {
super();
this.processClosed = false;
this.processError = "";
this.processExitCode = 0;
this.processExited = false;
this.processStderr = false;
this.delay = 1e4;
this.done = false;
this.timeout = null;
if (!toolPath) {
throw new Error("toolPath must not be empty");
}
this.options = options;
this.toolPath = toolPath;
if (options.delay) {
this.delay = options.delay;
}
}
CheckComplete() {
if (this.done) {
return;
}
if (this.processClosed) {
this._setResult();
} else if (this.processExited) {
this.timeout = timers_1.setTimeout(_ExecState.HandleTimeout, this.delay, this);
}
}
_debug(message) {
this.emit("debug", message);
}
_setResult() {
let error;
if (this.processExited) {
if (this.processError) {
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
} else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
} else if (this.processStderr && this.options.failOnStdErr) {
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
}
}
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.done = true;
this.emit("done", error, this.processExitCode);
}
static HandleTimeout(state) {
if (state.done) {
return;
}
if (!state.processClosed && state.processExited) {
const message = `The STDIO streams did not close within ${state.delay / 1e3} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
state._debug(message);
}
state._setResult();
}
};
}
});
// node_modules/@actions/exec/lib/exec.js
var require_exec = __commonJS({
"node_modules/@actions/exec/lib/exec.js"(exports2) {
"use strict";
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
} : function(o, v) {
o["default"] = v;
});
var __importStar = exports2 && exports2.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.getExecOutput = exports2.exec = void 0;
var string_decoder_1 = require("string_decoder");
var tr = __importStar(require_toolrunner());
function exec2(commandLine, args2, options) {
return __awaiter2(this, void 0, void 0, function* () {
const commandArgs = tr.argStringToArray(commandLine);
if (commandArgs.length === 0) {
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
}
const toolPath = commandArgs[0];
args2 = commandArgs.slice(1).concat(args2 || []);
const runner = new tr.ToolRunner(toolPath, args2, options);
return runner.exec();
});
}
exports2.exec = exec2;
function getExecOutput(commandLine, args2, options) {
var _a, _b;
return __awaiter2(this, void 0, void 0, function* () {
let stdout = "";
let stderr = "";
const stdoutDecoder = new string_decoder_1.StringDecoder("utf8");
const stderrDecoder = new string_decoder_1.StringDecoder("utf8");
const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
const stdErrListener = (data) => {
stderr += stderrDecoder.write(data);
if (originalStdErrListener) {
originalStdErrListener(data);
}
};
const stdOutListener = (data) => {
stdout += stdoutDecoder.write(data);
if (originalStdoutListener) {
originalStdoutListener(data);
}
};
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
const exitCode = yield exec2(commandLine, args2, Object.assign(Object.assign({}, options), { listeners }));
stdout += stdoutDecoder.end();
stderr += stderrDecoder.end();
return {
exitCode,
stdout,
stderr
};
});
}
exports2.getExecOutput = getExecOutput;
}
});
// out/lib/actionLogger.js
var require_actionLogger = __commonJS({
"out/lib/actionLogger.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.ActionLogger = void 0;
var core2 = require_core();
var ActionLogger = class {
info(...args2) {
core2.info(args2.join());
}
warn(...args2) {
core2.warning(args2.join());
}
error(...args2) {
const errorMessage = args2.join();
core2.setFailed(errorMessage);
core2.error(errorMessage);
}
debug(...args2) {
core2.debug(args2.join());
}
log(...args2) {
console.log(args2.join());
}
};
exports2.ActionLogger = ActionLogger;
}
});
// out/pacPackageInfo.json
var require_pacPackageInfo = __commonJS({
"out/pacPackageInfo.json"(exports2, module2) {
module2.exports = {
PacPackageName: "Microsoft.PowerApps.CLI",
LegacyLinuxPackage: "Microsoft.PowerApps.CLI.Core.linux-x64",
DotnetToolName: "Microsoft.PowerApps.CLI.Tool",
PacPackageVersion: "1.34.4"
};
}
});
// out/lib/getExePath.js
var require_getExePath = __commonJS({
"out/lib/getExePath.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var path_1 = require("path");
function getExePath(...relativePath) {
const currentDirectory = (0, path_1.resolve)(__dirname);
const parentDir = (0, path_1.dirname)(currentDirectory);
let outDirRoot;
switch ((0, path_1.basename)(parentDir)) {
case "actions":
outDirRoot = (0, path_1.resolve)((0, path_1.dirname)(parentDir));
break;
case "src":
case "out":
outDirRoot = (0, path_1.resolve)(parentDir, "..", "out");
break;
default:
throw Error(`ExeRunner: cannot resolve outDirRoot running from this location: ${path_1.dirname}`);
}
return (0, path_1.resolve)(outDirRoot, ...relativePath);
}
exports2.default = getExePath;
}
});
// package.json
var require_package = __commonJS({
"package.json"(exports2, module2) {
module2.exports = {
name: "@microsoft/powerplatform-actions",
version: "1.7.0",
description: "Github Action for Power Platform",
main: "index.js",
scripts: {
clean: "scorch",
build: "node node_modules/gulp/bin/gulp.js",
test: "node node_modules/gulp/bin/gulp.js test",
ci: "node node_modules/gulp/bin/gulp.js ci",
"update-dist": "node node_modules/gulp/bin/gulp.js updateDist"
},
author: "PowerApps-ISV-Tools",
license: "MIT",
repository: {
type: "git",
url: "https://github.com/microsoft/powerplatform-actions.git"
},
devDependencies: {
"@types/async": "^3.2.24",
"@types/chai": "^4.3.6",
"@types/fancy-log": "^2.0.2",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.9",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.10",
"@types/sinon": "^10.0.15",
"@types/sinon-chai": "^3.2.12",
"@types/unzip-stream": "^0.3.4",
"@types/uuid": "^9.0.8",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
async: "^3.2.5",
chai: "^4.4.1",
dotenv: "^16.4.5",
esbuild: "^0.21.5",
eslint: "^8.49.0",
"fancy-log": "^2.0.0",
glob: "^10.4.1",
"glob-parent": "^6.0.2",
gulp: "^5.0.0",
"gulp-eslint-new": "^2.0.0",
"gulp-mocha": "^8.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
mocha: "^10.4.0",
"node-fetch": "^3.3.2",
postcss: "^8.4.38",
"ps-list": "^8.1.1",
rewiremock: "^3.14.5",
sinon: "^15.2.0",
"sinon-chai": "^3.5.0",
"ts-node": "^10.9.2",
"ts-sinon": "^2.0.1",
typescript: "^5.4.5",
"unzip-stream": "^0.3.4",
winston: "^3.13.0",
yargs: "^17.7.2"
},
dependencies: {
"@actions/artifact": "^1.1.1",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@microsoft/powerplatform-cli-wrapper": "^0.1.129",
"date-fns": "^3.6.0",
"fs-extra": "^11.2.0",
"js-yaml": "^4.1",
uuid: "^9.0.1"
}
};
}
});
// out/lib/runnerParameters.js
var require_runnerParameters = __commonJS({
"out/lib/runnerParameters.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.PacPathEnvVarName = exports2.PacInstalledEnvVarName = exports2.getAutomationAgent = exports2.runnerParameters = void 0;
var node_process_1 = require("node:process");
var actionLogger_12 = require_actionLogger();
var getExePath_1 = require_getExePath();
var PacInstalledEnvVarName = "POWERPLATFORMTOOLS_PACINSTALLED";
exports2.PacInstalledEnvVarName = PacInstalledEnvVarName;
var PacPathEnvVarName = "POWERPLATFORMTOOLS_PACPATH";
exports2.PacPathEnvVarName = PacPathEnvVarName;
function getAutomationAgent() {
const jsonPackage = require_package();
const productName = jsonPackage.name.split("/")[1];
return productName + "/" + jsonPackage.version;
}
exports2.getAutomationAgent = getAutomationAgent;
var ActionsRunnerParameters = class {
constructor() {
this.workingDir = process.env["GITHUB_WORKSPACE"] || (0, node_process_1.cwd)();
this.logger = new actionLogger_12.ActionLogger();
this.agent = getAutomationAgent();
this.pacPath = process.env[PacPathEnvVarName];
}
get runnersDir() {
if (process.env[PacInstalledEnvVarName] !== "true") {
throw new Error(`PAC is not installed. Please run the actions-install action first.`);
}
return (0, getExePath_1.default)();
}
};
var runnerParameters = new ActionsRunnerParameters();
exports2.runnerParameters = runnerParameters;
}
});
// out/actions/actions-install/index.js
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
var core = require_core();
var exec = require_exec();
var io = require_io();
var os = require("node:os");
var node_path_1 = require("node:path");
var fs = require("node:fs/promises");
var path = require("node:path");
var actionLogger_1 = require_actionLogger();
var PacInfo = require_pacPackageInfo();
var runnerParameters_1 = require_runnerParameters();
var argName = {
versionOverride: "pac-version-override",
nugetFeedOverride: "nuget-feed-override",
nugetFeedUsername: "nuget-feed-username",
nugetFeedPassword: "nuget-feed-password",
localPacPath: "use-preinstalled-pac",
addToolsToPath: "add-tools-to-path"
};
var args;
var MutuallyExclusiveArgsError = class extends Error {
constructor(argument1, argument2) {
super(`Cannot specify both ${argument1} and ${argument2}.`);
}
};
(() => __awaiter(void 0, void 0, void 0, function* () {
if (process.env.GITHUB_ACTIONS) {
yield main();
}
}))().catch((error) => {
const logger = new actionLogger_1.ActionLogger();
logger.error(`failed: ${error}`);
core.endGroup();
});
function main() {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup("actions-install:");
args = {
versionOverride: core.getInput(argName.versionOverride, { required: false }),
nugetFeedOverride: core.getInput(argName.nugetFeedOverride, { required: false }),
nugetFeedUsername: core.getInput(argName.nugetFeedUsername, { required: false }),
nugetFeedPassword: core.getInput(argName.nugetFeedPassword, { required: false }),
addToolsToPath: core.getInput(argName.addToolsToPath, { required: false }) === "true",
localPacPath: core.getInput(argName.localPacPath, { required: false })
};
args.nugetFeedPassword && core.setSecret(args.nugetFeedPassword);
if (args.localPacPath && args.nugetFeedOverride)
throw new MutuallyExclusiveArgsError(argName.localPacPath, argName.nugetFeedOverride);
if (args.localPacPath && args.versionOverride)
throw new MutuallyExclusiveArgsError(argName.localPacPath, argName.versionOverride);
if (args.nugetFeedPassword && !args.nugetFeedOverride) {
throw new Error(`Do not provide Authentication args (${argName.nugetFeedPassword}) without providing a feed which requires authentication via ${argName.nugetFeedOverride}.`);
}
if (args.nugetFeedPassword && !args.nugetFeedUsername || !args.nugetFeedPassword && args.nugetFeedUsername) {
throw new Error(`Cannot specify ${argName.nugetFeedPassword} or ${argName.nugetFeedUsername} without the other.`);
}
if (args.versionOverride && args.versionOverride !== PacInfo.PacPackageVersion) {
core.warning(`Actions built targetting PAC ${PacInfo.PacPackageVersion}, so Action and PAC parameters might not match with requested version ${args.versionOverride}.`);
}
if (process.env[runnerParameters_1.PacInstalledEnvVarName] === "true") {
core.warning("PAC is already installed. Skipping installation.");
core.endGroup();
return;
}
const packageVersion = args.versionOverride || PacInfo.PacPackageVersion;
if (args.localPacPath) {
yield usingPreinstalledPac(args.localPacPath);
} else if (os.platform() === "win32") {
yield nugetInstall(PacInfo.PacPackageName, packageVersion, args.nugetFeedOverride, args.nugetFeedUsername, args.nugetFeedPassword);
} else {
yield dotnetInstall(PacInfo.DotnetToolName, packageVersion, args.nugetFeedOverride, args.nugetFeedUsername, args.nugetFeedPassword);
}
core.endGroup();
});
}
exports.main = main;
function removePacFromPath(path2) {
return path2.replace(/(\/|\\)(pac.exe|pac)$/, "");
}
function usingPreinstalledPac(localPacPath) {
return __awaiter(this, void 0, void 0, function* () {
const absolutePath = path.resolve(localPacPath);
core.info(`Using preinstalled pac from ${absolutePath}`);
yield fs.access(absolutePath, fs.constants.X_OK).catch(() => {
throw new Error(`The path ${absolutePath} does not exist or is not executable.`);
});
if (os.platform() === "win32" && !absolutePath.endsWith("pac.exe")) {
throw new Error(`The path ${absolutePath} does point at the expected 'pac.exe'.`);
} else if (os.platform() !== "win32" && !absolutePath.endsWith("pac")) {
throw new Error(`The path ${absolutePath} does point at the expected 'pac'.`);
}
core.exportVariable(runnerParameters_1.PacInstalledEnvVarName, "true");
core.exportVariable(runnerParameters_1.PacPathEnvVarName, absolutePath);
if (args.addToolsToPath) {
core.addPath(removePacFromPath(absolutePath));
}
core.warning(`Actions built targetting PAC ${PacInfo.PacPackageVersion}, so Action and PAC parameters might not match if preinstalled pac is a different version.`);
});
}
function nugetInstall(packageName, packageVersion, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Installing ${packageName}.${packageVersion} via nuget.exe`);
yield checkForInstallationTool("nuget");
const toolpath = yield fs.mkdtemp(path.join(os.tmpdir(), "powerplatform-actions-"));
let nugetConfigFile = void 0;
try {
if (nugetFeedOverride && nugetFeedOverride !== "https://api.nuget.org/v3/index.json") {
nugetConfigFile = yield createNugetConfigViaNuget(toolpath, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword);
}
const installArgs = [
"install",
packageName,
"-Version",
packageVersion,
"-DependencyVersion",
"ignore",
// There are no dependencies, so don't waste that time checking
"-NonInteractive",
"-OutputDirectory",
toolpath
];
nugetConfigFile && installArgs.push("-ConfigFile", nugetConfigFile);
yield exec.getExecOutput("nuget", installArgs);
const pacPathWithoutExecutable = (0, node_path_1.resolve)(toolpath, packageName + "." + packageVersion, "tools");
const pacPath = (0, node_path_1.resolve)(pacPathWithoutExecutable, "pac.exe");
core.exportVariable(runnerParameters_1.PacInstalledEnvVarName, "true");
core.exportVariable(runnerParameters_1.PacPathEnvVarName, pacPath);
if (args.addToolsToPath) {
core.addPath(pacPathWithoutExecutable);
}
} finally {
if (nugetConfigFile) {
yield fs.rm(nugetConfigFile);
}
}
});
}
function dotnetInstall(packageName, packageVersion, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Installing ${packageName}.${packageVersion} via dotnet tool install`);
yield checkForInstallationTool("dotnet");
const toolpath = yield fs.mkdtemp(path.join(os.tmpdir(), "powerplatform-actions-"));
let nugetConfigFile = void 0;
try {
if (nugetFeedOverride && nugetFeedOverride !== "https://api.nuget.org/v3/index.json") {
nugetConfigFile = yield createNugetConfigViaDotnet(toolpath, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword);
}
const installArgs = ["tool", "install", packageName, "--version", packageVersion, "--tool-path", toolpath];
nugetConfigFile && installArgs.push("--configfile", nugetConfigFile);
yield exec.getExecOutput("dotnet", installArgs);
core.exportVariable(runnerParameters_1.PacInstalledEnvVarName, "true");
const pacPath = path.join(toolpath, os.platform() === "win32" ? "pac.exe" : "pac");
core.exportVariable(runnerParameters_1.PacPathEnvVarName, pacPath);
if (args.addToolsToPath) {
core.addPath(removePacFromPath(toolpath));
}
core.info(`pac installed to ${process.env[runnerParameters_1.PacPathEnvVarName]}`);
} finally {
if (nugetConfigFile) {
yield fs.rm(nugetConfigFile);
}
}
});
}
function createNugetConfigViaNuget(toolDirectory, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Adding nuget feed ${nugetFeedOverride} to nuget sources`);
const filename = path.resolve(toolDirectory, "nuget.config");
yield fs.writeFile(filename, `<?xml version="1.0" encoding="utf-8"?><configuration></configuration>`);
const configArgs = ["sources", "add", "-name", "pacNugetFeed", "-source", nugetFeedOverride, `-ConfigFile`, filename];
nugetFeedUsername && configArgs.push("-username", nugetFeedUsername);
nugetFeedPassword && configArgs.push("-password", nugetFeedPassword);
yield exec.getExecOutput("nuget", configArgs);
return filename;
});
}
function createNugetConfigViaDotnet(toolDirectory, nugetFeedOverride, nugetFeedUsername, nugetFeedPassword) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Adding nuget feed ${nugetFeedOverride} to dotnet nuget sources`);
const filename = path.resolve(toolDirectory, "nuget.config");
yield exec.getExecOutput("dotnet", ["new", "nugetconfig", "-o", toolDirectory]);
yield exec.getExecOutput("dotnet", ["nuget", "remove", "source", "nuget", "--configfile", filename]);
const nugetSourceArgs = ["nuget", "add", "source", nugetFeedOverride, "--name", "pacNugetFeed", "--configfile", filename];
nugetFeedUsername && nugetSourceArgs.push("--username", nugetFeedUsername);
nugetFeedPassword && nugetSourceArgs.push("--password", nugetFeedPassword);
if (os.platform() !== "win32") {
nugetSourceArgs.push("--store-password-in-clear-text");
}
yield exec.getExecOutput("dotnet", nugetSourceArgs);
return filename;
});
}
function checkForInstallationTool(toolName) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield io.which(toolName, true);
} catch (error) {
throw new Error(`Runner does not have prerequisite "${toolName}" installed, as it was not found in the PATH.`);
}
});
}