From c4eaa8ceb1b933691ec00bf1b54c50604b80c9fb Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:49:04 -0800 Subject: [PATCH] Stop warning about python-version and python-platform in 1.1.352+ --- dist/index.js | 6635 ++++++++++++++------------- src/__snapshots__/main.test.ts.snap | 320 ++ src/helpers.ts | 11 - src/main.test.ts | 96 +- src/main.ts | 31 +- 5 files changed, 3764 insertions(+), 3329 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9bf2dc7..190835a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4264,2632 +4264,2223 @@ var require_toml = __commonJS({ } }); -// node_modules/shell-quote/quote.js -var require_quote = __commonJS({ - "node_modules/shell-quote/quote.js"(exports2, module2) { - "use strict"; - module2.exports = function quote2(xs) { - return xs.map(function(s) { - if (s && typeof s === "object") { - return s.op.replace(/(.)/g, "\\$1"); - } - if (/["\s]/.test(s) && !/'/.test(s)) { - return "'" + s.replace(/(['\\])/g, "\\$1") + "'"; - } - if (/["'\s]/.test(s)) { - return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"'; - } - return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2"); - }).join(" "); +// node_modules/semver/internal/debug.js +var require_debug = __commonJS({ + "node_modules/semver/internal/debug.js"(exports2, module2) { + var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { }; + module2.exports = debug; } }); -// node_modules/shell-quote/parse.js -var require_parse2 = __commonJS({ - "node_modules/shell-quote/parse.js"(exports2, module2) { - "use strict"; - var CONTROL = "(?:" + [ - "\\|\\|", - "\\&\\&", - ";;", - "\\|\\&", - "\\<\\(", - "\\<\\<\\<", - ">>", - ">\\&", - "<\\&", - "[&;()|<>]" - ].join("|") + ")"; - var controlRE = new RegExp("^" + CONTROL + "$"); - var META = "|&;()<> \\t"; - var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"'; - var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'"; - var hash = /^#$/; - var SQ = "'"; - var DQ = '"'; - var DS = "$"; - var TOKEN = ""; - var mult = 4294967296; - for (i = 0; i < 4; i++) { - TOKEN += (mult * Math.random()).toString(16); - } - var i; - var startsWithToken = new RegExp("^" + TOKEN); - function matchAll(s, r) { - var origIndex = r.lastIndex; - var matches = []; - var matchObj; - while (matchObj = r.exec(s)) { - matches.push(matchObj); - if (r.lastIndex === matchObj.index) { - r.lastIndex += 1; - } - } - r.lastIndex = origIndex; - return matches; - } - function getVar(env, pre, key) { - var r = typeof env === "function" ? env(key) : env[key]; - if (typeof r === "undefined" && key != "") { - r = ""; - } else if (typeof r === "undefined") { - r = "$"; - } - if (typeof r === "object") { - return pre + TOKEN + JSON.stringify(r) + TOKEN; - } - return pre + r; - } - function parseInternal(string2, env, opts) { - if (!opts) { - opts = {}; - } - var BS = opts.escape || "\\"; - var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+"; - var chunker = new RegExp([ - "(" + CONTROL + ")", - // control chars - "(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+" - ].join("|"), "g"); - var matches = matchAll(string2, chunker); - if (matches.length === 0) { - return []; - } - if (!env) { - env = {}; - } - var commented = false; - return matches.map(function(match) { - var s = match[0]; - if (!s || commented) { - return void 0; - } - if (controlRE.test(s)) { - return { op: s }; - } - var quote2 = false; - var esc = false; - var out = ""; - var isGlob = false; - var i2; - function parseEnvVar() { - i2 += 1; - var varend; - var varname; - var char = s.charAt(i2); - if (char === "{") { - i2 += 1; - if (s.charAt(i2) === "}") { - throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1)); - } - varend = s.indexOf("}", i2); - if (varend < 0) { - throw new Error("Bad substitution: " + s.slice(i2)); - } - varname = s.slice(i2, varend); - i2 = varend; - } else if (/[*@#?$!_-]/.test(char)) { - varname = char; - i2 += 1; - } else { - var slicedFromI = s.slice(i2); - varend = slicedFromI.match(/[^\w\d_]/); - if (!varend) { - varname = slicedFromI; - i2 = s.length; - } else { - varname = slicedFromI.slice(0, varend.index); - i2 += varend.index - 1; - } - } - return getVar(env, "", varname); - } - for (i2 = 0; i2 < s.length; i2++) { - var c = s.charAt(i2); - isGlob = isGlob || !quote2 && (c === "*" || c === "?"); - if (esc) { - out += c; - esc = false; - } else if (quote2) { - if (c === quote2) { - quote2 = false; - } else if (quote2 == SQ) { - out += c; - } else { - if (c === BS) { - i2 += 1; - c = s.charAt(i2); - if (c === DQ || c === BS || c === DS) { - out += c; - } else { - out += BS + c; - } - } else if (c === DS) { - out += parseEnvVar(); - } else { - out += c; - } - } - } else if (c === DQ || c === SQ) { - quote2 = c; - } else if (controlRE.test(c)) { - return { op: s }; - } else if (hash.test(c)) { - commented = true; - var commentObj = { comment: string2.slice(match.index + i2 + 1) }; - if (out.length) { - return [out, commentObj]; - } - return [commentObj]; - } else if (c === BS) { - esc = true; - } else if (c === DS) { - out += parseEnvVar(); - } else { - out += c; - } - } - if (isGlob) { - return { op: "glob", pattern: out }; - } - return out; - }).reduce(function(prev, arg) { - return typeof arg === "undefined" ? prev : prev.concat(arg); - }, []); - } - module2.exports = function parse7(s, env, opts) { - var mapped = parseInternal(s, env, opts); - if (typeof env !== "function") { - return mapped; - } - return mapped.reduce(function(acc, s2) { - if (typeof s2 === "object") { - return acc.concat(s2); - } - var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g")); - if (xs.length === 1) { - return acc.concat(xs[0]); - } - return acc.concat(xs.filter(Boolean).map(function(x) { - if (startsWithToken.test(x)) { - return JSON.parse(x.split(TOKEN)[1]); - } - return x; - })); - }, []); +// node_modules/semver/internal/constants.js +var require_constants = __commonJS({ + "node_modules/semver/internal/constants.js"(exports2, module2) { + var SEMVER_SPEC_VERSION = "2.0.0"; + var MAX_LENGTH = 256; + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ + 9007199254740991; + var MAX_SAFE_COMPONENT_LENGTH = 16; + var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; + var RELEASE_TYPES = [ + "major", + "premajor", + "minor", + "preminor", + "patch", + "prepatch", + "prerelease" + ]; + module2.exports = { + MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_SAFE_INTEGER, + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 1, + FLAG_LOOSE: 2 }; } }); -// node_modules/shell-quote/index.js -var require_shell_quote = __commonJS({ - "node_modules/shell-quote/index.js"(exports2) { - "use strict"; - exports2.quote = require_quote(); - exports2.parse = require_parse2(); - } -}); - -// 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); +// node_modules/semver/internal/re.js +var require_re = __commonJS({ + "node_modules/semver/internal/re.js"(exports2, module2) { + var { + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_LENGTH + } = require_constants(); + var debug = require_debug(); + exports2 = module2.exports = {}; + var re = exports2.re = []; + var safeRe = exports2.safeRe = []; + var src = exports2.src = []; + var t = exports2.t = {}; + var R = 0; + var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; + var safeRegexReplacements = [ + ["\\s", 1], + ["\\d", MAX_LENGTH], + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] + ]; + var makeSafeRegex = (value) => { + for (const [token, max] of safeRegexReplacements) { + value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); } - __setModuleDefault(result, mod); - return result; + return value; }; - var __awaiter = 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 createToken = (name, value, isGlobal) => { + const safe = makeSafeRegex(value); + const index = R++; + debug(name, index, value); + t[name] = index; + src[index] = value; + re[index] = new RegExp(value, isGlobal ? "g" : void 0); + safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0); }; - 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 path3 = __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 __awaiter(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 __awaiter(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 __awaiter(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 = path3.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 = path3.dirname(filePath); - const upperName = path3.basename(filePath).toUpperCase(); - for (const actualName of yield exports2.readdir(directory)) { - if (upperName === actualName.toUpperCase()) { - filePath = path3.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; + createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*"); + createToken("NUMERICIDENTIFIERLOOSE", "\\d+"); + createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); + createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); + createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); + createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); + createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); + createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); + createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); + createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); + createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); + createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); + createToken("FULL", `^${src[t.FULLPLAIN]}$`); + createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); + createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); + createToken("GTLT", "((?:<|>)?=?)"); + createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); + createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); + createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); + createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); + createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); + createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); + createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`); + createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`); + createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); + createToken("COERCERTL", src[t.COERCE], true); + createToken("COERCERTLFULL", src[t.COERCEFULL], true); + createToken("LONETILDE", "(?:~>?)"); + createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); + exports2.tildeTrimReplace = "$1~"; + createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); + createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); + createToken("LONECARET", "(?:\\^)"); + createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); + exports2.caretTrimReplace = "$1^"; + createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); + createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); + createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); + createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); + createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); + exports2.comparatorTrimReplace = "$1$2$3"; + createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); + createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); + createToken("STAR", "(<|>)?=?\\s*\\*"); + createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); + createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); } }); -// 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 __awaiter = 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 path3 = __importStar(require("path")); - var ioUtil = __importStar(require_io_util()); - function cp2(source, dest, options = {}) { - return __awaiter(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 ? path3.join(dest, path3.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 (path3.relative(source, newDest) === "") { - throw new Error(`'${newDest}' and '${source}' are the same file`); - } - yield copyFile(source, newDest, force); - } - }); - } - exports2.cp = cp2; - function mv(source, dest, options = {}) { - return __awaiter(this, void 0, void 0, function* () { - if (yield ioUtil.exists(dest)) { - let destExists = true; - if (yield ioUtil.isDirectory(dest)) { - dest = path3.join(dest, path3.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(path3.dirname(dest)); - yield ioUtil.rename(source, dest); - }); - } - exports2.mv = mv; - function rmRF(inputPath) { - return __awaiter(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 __awaiter(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 __awaiter(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 __awaiter(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(path3.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(path3.sep)) { - return []; - } - const directories = []; - if (process.env.PATH) { - for (const p of process.env.PATH.split(path3.delimiter)) { - if (p) { - directories.push(p); - } - } - } - const matches = []; - for (const directory of directories) { - const filePath = yield ioUtil.tryGetExecutablePath(path3.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 __awaiter(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 __awaiter(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/tool-cache/node_modules/semver/semver.js -var require_semver = __commonJS({ - "node_modules/@actions/tool-cache/node_modules/semver/semver.js"(exports2, module2) { - exports2 = module2.exports = SemVer3; - var debug; - if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift("SEMVER"); - console.log.apply(console, args); - }; - } else { - debug = function() { - }; - } - exports2.SEMVER_SPEC_VERSION = "2.0.0"; - var MAX_LENGTH = 256; - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ - 9007199254740991; - var MAX_SAFE_COMPONENT_LENGTH = 16; - var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; - var re = exports2.re = []; - var safeRe = exports2.safeRe = []; - var src = exports2.src = []; - var t = exports2.tokens = {}; - var R = 0; - function tok(n) { - t[n] = R++; - } - var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; - var safeRegexReplacements = [ - ["\\s", 1], - ["\\d", MAX_LENGTH], - [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] - ]; - function makeSafeRe(value) { - for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) { - var token = safeRegexReplacements[i2][0]; - var max = safeRegexReplacements[i2][1]; - value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}"); - } - return value; - } - tok("NUMERICIDENTIFIER"); - src[t.NUMERICIDENTIFIER] = "0|[1-9]\\d*"; - tok("NUMERICIDENTIFIERLOOSE"); - src[t.NUMERICIDENTIFIERLOOSE] = "\\d+"; - tok("NONNUMERICIDENTIFIER"); - src[t.NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*"; - tok("MAINVERSION"); - src[t.MAINVERSION] = "(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")"; - tok("MAINVERSIONLOOSE"); - src[t.MAINVERSIONLOOSE] = "(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")"; - tok("PRERELEASEIDENTIFIER"); - src[t.PRERELEASEIDENTIFIER] = "(?:" + src[t.NUMERICIDENTIFIER] + "|" + src[t.NONNUMERICIDENTIFIER] + ")"; - tok("PRERELEASEIDENTIFIERLOOSE"); - src[t.PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[t.NUMERICIDENTIFIERLOOSE] + "|" + src[t.NONNUMERICIDENTIFIER] + ")"; - tok("PRERELEASE"); - src[t.PRERELEASE] = "(?:-(" + src[t.PRERELEASEIDENTIFIER] + "(?:\\." + src[t.PRERELEASEIDENTIFIER] + ")*))"; - tok("PRERELEASELOOSE"); - src[t.PRERELEASELOOSE] = "(?:-?(" + src[t.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[t.PRERELEASEIDENTIFIERLOOSE] + ")*))"; - tok("BUILDIDENTIFIER"); - src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + "+"; - tok("BUILD"); - src[t.BUILD] = "(?:\\+(" + src[t.BUILDIDENTIFIER] + "(?:\\." + src[t.BUILDIDENTIFIER] + ")*))"; - tok("FULL"); - tok("FULLPLAIN"); - src[t.FULLPLAIN] = "v?" + src[t.MAINVERSION] + src[t.PRERELEASE] + "?" + src[t.BUILD] + "?"; - src[t.FULL] = "^" + src[t.FULLPLAIN] + "$"; - tok("LOOSEPLAIN"); - src[t.LOOSEPLAIN] = "[v=\\s]*" + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + "?" + src[t.BUILD] + "?"; - tok("LOOSE"); - src[t.LOOSE] = "^" + src[t.LOOSEPLAIN] + "$"; - tok("GTLT"); - src[t.GTLT] = "((?:<|>)?=?)"; - tok("XRANGEIDENTIFIERLOOSE"); - src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + "|x|X|\\*"; - tok("XRANGEIDENTIFIER"); - src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + "|x|X|\\*"; - tok("XRANGEPLAIN"); - src[t.XRANGEPLAIN] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:" + src[t.PRERELEASE] + ")?" + src[t.BUILD] + "?)?)?"; - tok("XRANGEPLAINLOOSE"); - src[t.XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:" + src[t.PRERELEASELOOSE] + ")?" + src[t.BUILD] + "?)?)?"; - tok("XRANGE"); - src[t.XRANGE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAIN] + "$"; - tok("XRANGELOOSE"); - src[t.XRANGELOOSE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAINLOOSE] + "$"; - tok("COERCE"); - src[t.COERCE] = "(^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])"; - tok("COERCERTL"); - re[t.COERCERTL] = new RegExp(src[t.COERCE], "g"); - safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), "g"); - tok("LONETILDE"); - src[t.LONETILDE] = "(?:~>?)"; - tok("TILDETRIM"); - src[t.TILDETRIM] = "(\\s*)" + src[t.LONETILDE] + "\\s+"; - re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], "g"); - safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), "g"); - var tildeTrimReplace = "$1~"; - tok("TILDE"); - src[t.TILDE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAIN] + "$"; - tok("TILDELOOSE"); - src[t.TILDELOOSE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + "$"; - tok("LONECARET"); - src[t.LONECARET] = "(?:\\^)"; - tok("CARETTRIM"); - src[t.CARETTRIM] = "(\\s*)" + src[t.LONECARET] + "\\s+"; - re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], "g"); - safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), "g"); - var caretTrimReplace = "$1^"; - tok("CARET"); - src[t.CARET] = "^" + src[t.LONECARET] + src[t.XRANGEPLAIN] + "$"; - tok("CARETLOOSE"); - src[t.CARETLOOSE] = "^" + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + "$"; - tok("COMPARATORLOOSE"); - src[t.COMPARATORLOOSE] = "^" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + ")$|^$"; - tok("COMPARATOR"); - src[t.COMPARATOR] = "^" + src[t.GTLT] + "\\s*(" + src[t.FULLPLAIN] + ")$|^$"; - tok("COMPARATORTRIM"); - src[t.COMPARATORTRIM] = "(\\s*)" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + "|" + src[t.XRANGEPLAIN] + ")"; - re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], "g"); - safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), "g"); - var comparatorTrimReplace = "$1$2$3"; - tok("HYPHENRANGE"); - src[t.HYPHENRANGE] = "^\\s*(" + src[t.XRANGEPLAIN] + ")\\s+-\\s+(" + src[t.XRANGEPLAIN] + ")\\s*$"; - tok("HYPHENRANGELOOSE"); - src[t.HYPHENRANGELOOSE] = "^\\s*(" + src[t.XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[t.XRANGEPLAINLOOSE] + ")\\s*$"; - tok("STAR"); - src[t.STAR] = "(<|>)?=?\\s*\\*"; - for (i = 0; i < R; i++) { - debug(i, src[i]); - if (!re[i]) { - re[i] = new RegExp(src[i]); - safeRe[i] = new RegExp(makeSafeRe(src[i])); - } - } - var i; - exports2.parse = parse7; - function parse7(version3, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (version3 instanceof SemVer3) { - return version3; - } - if (typeof version3 !== "string") { - return null; - } - if (version3.length > MAX_LENGTH) { - return null; - } - var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]; - if (!r.test(version3)) { - return null; - } - try { - return new SemVer3(version3, options); - } catch (er) { - return null; - } - } - exports2.valid = valid; - function valid(version3, options) { - var v = parse7(version3, options); - return v ? v.version : null; - } - exports2.clean = clean; - function clean(version3, options) { - var s = parse7(version3.trim().replace(/^[=v]+/, ""), options); - return s ? s.version : null; - } - exports2.SemVer = SemVer3; - function SemVer3(version3, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (version3 instanceof SemVer3) { - if (version3.loose === options.loose) { - return version3; - } else { - version3 = version3.version; - } - } else if (typeof version3 !== "string") { - throw new TypeError("Invalid Version: " + version3); - } - if (version3.length > MAX_LENGTH) { - throw new TypeError("version is longer than " + MAX_LENGTH + " characters"); - } - if (!(this instanceof SemVer3)) { - return new SemVer3(version3, options); - } - debug("SemVer", version3, options); - this.options = options; - this.loose = !!options.loose; - var m = version3.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]); - if (!m) { - throw new TypeError("Invalid Version: " + version3); - } - this.raw = version3; - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); - } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); - } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); - } - if (!m[4]) { - this.prerelease = []; - } else { - this.prerelease = m[4].split(".").map(function(id) { - if (/^[0-9]+$/.test(id)) { - var num = +id; - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; - } - } - return id; - }); - } - this.build = m[5] ? m[5].split(".") : []; - this.format(); - } - SemVer3.prototype.format = function() { - this.version = this.major + "." + this.minor + "." + this.patch; - if (this.prerelease.length) { - this.version += "-" + this.prerelease.join("."); - } - return this.version; - }; - SemVer3.prototype.toString = function() { - return this.version; - }; - SemVer3.prototype.compare = function(other) { - debug("SemVer.compare", this.version, this.options, other); - if (!(other instanceof SemVer3)) { - other = new SemVer3(other, this.options); - } - return this.compareMain(other) || this.comparePre(other); - }; - SemVer3.prototype.compareMain = function(other) { - if (!(other instanceof SemVer3)) { - other = new SemVer3(other, this.options); - } - return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); - }; - SemVer3.prototype.comparePre = function(other) { - if (!(other instanceof SemVer3)) { - other = new SemVer3(other, this.options); - } - if (this.prerelease.length && !other.prerelease.length) { - return -1; - } else if (!this.prerelease.length && other.prerelease.length) { - return 1; - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; - } - var i2 = 0; - do { - var a = this.prerelease[i2]; - var b = other.prerelease[i2]; - debug("prerelease compare", i2, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i2); - }; - SemVer3.prototype.compareBuild = function(other) { - if (!(other instanceof SemVer3)) { - other = new SemVer3(other, this.options); - } - var i2 = 0; - do { - var a = this.build[i2]; - var b = other.build[i2]; - debug("prerelease compare", i2, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i2); - }; - SemVer3.prototype.inc = function(release, identifier) { - switch (release) { - case "premajor": - this.prerelease.length = 0; - this.patch = 0; - this.minor = 0; - this.major++; - this.inc("pre", identifier); - break; - case "preminor": - this.prerelease.length = 0; - this.patch = 0; - this.minor++; - this.inc("pre", identifier); - break; - case "prepatch": - this.prerelease.length = 0; - this.inc("patch", identifier); - this.inc("pre", identifier); - break; - case "prerelease": - if (this.prerelease.length === 0) { - this.inc("patch", identifier); - } - this.inc("pre", identifier); - break; - case "major": - if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { - this.major++; - } - this.minor = 0; - this.patch = 0; - this.prerelease = []; - break; - case "minor": - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++; - } - this.patch = 0; - this.prerelease = []; - break; - case "patch": - if (this.prerelease.length === 0) { - this.patch++; - } - this.prerelease = []; - break; - case "pre": - if (this.prerelease.length === 0) { - this.prerelease = [0]; - } else { - var i2 = this.prerelease.length; - while (--i2 >= 0) { - if (typeof this.prerelease[i2] === "number") { - this.prerelease[i2]++; - i2 = -2; - } - } - if (i2 === -1) { - this.prerelease.push(0); - } - } - if (identifier) { - if (this.prerelease[0] === identifier) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0]; - } - } else { - this.prerelease = [identifier, 0]; - } - } - break; - default: - throw new Error("invalid increment argument: " + release); - } - this.format(); - this.raw = this.version; - return this; - }; - exports2.inc = inc; - function inc(version3, release, loose, identifier) { - if (typeof loose === "string") { - identifier = loose; - loose = void 0; - } - try { - return new SemVer3(version3, loose).inc(release, identifier).version; - } catch (er) { - return null; - } - } - exports2.diff = diff; - function diff(version1, version22) { - if (eq(version1, version22)) { - return null; - } else { - var v12 = parse7(version1); - var v2 = parse7(version22); - var prefix = ""; - if (v12.prerelease.length || v2.prerelease.length) { - prefix = "pre"; - var defaultResult = "prerelease"; - } - for (var key in v12) { - if (key === "major" || key === "minor" || key === "patch") { - if (v12[key] !== v2[key]) { - return prefix + key; - } - } - } - return defaultResult; +// node_modules/semver/internal/parse-options.js +var require_parse_options = __commonJS({ + "node_modules/semver/internal/parse-options.js"(exports2, module2) { + var looseOption = Object.freeze({ loose: true }); + var emptyOpts = Object.freeze({}); + var parseOptions = (options) => { + if (!options) { + return emptyOpts; } - } - exports2.compareIdentifiers = compareIdentifiers; + if (typeof options !== "object") { + return looseOption; + } + return options; + }; + module2.exports = parseOptions; + } +}); + +// node_modules/semver/internal/identifiers.js +var require_identifiers = __commonJS({ + "node_modules/semver/internal/identifiers.js"(exports2, module2) { var numeric = /^[0-9]+$/; - function compareIdentifiers(a, b) { - var anum = numeric.test(a); - var bnum = numeric.test(b); + var compareIdentifiers = (a, b) => { + const anum = numeric.test(a); + const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; - } - exports2.rcompareIdentifiers = rcompareIdentifiers; - function rcompareIdentifiers(a, b) { - return compareIdentifiers(b, a); - } - exports2.major = major; - function major(a, loose) { - return new SemVer3(a, loose).major; - } - exports2.minor = minor; - function minor(a, loose) { - return new SemVer3(a, loose).minor; - } - exports2.patch = patch; - function patch(a, loose) { - return new SemVer3(a, loose).patch; - } - exports2.compare = compare; - function compare(a, b, loose) { - return new SemVer3(a, loose).compare(new SemVer3(b, loose)); - } - exports2.compareLoose = compareLoose; - function compareLoose(a, b) { - return compare(a, b, true); - } - exports2.compareBuild = compareBuild; - function compareBuild(a, b, loose) { - var versionA = new SemVer3(a, loose); - var versionB = new SemVer3(b, loose); - return versionA.compare(versionB) || versionA.compareBuild(versionB); - } - exports2.rcompare = rcompare; - function rcompare(a, b, loose) { - return compare(b, a, loose); - } - exports2.sort = sort; - function sort(list, loose) { - return list.sort(function(a, b) { - return exports2.compareBuild(a, b, loose); - }); - } - exports2.rsort = rsort; - function rsort(list, loose) { - return list.sort(function(a, b) { - return exports2.compareBuild(b, a, loose); - }); - } - exports2.gt = gt; - function gt(a, b, loose) { - return compare(a, b, loose) > 0; - } - exports2.lt = lt; - function lt(a, b, loose) { - return compare(a, b, loose) < 0; - } - exports2.eq = eq; - function eq(a, b, loose) { - return compare(a, b, loose) === 0; - } - exports2.neq = neq; - function neq(a, b, loose) { - return compare(a, b, loose) !== 0; - } - exports2.gte = gte; - function gte(a, b, loose) { - return compare(a, b, loose) >= 0; - } - exports2.lte = lte; - function lte(a, b, loose) { - return compare(a, b, loose) <= 0; - } - exports2.cmp = cmp; - function cmp(a, op, b, loose) { - switch (op) { - case "===": - if (typeof a === "object") - a = a.version; - if (typeof b === "object") - b = b.version; - return a === b; - case "!==": - if (typeof a === "object") - a = a.version; - if (typeof b === "object") - b = b.version; - return a !== b; - case "": - case "=": - case "==": - return eq(a, b, loose); - case "!=": - return neq(a, b, loose); - case ">": - return gt(a, b, loose); - case ">=": - return gte(a, b, loose); - case "<": - return lt(a, b, loose); - case "<=": - return lte(a, b, loose); - default: - throw new TypeError("Invalid operator: " + op); - } - } - exports2.Comparator = Comparator; - function Comparator(comp, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp; + }; + var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); + module2.exports = { + compareIdentifiers, + rcompareIdentifiers + }; + } +}); + +// node_modules/semver/classes/semver.js +var require_semver = __commonJS({ + "node_modules/semver/classes/semver.js"(exports2, module2) { + var debug = require_debug(); + var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(); + var { safeRe: re, t } = require_re(); + var parseOptions = require_parse_options(); + var { compareIdentifiers } = require_identifiers(); + var SemVer4 = class _SemVer { + constructor(version3, options) { + options = parseOptions(options); + if (version3 instanceof _SemVer) { + if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) { + return version3; + } else { + version3 = version3.version; + } + } else if (typeof version3 !== "string") { + throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version3}".`); + } + if (version3.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ); + } + debug("SemVer", version3, options); + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; + const m = version3.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); + if (!m) { + throw new TypeError(`Invalid Version: ${version3}`); + } + this.raw = version3; + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError("Invalid major version"); + } + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError("Invalid minor version"); + } + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError("Invalid patch version"); + } + if (!m[4]) { + this.prerelease = []; } else { - comp = comp.value; + this.prerelease = m[4].split(".").map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id; + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num; + } + } + return id; + }); } + this.build = m[5] ? m[5].split(".") : []; + this.format(); } - if (!(this instanceof Comparator)) { - return new Comparator(comp, options); - } - comp = comp.trim().split(/\s+/).join(" "); - debug("comparator", comp, options); - this.options = options; - this.loose = !!options.loose; - this.parse(comp); - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } - debug("comp", this); - } - var ANY = {}; - Comparator.prototype.parse = function(comp) { - var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]; - var m = comp.match(r); - if (!m) { - throw new TypeError("Invalid comparator: " + comp); - } - this.operator = m[1] !== void 0 ? m[1] : ""; - if (this.operator === "=") { - this.operator = ""; + format() { + this.version = `${this.major}.${this.minor}.${this.patch}`; + if (this.prerelease.length) { + this.version += `-${this.prerelease.join(".")}`; + } + return this.version; } - if (!m[2]) { - this.semver = ANY; - } else { - this.semver = new SemVer3(m[2], this.options.loose); + toString() { + return this.version; } - }; - Comparator.prototype.toString = function() { - return this.value; - }; - Comparator.prototype.test = function(version3) { - debug("Comparator.test", version3, this.options.loose); - if (this.semver === ANY || version3 === ANY) { - return true; + compare(other) { + debug("SemVer.compare", this.version, this.options, other); + if (!(other instanceof _SemVer)) { + if (typeof other === "string" && other === this.version) { + return 0; + } + other = new _SemVer(other, this.options); + } + if (other.version === this.version) { + return 0; + } + return this.compareMain(other) || this.comparePre(other); } - if (typeof version3 === "string") { - try { - version3 = new SemVer3(version3, this.options); - } catch (er) { - return false; + compareMain(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); } + return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); } - return cmp(version3, this.operator, this.semver, this.options); - }; - Comparator.prototype.intersects = function(comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError("a Comparator is required"); + comparePre(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); + } + if (this.prerelease.length && !other.prerelease.length) { + return -1; + } else if (!this.prerelease.length && other.prerelease.length) { + return 1; + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0; + } + let i = 0; + do { + const a = this.prerelease[i]; + const b = other.prerelease[i]; + debug("prerelease compare", i, a, b); + if (a === void 0 && b === void 0) { + return 0; + } else if (b === void 0) { + return 1; + } else if (a === void 0) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); + } + } while (++i); } - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; + compareBuild(other) { + if (!(other instanceof _SemVer)) { + other = new _SemVer(other, this.options); + } + let i = 0; + do { + const a = this.build[i]; + const b = other.build[i]; + debug("prerelease compare", i, a, b); + if (a === void 0 && b === void 0) { + return 0; + } else if (b === void 0) { + return 1; + } else if (a === void 0) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); + } + } while (++i); } - var rangeTmp; - if (this.operator === "") { - if (this.value === "") { - return true; + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc(release, identifier, identifierBase) { + switch (release) { + case "premajor": + this.prerelease.length = 0; + this.patch = 0; + this.minor = 0; + this.major++; + this.inc("pre", identifier, identifierBase); + break; + case "preminor": + this.prerelease.length = 0; + this.patch = 0; + this.minor++; + this.inc("pre", identifier, identifierBase); + break; + case "prepatch": + this.prerelease.length = 0; + this.inc("patch", identifier, identifierBase); + this.inc("pre", identifier, identifierBase); + break; + case "prerelease": + if (this.prerelease.length === 0) { + this.inc("patch", identifier, identifierBase); + } + this.inc("pre", identifier, identifierBase); + break; + case "major": + if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { + this.major++; + } + this.minor = 0; + this.patch = 0; + this.prerelease = []; + break; + case "minor": + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++; + } + this.patch = 0; + this.prerelease = []; + break; + case "patch": + if (this.prerelease.length === 0) { + this.patch++; + } + this.prerelease = []; + break; + case "pre": { + const base = Number(identifierBase) ? 1 : 0; + if (!identifier && identifierBase === false) { + throw new Error("invalid increment argument: identifier is empty"); + } + if (this.prerelease.length === 0) { + this.prerelease = [base]; + } else { + let i = this.prerelease.length; + while (--i >= 0) { + if (typeof this.prerelease[i] === "number") { + this.prerelease[i]++; + i = -2; + } + } + if (i === -1) { + if (identifier === this.prerelease.join(".") && identifierBase === false) { + throw new Error("invalid increment argument: identifier already exists"); + } + this.prerelease.push(base); + } + } + if (identifier) { + let prerelease = [identifier, base]; + if (identifierBase === false) { + prerelease = [identifier]; + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { + if (isNaN(this.prerelease[1])) { + this.prerelease = prerelease; + } + } else { + this.prerelease = prerelease; + } + } + break; + } + default: + throw new Error(`invalid increment argument: ${release}`); } - rangeTmp = new Range2(comp.value, options); - return satisfies(this.value, rangeTmp, options); - } else if (comp.operator === "") { - if (comp.value === "") { - return true; + this.raw = this.format(); + if (this.build.length) { + this.raw += `+${this.build.join(".")}`; } - rangeTmp = new Range2(this.value, options); - return satisfies(comp.semver, rangeTmp, options); + return this; } - var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">"); - var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<"); - var sameSemVer = this.semver.version === comp.semver.version; - var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<="); - var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<")); - var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">")); - return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan; }; - exports2.Range = Range2; - function Range2(range, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; + module2.exports = SemVer4; + } +}); + +// node_modules/shell-quote/quote.js +var require_quote = __commonJS({ + "node_modules/shell-quote/quote.js"(exports2, module2) { + "use strict"; + module2.exports = function quote2(xs) { + return xs.map(function(s) { + if (s && typeof s === "object") { + return s.op.replace(/(.)/g, "\\$1"); + } + if (/["\s]/.test(s) && !/'/.test(s)) { + return "'" + s.replace(/(['\\])/g, "\\$1") + "'"; + } + if (/["'\s]/.test(s)) { + return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"'; + } + return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2"); + }).join(" "); + }; + } +}); + +// node_modules/shell-quote/parse.js +var require_parse2 = __commonJS({ + "node_modules/shell-quote/parse.js"(exports2, module2) { + "use strict"; + var CONTROL = "(?:" + [ + "\\|\\|", + "\\&\\&", + ";;", + "\\|\\&", + "\\<\\(", + "\\<\\<\\<", + ">>", + ">\\&", + "<\\&", + "[&;()|<>]" + ].join("|") + ")"; + var controlRE = new RegExp("^" + CONTROL + "$"); + var META = "|&;()<> \\t"; + var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"'; + var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'"; + var hash = /^#$/; + var SQ = "'"; + var DQ = '"'; + var DS = "$"; + var TOKEN = ""; + var mult = 4294967296; + for (i = 0; i < 4; i++) { + TOKEN += (mult * Math.random()).toString(16); + } + var i; + var startsWithToken = new RegExp("^" + TOKEN); + function matchAll(s, r) { + var origIndex = r.lastIndex; + var matches = []; + var matchObj; + while (matchObj = r.exec(s)) { + matches.push(matchObj); + if (r.lastIndex === matchObj.index) { + r.lastIndex += 1; + } + } + r.lastIndex = origIndex; + return matches; + } + function getVar(env, pre, key) { + var r = typeof env === "function" ? env(key) : env[key]; + if (typeof r === "undefined" && key != "") { + r = ""; + } else if (typeof r === "undefined") { + r = "$"; } - if (range instanceof Range2) { - if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { - return range; - } else { - return new Range2(range.raw, options); - } + if (typeof r === "object") { + return pre + TOKEN + JSON.stringify(r) + TOKEN; } - if (range instanceof Comparator) { - return new Range2(range.value, options); + return pre + r; + } + function parseInternal(string2, env, opts) { + if (!opts) { + opts = {}; } - if (!(this instanceof Range2)) { - return new Range2(range, options); + var BS = opts.escape || "\\"; + var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+"; + var chunker = new RegExp([ + "(" + CONTROL + ")", + // control chars + "(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+" + ].join("|"), "g"); + var matches = matchAll(string2, chunker); + if (matches.length === 0) { + return []; } - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - this.raw = range.trim().split(/\s+/).join(" "); - this.set = this.raw.split("||").map(function(range2) { - return this.parseRange(range2.trim()); - }, this).filter(function(c) { - return c.length; - }); - if (!this.set.length) { - throw new TypeError("Invalid SemVer Range: " + this.raw); + if (!env) { + env = {}; } - this.format(); + var commented = false; + return matches.map(function(match) { + var s = match[0]; + if (!s || commented) { + return void 0; + } + if (controlRE.test(s)) { + return { op: s }; + } + var quote2 = false; + var esc = false; + var out = ""; + var isGlob = false; + var i2; + function parseEnvVar() { + i2 += 1; + var varend; + var varname; + var char = s.charAt(i2); + if (char === "{") { + i2 += 1; + if (s.charAt(i2) === "}") { + throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1)); + } + varend = s.indexOf("}", i2); + if (varend < 0) { + throw new Error("Bad substitution: " + s.slice(i2)); + } + varname = s.slice(i2, varend); + i2 = varend; + } else if (/[*@#?$!_-]/.test(char)) { + varname = char; + i2 += 1; + } else { + var slicedFromI = s.slice(i2); + varend = slicedFromI.match(/[^\w\d_]/); + if (!varend) { + varname = slicedFromI; + i2 = s.length; + } else { + varname = slicedFromI.slice(0, varend.index); + i2 += varend.index - 1; + } + } + return getVar(env, "", varname); + } + for (i2 = 0; i2 < s.length; i2++) { + var c = s.charAt(i2); + isGlob = isGlob || !quote2 && (c === "*" || c === "?"); + if (esc) { + out += c; + esc = false; + } else if (quote2) { + if (c === quote2) { + quote2 = false; + } else if (quote2 == SQ) { + out += c; + } else { + if (c === BS) { + i2 += 1; + c = s.charAt(i2); + if (c === DQ || c === BS || c === DS) { + out += c; + } else { + out += BS + c; + } + } else if (c === DS) { + out += parseEnvVar(); + } else { + out += c; + } + } + } else if (c === DQ || c === SQ) { + quote2 = c; + } else if (controlRE.test(c)) { + return { op: s }; + } else if (hash.test(c)) { + commented = true; + var commentObj = { comment: string2.slice(match.index + i2 + 1) }; + if (out.length) { + return [out, commentObj]; + } + return [commentObj]; + } else if (c === BS) { + esc = true; + } else if (c === DS) { + out += parseEnvVar(); + } else { + out += c; + } + } + if (isGlob) { + return { op: "glob", pattern: out }; + } + return out; + }).reduce(function(prev, arg) { + return typeof arg === "undefined" ? prev : prev.concat(arg); + }, []); } - Range2.prototype.format = function() { - this.range = this.set.map(function(comps) { - return comps.join(" ").trim(); - }).join("||").trim(); - return this.range; - }; - Range2.prototype.toString = function() { - return this.range; - }; - Range2.prototype.parseRange = function(range) { - var loose = this.options.loose; - var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE]; - range = range.replace(hr, hyphenReplace); - debug("hyphen replace", range); - range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace); - debug("comparator trim", range, safeRe[t.COMPARATORTRIM]); - range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace); - range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace); - range = range.split(/\s+/).join(" "); - var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]; - var set = range.split(" ").map(function(comp) { - return parseComparator(comp, this.options); - }, this).join(" ").split(/\s+/); - if (this.options.loose) { - set = set.filter(function(comp) { - return !!comp.match(compRe); - }); + module2.exports = function parse7(s, env, opts) { + var mapped = parseInternal(s, env, opts); + if (typeof env !== "function") { + return mapped; } - set = set.map(function(comp) { - return new Comparator(comp, this.options); - }, this); - return set; + return mapped.reduce(function(acc, s2) { + if (typeof s2 === "object") { + return acc.concat(s2); + } + var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g")); + if (xs.length === 1) { + return acc.concat(xs[0]); + } + return acc.concat(xs.filter(Boolean).map(function(x) { + if (startsWithToken.test(x)) { + return JSON.parse(x.split(TOKEN)[1]); + } + return x; + })); + }, []); }; - Range2.prototype.intersects = function(range, options) { - if (!(range instanceof Range2)) { - throw new TypeError("a Range is required"); + } +}); + +// node_modules/shell-quote/index.js +var require_shell_quote = __commonJS({ + "node_modules/shell-quote/index.js"(exports2) { + "use strict"; + exports2.quote = require_quote(); + exports2.parse = require_parse2(); + } +}); + +// 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); } - return this.set.some(function(thisComparators) { - return isSatisfiable(thisComparators, options) && range.set.some(function(rangeComparators) { - return isSatisfiable(rangeComparators, options) && thisComparators.every(function(thisComparator) { - return rangeComparators.every(function(rangeComparator) { - return thisComparator.intersects(rangeComparator, options); - }); - }); + __setModuleDefault(result, mod); + return result; + }; + var __awaiter = 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()); }); }; - function isSatisfiable(comparators, options) { - var result = true; - var remainingComparators = comparators.slice(); - var testComparator = remainingComparators.pop(); - while (result && remainingComparators.length) { - result = remainingComparators.every(function(otherComparator) { - return testComparator.intersects(otherComparator, options); - }); - testComparator = remainingComparators.pop(); + 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 path3 = __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 __awaiter(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 __awaiter(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'); } - return result; + if (exports2.IS_WINDOWS) { + return p.startsWith("\\") || /^[A-Z]:/i.test(p); + } + return p.startsWith("/"); } - exports2.toComparators = toComparators; - function toComparators(range, options) { - return new Range2(range, options).set.map(function(comp) { - return comp.map(function(c) { - return c.value; - }).join(" ").trim().split(" "); + exports2.isRooted = isRooted; + function tryGetExecutablePath(filePath, extensions) { + return __awaiter(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 = path3.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 = path3.dirname(filePath); + const upperName = path3.basename(filePath).toUpperCase(); + for (const actualName of yield exports2.readdir(directory)) { + if (upperName === actualName.toUpperCase()) { + filePath = path3.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 ""; }); } - function parseComparator(comp, options) { - debug("comp", comp, options); - comp = replaceCarets(comp, options); - debug("caret", comp); - comp = replaceTildes(comp, options); - debug("tildes", comp); - comp = replaceXRanges(comp, options); - debug("xrange", comp); - comp = replaceStars(comp, options); - debug("stars", comp); - return comp; + 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 isX(id) { - return !id || id.toLowerCase() === "x" || id === "*"; + 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 replaceTildes(comp, options) { - return comp.trim().split(/\s+/).map(function(comp2) { - return replaceTilde(comp2, options); - }).join(" "); + function getCmdPath() { + var _a2; + return (_a2 = process.env["COMSPEC"]) !== null && _a2 !== void 0 ? _a2 : `cmd.exe`; } - function replaceTilde(comp, options) { - var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE]; - return comp.replace(r, function(_, M, m, p, pr) { - debug("tilde", comp, _, M, m, p, pr); - var ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; - } else if (isX(p)) { - ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; - } else if (pr) { - debug("replaceTilde pr", pr); - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; + 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 __awaiter = 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 path3 = __importStar(require("path")); + var ioUtil = __importStar(require_io_util()); + function cp2(source, dest, options = {}) { + return __awaiter(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 ? path3.join(dest, path3.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 { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; + if (path3.relative(source, newDest) === "") { + throw new Error(`'${newDest}' and '${source}' are the same file`); + } + yield copyFile(source, newDest, force); } - debug("tilde return", ret); - return ret; }); } - function replaceCarets(comp, options) { - return comp.trim().split(/\s+/).map(function(comp2) { - return replaceCaret(comp2, options); - }).join(" "); - } - function replaceCaret(comp, options) { - debug("caret", comp, options); - var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET]; - return comp.replace(r, function(_, M, m, p, pr) { - debug("caret", comp, _, M, m, p, pr); - var ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; - } else if (isX(p)) { - if (M === "0") { - ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; - } else { - ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0"; + exports2.cp = cp2; + function mv(source, dest, options = {}) { + return __awaiter(this, void 0, void 0, function* () { + if (yield ioUtil.exists(dest)) { + let destExists = true; + if (yield ioUtil.isDirectory(dest)) { + dest = path3.join(dest, path3.basename(source)); + destExists = yield ioUtil.exists(dest); } - } else if (pr) { - debug("replaceCaret pr", pr); - if (M === "0") { - if (m === "0") { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1); + if (destExists) { + if (options.force == null || options.force) { + yield rmRF(dest); } else { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; + throw new Error("Destination already exists"); } - } else { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0"; } - } else { - debug("no pr"); - if (M === "0") { - if (m === "0") { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1); - } else { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; - } - } else { - ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0"; + } + yield mkdirP(path3.dirname(dest)); + yield ioUtil.rename(source, dest); + }); + } + exports2.mv = mv; + function rmRF(inputPath) { + return __awaiter(this, void 0, void 0, function* () { + if (ioUtil.IS_WINDOWS) { + if (/[*"<>|]/.test(inputPath)) { + throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); } } - debug("caret return", ret); - return ret; + 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}`); + } }); } - function replaceXRanges(comp, options) { - debug("replaceXRanges", comp, options); - return comp.split(/\s+/).map(function(comp2) { - return replaceXRange(comp2, options); - }).join(" "); + exports2.rmRF = rmRF; + function mkdirP(fsPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(fsPath, "a path argument must be provided"); + yield ioUtil.mkdir(fsPath, { recursive: true }); + }); } - function replaceXRange(comp, options) { - comp = comp.trim(); - var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE]; - return comp.replace(r, function(ret, gtlt, M, m, p, pr) { - debug("xRange", comp, ret, gtlt, M, m, p, pr); - var xM = isX(M); - var xm = xM || isX(m); - var xp = xm || isX(p); - var anyX = xp; - if (gtlt === "=" && anyX) { - gtlt = ""; + exports2.mkdirP = mkdirP; + function which(tool, check) { + return __awaiter(this, void 0, void 0, function* () { + if (!tool) { + throw new Error("parameter 'tool' is required"); } - pr = options.includePrerelease ? "-0" : ""; - if (xM) { - if (gtlt === ">" || gtlt === "<") { - ret = "<0.0.0-0"; - } else { - ret = "*"; - } - } else if (gtlt && anyX) { - if (xm) { - m = 0; - } - p = 0; - if (gtlt === ">") { - gtlt = ">="; - if (xm) { - M = +M + 1; - m = 0; - p = 0; - } else { - m = +m + 1; - p = 0; - } - } else if (gtlt === "<=") { - gtlt = "<"; - if (xm) { - M = +M + 1; + 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 { - m = +m + 1; + 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.`); } } - ret = gtlt + M + "." + m + "." + p + pr; - } else if (xm) { - ret = ">=" + M + ".0.0" + pr + " <" + (+M + 1) + ".0.0" + pr; - } else if (xp) { - ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr; + return result; } - debug("xRange return", ret); - return ret; + const matches = yield findInPath(tool); + if (matches && matches.length > 0) { + return matches[0]; + } + return ""; }); } - function replaceStars(comp, options) { - debug("replaceStars", comp, options); - return comp.trim().replace(safeRe[t.STAR], ""); - } - function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = ""; - } else if (isX(fm)) { - from = ">=" + fM + ".0.0"; - } else if (isX(fp)) { - from = ">=" + fM + "." + fm + ".0"; - } else { - from = ">=" + from; - } - if (isX(tM)) { - to = ""; - } else if (isX(tm)) { - to = "<" + (+tM + 1) + ".0.0"; - } else if (isX(tp)) { - to = "<" + tM + "." + (+tm + 1) + ".0"; - } else if (tpr) { - to = "<=" + tM + "." + tm + "." + tp + "-" + tpr; - } else { - to = "<=" + to; - } - return (from + " " + to).trim(); - } - Range2.prototype.test = function(version3) { - if (!version3) { - return false; - } - if (typeof version3 === "string") { - try { - version3 = new SemVer3(version3, this.options); - } catch (er) { - return false; + exports2.which = which; + function findInPath(tool) { + return __awaiter(this, void 0, void 0, function* () { + if (!tool) { + throw new Error("parameter 'tool' is required"); } - } - for (var i2 = 0; i2 < this.set.length; i2++) { - if (testSet(this.set[i2], version3, this.options)) { - return true; + const extensions = []; + if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) { + for (const extension of process.env["PATHEXT"].split(path3.delimiter)) { + if (extension) { + extensions.push(extension); + } + } } - } - return false; - }; - function testSet(set, version3, options) { - for (var i2 = 0; i2 < set.length; i2++) { - if (!set[i2].test(version3)) { - return false; + if (ioUtil.isRooted(tool)) { + const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); + if (filePath) { + return [filePath]; + } + return []; } - } - if (version3.prerelease.length && !options.includePrerelease) { - for (i2 = 0; i2 < set.length; i2++) { - debug(set[i2].semver); - if (set[i2].semver === ANY) { - continue; + if (tool.includes(path3.sep)) { + return []; + } + const directories = []; + if (process.env.PATH) { + for (const p of process.env.PATH.split(path3.delimiter)) { + if (p) { + directories.push(p); + } + } + } + const matches = []; + for (const directory of directories) { + const filePath = yield ioUtil.tryGetExecutablePath(path3.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 __awaiter(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); } - if (set[i2].semver.prerelease.length > 0) { - var allowed = set[i2].semver; - if (allowed.major === version3.major && allowed.minor === version3.minor && allowed.patch === version3.patch) { - return true; + } + yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); + }); + } + function copyFile(srcFile, destFile, force) { + return __awaiter(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); } - return false; - } - return true; + }); } - exports2.satisfies = satisfies; - function satisfies(version3, range, options) { - try { - range = new Range2(range, options); - } catch (er) { - return false; - } - return range.test(version3); + } +}); + +// node_modules/@actions/tool-cache/node_modules/semver/semver.js +var require_semver2 = __commonJS({ + "node_modules/@actions/tool-cache/node_modules/semver/semver.js"(exports2, module2) { + exports2 = module2.exports = SemVer4; + var debug; + if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments, 0); + args.unshift("SEMVER"); + console.log.apply(console, args); + }; + } else { + debug = function() { + }; } - exports2.maxSatisfying = maxSatisfying; - function maxSatisfying(versions, range, options) { - var max = null; - var maxSV = null; - try { - var rangeObj = new Range2(range, options); - } catch (er) { - return null; + exports2.SEMVER_SPEC_VERSION = "2.0.0"; + var MAX_LENGTH = 256; + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ + 9007199254740991; + var MAX_SAFE_COMPONENT_LENGTH = 16; + var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; + var re = exports2.re = []; + var safeRe = exports2.safeRe = []; + var src = exports2.src = []; + var t = exports2.tokens = {}; + var R = 0; + function tok(n) { + t[n] = R++; + } + var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; + var safeRegexReplacements = [ + ["\\s", 1], + ["\\d", MAX_LENGTH], + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] + ]; + function makeSafeRe(value) { + for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) { + var token = safeRegexReplacements[i2][0]; + var max = safeRegexReplacements[i2][1]; + value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}"); } - versions.forEach(function(v) { - if (rangeObj.test(v)) { - if (!max || maxSV.compare(v) === -1) { - max = v; - maxSV = new SemVer3(max, options); - } - } - }); - return max; + return value; } - exports2.minSatisfying = minSatisfying; - function minSatisfying(versions, range, options) { - var min = null; - var minSV = null; - try { - var rangeObj = new Range2(range, options); - } catch (er) { - return null; + tok("NUMERICIDENTIFIER"); + src[t.NUMERICIDENTIFIER] = "0|[1-9]\\d*"; + tok("NUMERICIDENTIFIERLOOSE"); + src[t.NUMERICIDENTIFIERLOOSE] = "\\d+"; + tok("NONNUMERICIDENTIFIER"); + src[t.NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*"; + tok("MAINVERSION"); + src[t.MAINVERSION] = "(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")"; + tok("MAINVERSIONLOOSE"); + src[t.MAINVERSIONLOOSE] = "(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")"; + tok("PRERELEASEIDENTIFIER"); + src[t.PRERELEASEIDENTIFIER] = "(?:" + src[t.NUMERICIDENTIFIER] + "|" + src[t.NONNUMERICIDENTIFIER] + ")"; + tok("PRERELEASEIDENTIFIERLOOSE"); + src[t.PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[t.NUMERICIDENTIFIERLOOSE] + "|" + src[t.NONNUMERICIDENTIFIER] + ")"; + tok("PRERELEASE"); + src[t.PRERELEASE] = "(?:-(" + src[t.PRERELEASEIDENTIFIER] + "(?:\\." + src[t.PRERELEASEIDENTIFIER] + ")*))"; + tok("PRERELEASELOOSE"); + src[t.PRERELEASELOOSE] = "(?:-?(" + src[t.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[t.PRERELEASEIDENTIFIERLOOSE] + ")*))"; + tok("BUILDIDENTIFIER"); + src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + "+"; + tok("BUILD"); + src[t.BUILD] = "(?:\\+(" + src[t.BUILDIDENTIFIER] + "(?:\\." + src[t.BUILDIDENTIFIER] + ")*))"; + tok("FULL"); + tok("FULLPLAIN"); + src[t.FULLPLAIN] = "v?" + src[t.MAINVERSION] + src[t.PRERELEASE] + "?" + src[t.BUILD] + "?"; + src[t.FULL] = "^" + src[t.FULLPLAIN] + "$"; + tok("LOOSEPLAIN"); + src[t.LOOSEPLAIN] = "[v=\\s]*" + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + "?" + src[t.BUILD] + "?"; + tok("LOOSE"); + src[t.LOOSE] = "^" + src[t.LOOSEPLAIN] + "$"; + tok("GTLT"); + src[t.GTLT] = "((?:<|>)?=?)"; + tok("XRANGEIDENTIFIERLOOSE"); + src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + "|x|X|\\*"; + tok("XRANGEIDENTIFIER"); + src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + "|x|X|\\*"; + tok("XRANGEPLAIN"); + src[t.XRANGEPLAIN] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:" + src[t.PRERELEASE] + ")?" + src[t.BUILD] + "?)?)?"; + tok("XRANGEPLAINLOOSE"); + src[t.XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:" + src[t.PRERELEASELOOSE] + ")?" + src[t.BUILD] + "?)?)?"; + tok("XRANGE"); + src[t.XRANGE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAIN] + "$"; + tok("XRANGELOOSE"); + src[t.XRANGELOOSE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAINLOOSE] + "$"; + tok("COERCE"); + src[t.COERCE] = "(^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])"; + tok("COERCERTL"); + re[t.COERCERTL] = new RegExp(src[t.COERCE], "g"); + safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), "g"); + tok("LONETILDE"); + src[t.LONETILDE] = "(?:~>?)"; + tok("TILDETRIM"); + src[t.TILDETRIM] = "(\\s*)" + src[t.LONETILDE] + "\\s+"; + re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], "g"); + safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), "g"); + var tildeTrimReplace = "$1~"; + tok("TILDE"); + src[t.TILDE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAIN] + "$"; + tok("TILDELOOSE"); + src[t.TILDELOOSE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + "$"; + tok("LONECARET"); + src[t.LONECARET] = "(?:\\^)"; + tok("CARETTRIM"); + src[t.CARETTRIM] = "(\\s*)" + src[t.LONECARET] + "\\s+"; + re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], "g"); + safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), "g"); + var caretTrimReplace = "$1^"; + tok("CARET"); + src[t.CARET] = "^" + src[t.LONECARET] + src[t.XRANGEPLAIN] + "$"; + tok("CARETLOOSE"); + src[t.CARETLOOSE] = "^" + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + "$"; + tok("COMPARATORLOOSE"); + src[t.COMPARATORLOOSE] = "^" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + ")$|^$"; + tok("COMPARATOR"); + src[t.COMPARATOR] = "^" + src[t.GTLT] + "\\s*(" + src[t.FULLPLAIN] + ")$|^$"; + tok("COMPARATORTRIM"); + src[t.COMPARATORTRIM] = "(\\s*)" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + "|" + src[t.XRANGEPLAIN] + ")"; + re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], "g"); + safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), "g"); + var comparatorTrimReplace = "$1$2$3"; + tok("HYPHENRANGE"); + src[t.HYPHENRANGE] = "^\\s*(" + src[t.XRANGEPLAIN] + ")\\s+-\\s+(" + src[t.XRANGEPLAIN] + ")\\s*$"; + tok("HYPHENRANGELOOSE"); + src[t.HYPHENRANGELOOSE] = "^\\s*(" + src[t.XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[t.XRANGEPLAINLOOSE] + ")\\s*$"; + tok("STAR"); + src[t.STAR] = "(<|>)?=?\\s*\\*"; + for (i = 0; i < R; i++) { + debug(i, src[i]); + if (!re[i]) { + re[i] = new RegExp(src[i]); + safeRe[i] = new RegExp(makeSafeRe(src[i])); } - versions.forEach(function(v) { - if (rangeObj.test(v)) { - if (!min || minSV.compare(v) === 1) { - min = v; - minSV = new SemVer3(min, options); - } - } - }); - return min; } - exports2.minVersion = minVersion; - function minVersion(range, loose) { - range = new Range2(range, loose); - var minver = new SemVer3("0.0.0"); - if (range.test(minver)) { - return minver; + var i; + exports2.parse = parse7; + function parse7(version3, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; } - minver = new SemVer3("0.0.0-0"); - if (range.test(minver)) { - return minver; + if (version3 instanceof SemVer4) { + return version3; } - minver = null; - for (var i2 = 0; i2 < range.set.length; ++i2) { - var comparators = range.set[i2]; - comparators.forEach(function(comparator) { - var compver = new SemVer3(comparator.semver.version); - switch (comparator.operator) { - case ">": - if (compver.prerelease.length === 0) { - compver.patch++; - } else { - compver.prerelease.push(0); - } - compver.raw = compver.format(); - case "": - case ">=": - if (!minver || gt(minver, compver)) { - minver = compver; - } - break; - case "<": - case "<=": - break; - default: - throw new Error("Unexpected operation: " + comparator.operator); - } - }); + if (typeof version3 !== "string") { + return null; } - if (minver && range.test(minver)) { - return minver; + if (version3.length > MAX_LENGTH) { + return null; + } + var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]; + if (!r.test(version3)) { + return null; } - return null; - } - exports2.validRange = validRange; - function validRange(range, options) { try { - return new Range2(range, options).range || "*"; + return new SemVer4(version3, options); } catch (er) { return null; } } - exports2.ltr = ltr; - function ltr(version3, range, options) { - return outside(version3, range, "<", options); + exports2.valid = valid; + function valid(version3, options) { + var v = parse7(version3, options); + return v ? v.version : null; } - exports2.gtr = gtr; - function gtr(version3, range, options) { - return outside(version3, range, ">", options); + exports2.clean = clean; + function clean(version3, options) { + var s = parse7(version3.trim().replace(/^[=v]+/, ""), options); + return s ? s.version : null; } - exports2.outside = outside; - function outside(version3, range, hilo, options) { - version3 = new SemVer3(version3, options); - range = new Range2(range, options); - var gtfn, ltefn, ltfn, comp, ecomp; - switch (hilo) { - case ">": - gtfn = gt; - ltefn = lte; - ltfn = lt; - comp = ">"; - ecomp = ">="; - break; - case "<": - gtfn = lt; - ltefn = gte; - ltfn = gt; - comp = "<"; - ecomp = "<="; - break; - default: - throw new TypeError('Must provide a hilo val of "<" or ">"'); - } - if (satisfies(version3, range, options)) { - return false; + exports2.SemVer = SemVer4; + function SemVer4(version3, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; } - for (var i2 = 0; i2 < range.set.length; ++i2) { - var comparators = range.set[i2]; - var high = null; - var low = null; - comparators.forEach(function(comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator(">=0.0.0"); - } - high = high || comparator; - low = low || comparator; - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator; - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator; - } - }); - if (high.operator === comp || high.operator === ecomp) { - return false; - } - if ((!low.operator || low.operator === comp) && ltefn(version3, low.semver)) { - return false; - } else if (low.operator === ecomp && ltfn(version3, low.semver)) { - return false; + if (version3 instanceof SemVer4) { + if (version3.loose === options.loose) { + return version3; + } else { + version3 = version3.version; } + } else if (typeof version3 !== "string") { + throw new TypeError("Invalid Version: " + version3); } - return true; - } - exports2.prerelease = prerelease; - function prerelease(version3, options) { - var parsed = parse7(version3, options); - return parsed && parsed.prerelease.length ? parsed.prerelease : null; - } - exports2.intersects = intersects; - function intersects(r1, r2, options) { - r1 = new Range2(r1, options); - r2 = new Range2(r2, options); - return r1.intersects(r2); - } - exports2.coerce = coerce; - function coerce(version3, options) { - if (version3 instanceof SemVer3) { - return version3; - } - if (typeof version3 === "number") { - version3 = String(version3); + if (version3.length > MAX_LENGTH) { + throw new TypeError("version is longer than " + MAX_LENGTH + " characters"); } - if (typeof version3 !== "string") { - return null; + if (!(this instanceof SemVer4)) { + return new SemVer4(version3, options); } - options = options || {}; - var match = null; - if (!options.rtl) { - match = version3.match(safeRe[t.COERCE]); - } else { - var next; - while ((next = safeRe[t.COERCERTL].exec(version3)) && (!match || match.index + match[0].length !== version3.length)) { - if (!match || next.index + next[0].length !== match.index + match[0].length) { - match = next; - } - safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length; - } - safeRe[t.COERCERTL].lastIndex = -1; + debug("SemVer", version3, options); + this.options = options; + this.loose = !!options.loose; + var m = version3.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]); + if (!m) { + throw new TypeError("Invalid Version: " + version3); } - if (match === null) { - return null; + this.raw = version3; + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError("Invalid major version"); } - return parse7(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options); - } - } -}); - -// node_modules/@actions/tool-cache/lib/manifest.js -var require_manifest = __commonJS({ - "node_modules/@actions/tool-cache/lib/manifest.js"(exports2, module2) { - "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); + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError("Invalid minor version"); } - __setModuleDefault(result, mod); - return result; - }; - var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError("Invalid patch version"); } - 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._readLinuxVersionFile = exports2._getOsVersion = exports2._findMatch = void 0; - var semver = __importStar(require_semver()); - var core_1 = require_core(); - var os = require("os"); - var cp2 = require("child_process"); - var fs2 = require("fs"); - function _findMatch(versionSpec, stable, candidates, archFilter) { - return __awaiter(this, void 0, void 0, function* () { - const platFilter = os.platform(); - let result; - let match; - let file; - for (const candidate of candidates) { - const version3 = candidate.version; - core_1.debug(`check ${version3} satisfies ${versionSpec}`); - if (semver.satisfies(version3, versionSpec) && (!stable || candidate.stable === stable)) { - file = candidate.files.find((item) => { - core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`); - let chk = item.arch === archFilter && item.platform === platFilter; - if (chk && item.platform_version) { - const osVersion = module2.exports._getOsVersion(); - if (osVersion === item.platform_version) { - chk = true; - } else { - chk = semver.satisfies(osVersion, item.platform_version); - } - } - return chk; - }); - if (file) { - core_1.debug(`matched ${candidate.version}`); - match = candidate; - break; - } - } - } - if (match && file) { - result = Object.assign({}, match); - result.files = [file]; - } - return result; - }); - } - exports2._findMatch = _findMatch; - function _getOsVersion() { - const plat = os.platform(); - let version3 = ""; - if (plat === "darwin") { - version3 = cp2.execSync("sw_vers -productVersion").toString(); - } else if (plat === "linux") { - const lsbContents = module2.exports._readLinuxVersionFile(); - if (lsbContents) { - const lines = lsbContents.split("\n"); - for (const line of lines) { - const parts = line.split("="); - if (parts.length === 2 && (parts[0].trim() === "VERSION_ID" || parts[0].trim() === "DISTRIB_RELEASE")) { - version3 = parts[1].trim().replace(/^"/, "").replace(/"$/, ""); - break; + if (!m[4]) { + this.prerelease = []; + } else { + this.prerelease = m[4].split(".").map(function(id) { + if (/^[0-9]+$/.test(id)) { + var num = +id; + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num; } } - } + return id; + }); } - return version3; + this.build = m[5] ? m[5].split(".") : []; + this.format(); } - exports2._getOsVersion = _getOsVersion; - function _readLinuxVersionFile() { - const lsbReleaseFile = "/etc/lsb-release"; - const osReleaseFile = "/etc/os-release"; - let contents = ""; - if (fs2.existsSync(lsbReleaseFile)) { - contents = fs2.readFileSync(lsbReleaseFile).toString(); - } else if (fs2.existsSync(osReleaseFile)) { - contents = fs2.readFileSync(osReleaseFile).toString(); + SemVer4.prototype.format = function() { + this.version = this.major + "." + this.minor + "." + this.patch; + if (this.prerelease.length) { + this.version += "-" + this.prerelease.join("."); } - return contents; - } - exports2._readLinuxVersionFile = _readLinuxVersionFile; - } -}); - -// node_modules/@actions/tool-cache/node_modules/uuid/lib/rng.js -var require_rng = __commonJS({ - "node_modules/@actions/tool-cache/node_modules/uuid/lib/rng.js"(exports2, module2) { - var crypto4 = require("crypto"); - module2.exports = function nodeRNG() { - return crypto4.randomBytes(16); + return this.version; }; - } -}); - -// node_modules/@actions/tool-cache/node_modules/uuid/lib/bytesToUuid.js -var require_bytesToUuid = __commonJS({ - "node_modules/@actions/tool-cache/node_modules/uuid/lib/bytesToUuid.js"(exports2, module2) { - var byteToHex2 = []; - for (i = 0; i < 256; ++i) { - byteToHex2[i] = (i + 256).toString(16).substr(1); - } - var i; - function bytesToUuid(buf, offset) { - var i2 = offset || 0; - var bth = byteToHex2; - return [ - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]], - "-", - bth[buf[i2++]], - bth[buf[i2++]], - "-", - bth[buf[i2++]], - bth[buf[i2++]], - "-", - bth[buf[i2++]], - bth[buf[i2++]], - "-", - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]], - bth[buf[i2++]] - ].join(""); - } - module2.exports = bytesToUuid; - } -}); - -// node_modules/@actions/tool-cache/node_modules/uuid/v4.js -var require_v4 = __commonJS({ - "node_modules/@actions/tool-cache/node_modules/uuid/v4.js"(exports2, module2) { - var rng2 = require_rng(); - var bytesToUuid = require_bytesToUuid(); - function v42(options, buf, offset) { - var i = buf && offset || 0; - if (typeof options == "string") { - buf = options === "binary" ? new Array(16) : null; - options = null; + SemVer4.prototype.toString = function() { + return this.version; + }; + SemVer4.prototype.compare = function(other) { + debug("SemVer.compare", this.version, this.options, other); + if (!(other instanceof SemVer4)) { + other = new SemVer4(other, this.options); } - options = options || {}; - var rnds = options.random || (options.rng || rng2)(); - rnds[6] = rnds[6] & 15 | 64; - rnds[8] = rnds[8] & 63 | 128; - if (buf) { - for (var ii = 0; ii < 16; ++ii) { - buf[i + ii] = rnds[ii]; + return this.compareMain(other) || this.comparePre(other); + }; + SemVer4.prototype.compareMain = function(other) { + if (!(other instanceof SemVer4)) { + other = new SemVer4(other, this.options); + } + return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); + }; + SemVer4.prototype.comparePre = function(other) { + if (!(other instanceof SemVer4)) { + other = new SemVer4(other, this.options); + } + if (this.prerelease.length && !other.prerelease.length) { + return -1; + } else if (!this.prerelease.length && other.prerelease.length) { + return 1; + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0; + } + var i2 = 0; + do { + var a = this.prerelease[i2]; + var b = other.prerelease[i2]; + debug("prerelease compare", i2, a, b); + if (a === void 0 && b === void 0) { + return 0; + } else if (b === void 0) { + return 1; + } else if (a === void 0) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); } + } while (++i2); + }; + SemVer4.prototype.compareBuild = function(other) { + if (!(other instanceof SemVer4)) { + other = new SemVer4(other, this.options); } - return buf || bytesToUuid(rnds); - } - module2.exports = v42; - } -}); - -// 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); + var i2 = 0; + do { + var a = this.build[i2]; + var b = other.build[i2]; + debug("prerelease compare", i2, a, b); + if (a === void 0 && b === void 0) { + return 0; + } else if (b === void 0) { + return 1; + } else if (a === void 0) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); + } + } while (++i2); + }; + SemVer4.prototype.inc = function(release, identifier) { + switch (release) { + case "premajor": + this.prerelease.length = 0; + this.patch = 0; + this.minor = 0; + this.major++; + this.inc("pre", identifier); + break; + case "preminor": + this.prerelease.length = 0; + this.patch = 0; + this.minor++; + this.inc("pre", identifier); + break; + case "prepatch": + this.prerelease.length = 0; + this.inc("patch", identifier); + this.inc("pre", identifier); + break; + case "prerelease": + if (this.prerelease.length === 0) { + this.inc("patch", identifier); + } + this.inc("pre", identifier); + break; + case "major": + if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { + this.major++; + } + this.minor = 0; + this.patch = 0; + this.prerelease = []; + break; + case "minor": + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++; + } + this.patch = 0; + this.prerelease = []; + break; + case "patch": + if (this.prerelease.length === 0) { + this.patch++; + } + this.prerelease = []; + break; + case "pre": + if (this.prerelease.length === 0) { + this.prerelease = [0]; + } else { + var i2 = this.prerelease.length; + while (--i2 >= 0) { + if (typeof this.prerelease[i2] === "number") { + this.prerelease[i2]++; + i2 = -2; + } + } + if (i2 === -1) { + this.prerelease.push(0); + } + } + if (identifier) { + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0]; + } + } else { + this.prerelease = [identifier, 0]; + } + } + break; + default: + throw new Error("invalid increment argument: " + release); } - __setModuleDefault(result, mod); - return result; + this.format(); + this.raw = this.version; + return this; }; - var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); + exports2.inc = inc; + function inc(version3, release, loose, identifier) { + if (typeof loose === "string") { + identifier = loose; + loose = void 0; } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } + try { + return new SemVer4(version3, loose).inc(release, identifier).version; + } catch (er) { + return null; + } + } + exports2.diff = diff; + function diff(version1, version22) { + if (eq(version1, version22)) { + return null; + } else { + var v12 = parse7(version1); + var v2 = parse7(version22); + var prefix = ""; + if (v12.prerelease.length || v2.prerelease.length) { + prefix = "pre"; + var defaultResult = "prerelease"; } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); + for (var key in v12) { + if (key === "major" || key === "minor" || key === "patch") { + if (v12[key] !== v2[key]) { + return prefix + key; + } } } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); + return defaultResult; + } + } + exports2.compareIdentifiers = compareIdentifiers; + var numeric = /^[0-9]+$/; + function compareIdentifiers(a, b) { + var anum = numeric.test(a); + var bnum = numeric.test(b); + if (anum && bnum) { + a = +a; + b = +b; + } + return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; + } + exports2.rcompareIdentifiers = rcompareIdentifiers; + function rcompareIdentifiers(a, b) { + return compareIdentifiers(b, a); + } + exports2.major = major; + function major(a, loose) { + return new SemVer4(a, loose).major; + } + exports2.minor = minor; + function minor(a, loose) { + return new SemVer4(a, loose).minor; + } + exports2.patch = patch; + function patch(a, loose) { + return new SemVer4(a, loose).patch; + } + exports2.compare = compare; + function compare(a, b, loose) { + return new SemVer4(a, loose).compare(new SemVer4(b, loose)); + } + exports2.compareLoose = compareLoose; + function compareLoose(a, b) { + return compare(a, b, true); + } + exports2.compareBuild = compareBuild; + function compareBuild(a, b, loose) { + var versionA = new SemVer4(a, loose); + var versionB = new SemVer4(b, loose); + return versionA.compare(versionB) || versionA.compareBuild(versionB); + } + exports2.rcompare = rcompare; + function rcompare(a, b, loose) { + return compare(b, a, loose); + } + exports2.sort = sort; + function sort(list, loose) { + return list.sort(function(a, b) { + return exports2.compareBuild(a, b, loose); }); - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.argStringToArray = exports2.ToolRunner = void 0; - var os = __importStar(require("os")); - var events = __importStar(require("events")); - var child = __importStar(require("child_process")); - var path3 = __importStar(require("path")); - var io = __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, args, options) { - super(); - if (!toolPath) { - throw new Error("Parameter 'toolPath' cannot be null or empty."); - } - this.toolPath = toolPath; - this.args = args || []; - this.options = options || {}; + } + exports2.rsort = rsort; + function rsort(list, loose) { + return list.sort(function(a, b) { + return exports2.compareBuild(b, a, loose); + }); + } + exports2.gt = gt; + function gt(a, b, loose) { + return compare(a, b, loose) > 0; + } + exports2.lt = lt; + function lt(a, b, loose) { + return compare(a, b, loose) < 0; + } + exports2.eq = eq; + function eq(a, b, loose) { + return compare(a, b, loose) === 0; + } + exports2.neq = neq; + function neq(a, b, loose) { + return compare(a, b, loose) !== 0; + } + exports2.gte = gte; + function gte(a, b, loose) { + return compare(a, b, loose) >= 0; + } + exports2.lte = lte; + function lte(a, b, loose) { + return compare(a, b, loose) <= 0; + } + exports2.cmp = cmp; + function cmp(a, op, b, loose) { + switch (op) { + case "===": + if (typeof a === "object") + a = a.version; + if (typeof b === "object") + b = b.version; + return a === b; + case "!==": + if (typeof a === "object") + a = a.version; + if (typeof b === "object") + b = b.version; + return a !== b; + case "": + case "=": + case "==": + return eq(a, b, loose); + case "!=": + return neq(a, b, loose); + case ">": + return gt(a, b, loose); + case ">=": + return gte(a, b, loose); + case "<": + return lt(a, b, loose); + case "<=": + return lte(a, b, loose); + default: + throw new TypeError("Invalid operator: " + op); } - _debug(message) { - if (this.options.listeners && this.options.listeners.debug) { - this.options.listeners.debug(message); - } + } + exports2.Comparator = Comparator; + function Comparator(comp, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; } - _getCommandString(options, noPrefix) { - const toolPath = this._getSpawnFileName(); - const args = this._getSpawnArgs(options); - let cmd = noPrefix ? "" : "[command]"; - if (IS_WINDOWS) { - if (this._isCmdFile()) { - cmd += toolPath; - for (const a of args) { - cmd += ` ${a}`; - } - } else if (options.windowsVerbatimArguments) { - cmd += `"${toolPath}"`; - for (const a of args) { - cmd += ` ${a}`; - } - } else { - cmd += this._windowsQuoteCmdArg(toolPath); - for (const a of args) { - cmd += ` ${this._windowsQuoteCmdArg(a)}`; - } - } + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp; } else { - cmd += toolPath; - for (const a of args) { - cmd += ` ${a}`; - } + comp = comp.value; } - return cmd; } - _processLineBuffer(data, strBuffer, onLine) { + if (!(this instanceof Comparator)) { + return new Comparator(comp, options); + } + comp = comp.trim().split(/\s+/).join(" "); + debug("comparator", comp, options); + this.options = options; + this.loose = !!options.loose; + this.parse(comp); + if (this.semver === ANY) { + this.value = ""; + } else { + this.value = this.operator + this.semver.version; + } + debug("comp", this); + } + var ANY = {}; + Comparator.prototype.parse = function(comp) { + var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]; + var m = comp.match(r); + if (!m) { + throw new TypeError("Invalid comparator: " + comp); + } + this.operator = m[1] !== void 0 ? m[1] : ""; + if (this.operator === "=") { + this.operator = ""; + } + if (!m[2]) { + this.semver = ANY; + } else { + this.semver = new SemVer4(m[2], this.options.loose); + } + }; + Comparator.prototype.toString = function() { + return this.value; + }; + Comparator.prototype.test = function(version3) { + debug("Comparator.test", version3, this.options.loose); + if (this.semver === ANY || version3 === ANY) { + return true; + } + if (typeof version3 === "string") { try { - let s = strBuffer + data.toString(); - let n = s.indexOf(os.EOL); - while (n > -1) { - const line = s.substring(0, n); - onLine(line); - s = s.substring(n + os.EOL.length); - n = s.indexOf(os.EOL); - } - return s; - } catch (err) { - this._debug(`error processing line. Failed with error ${err}`); - return ""; + version3 = new SemVer4(version3, this.options); + } catch (er) { + return false; } } - _getSpawnFileName() { - if (IS_WINDOWS) { - if (this._isCmdFile()) { - return process.env["COMSPEC"] || "cmd.exe"; - } + return cmp(version3, this.operator, this.semver, this.options); + }; + Comparator.prototype.intersects = function(comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError("a Comparator is required"); + } + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + var rangeTmp; + if (this.operator === "") { + if (this.value === "") { + return true; } - return this.toolPath; + rangeTmp = new Range2(comp.value, options); + return satisfies(this.value, rangeTmp, options); + } else if (comp.operator === "") { + if (comp.value === "") { + return true; + } + rangeTmp = new Range2(this.value, options); + return satisfies(comp.semver, rangeTmp, options); } - _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]; - } + var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">"); + var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<"); + var sameSemVer = this.semver.version === comp.semver.version; + var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<="); + var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<")); + var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">")); + return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan; + }; + exports2.Range = Range2; + function Range2(range, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + if (range instanceof Range2) { + if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { + return range; + } else { + return new Range2(range.raw, options); } - return this.args; } - _endsWith(str, end) { - return str.endsWith(end); + if (range instanceof Comparator) { + return new Range2(range.value, options); } - _isCmdFile() { - const upperToolPath = this.toolPath.toUpperCase(); - return this._endsWith(upperToolPath, ".CMD") || this._endsWith(upperToolPath, ".BAT"); + if (!(this instanceof Range2)) { + return new Range2(range, options); } - _windowsQuoteCmdArg(arg) { - if (!this._isCmdFile()) { - return this._uvQuoteCmdArg(arg); - } - if (!arg) { - return '""'; + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; + this.raw = range.trim().split(/\s+/).join(" "); + this.set = this.raw.split("||").map(function(range2) { + return this.parseRange(range2.trim()); + }, this).filter(function(c) { + return c.length; + }); + if (!this.set.length) { + throw new TypeError("Invalid SemVer Range: " + this.raw); + } + this.format(); + } + Range2.prototype.format = function() { + this.range = this.set.map(function(comps) { + return comps.join(" ").trim(); + }).join("||").trim(); + return this.range; + }; + Range2.prototype.toString = function() { + return this.range; + }; + Range2.prototype.parseRange = function(range) { + var loose = this.options.loose; + var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE]; + range = range.replace(hr, hyphenReplace); + debug("hyphen replace", range); + range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace); + debug("comparator trim", range, safeRe[t.COMPARATORTRIM]); + range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace); + range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace); + range = range.split(/\s+/).join(" "); + var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]; + var set = range.split(" ").map(function(comp) { + return parseComparator(comp, this.options); + }, this).join(" ").split(/\s+/); + if (this.options.loose) { + set = set.filter(function(comp) { + return !!comp.match(compRe); + }); + } + set = set.map(function(comp) { + return new Comparator(comp, this.options); + }, this); + return set; + }; + Range2.prototype.intersects = function(range, options) { + if (!(range instanceof Range2)) { + throw new TypeError("a Range is required"); + } + return this.set.some(function(thisComparators) { + return isSatisfiable(thisComparators, options) && range.set.some(function(rangeComparators) { + return isSatisfiable(rangeComparators, options) && thisComparators.every(function(thisComparator) { + return rangeComparators.every(function(rangeComparator) { + return thisComparator.intersects(rangeComparator, options); + }); + }); + }); + }); + }; + function isSatisfiable(comparators, options) { + var result = true; + var remainingComparators = comparators.slice(); + var testComparator = remainingComparators.pop(); + while (result && remainingComparators.length) { + result = remainingComparators.every(function(otherComparator) { + return testComparator.intersects(otherComparator, options); + }); + testComparator = remainingComparators.pop(); + } + return result; + } + exports2.toComparators = toComparators; + function toComparators(range, options) { + return new Range2(range, options).set.map(function(comp) { + return comp.map(function(c) { + return c.value; + }).join(" ").trim().split(" "); + }); + } + function parseComparator(comp, options) { + debug("comp", comp, options); + comp = replaceCarets(comp, options); + debug("caret", comp); + comp = replaceTildes(comp, options); + debug("tildes", comp); + comp = replaceXRanges(comp, options); + debug("xrange", comp); + comp = replaceStars(comp, options); + debug("stars", comp); + return comp; + } + function isX(id) { + return !id || id.toLowerCase() === "x" || id === "*"; + } + function replaceTildes(comp, options) { + return comp.trim().split(/\s+/).map(function(comp2) { + return replaceTilde(comp2, options); + }).join(" "); + } + function replaceTilde(comp, options) { + var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE]; + return comp.replace(r, function(_, M, m, p, pr) { + debug("tilde", comp, _, M, m, p, pr); + var ret; + if (isX(M)) { + ret = ""; + } else if (isX(m)) { + ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; + } else if (isX(p)) { + ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; + } else if (pr) { + debug("replaceTilde pr", pr); + ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; + } else { + ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; } - const cmdSpecialChars = [ - " ", - " ", - "&", - "(", - ")", - "[", - "]", - "{", - "}", - "^", - "=", - ";", - "!", - "'", - "+", - ",", - "`", - "~", - "|", - "<", - ">", - '"' - ]; - let needsQuotes = false; - for (const char of arg) { - if (cmdSpecialChars.some((x) => x === char)) { - needsQuotes = true; - break; + debug("tilde return", ret); + return ret; + }); + } + function replaceCarets(comp, options) { + return comp.trim().split(/\s+/).map(function(comp2) { + return replaceCaret(comp2, options); + }).join(" "); + } + function replaceCaret(comp, options) { + debug("caret", comp, options); + var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET]; + return comp.replace(r, function(_, M, m, p, pr) { + debug("caret", comp, _, M, m, p, pr); + var ret; + if (isX(M)) { + ret = ""; + } else if (isX(m)) { + ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; + } else if (isX(p)) { + if (M === "0") { + ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; + } else { + ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0"; } - } - 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 if (pr) { + debug("replaceCaret pr", pr); + if (M === "0") { + if (m === "0") { + ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1); + } else { + ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; + } } else { - quoteHit = false; + ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0"; } - } - 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 { + debug("no pr"); + if (M === "0") { + if (m === "0") { + ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1); + } else { + ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; + } } else { - quoteHit = false; + ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0"; } } - 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}"`; + debug("caret return", ret); + return ret; + }); + } + function replaceXRanges(comp, options) { + debug("replaceXRanges", comp, options); + return comp.split(/\s+/).map(function(comp2) { + return replaceXRange(comp2, options); + }).join(" "); + } + function replaceXRange(comp, options) { + comp = comp.trim(); + var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE]; + return comp.replace(r, function(ret, gtlt, M, m, p, pr) { + debug("xRange", comp, ret, gtlt, M, m, p, pr); + var xM = isX(M); + var xm = xM || isX(m); + var xp = xm || isX(p); + var anyX = xp; + if (gtlt === "=" && anyX) { + gtlt = ""; } - 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 __awaiter(this, void 0, void 0, function* () { - if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) { - this.toolPath = path3.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); + pr = options.includePrerelease ? "-0" : ""; + if (xM) { + if (gtlt === ">" || gtlt === "<") { + ret = "<0.0.0-0"; + } else { + ret = "*"; } - this.toolPath = yield io.which(this.toolPath, true); - return new Promise((resolve, reject) => __awaiter(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) + os.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 cp2 = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); - let stdbuffer = ""; - if (cp2.stdout) { - cp2.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 (cp2.stderr) { - cp2.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); - } - }); - }); + } else if (gtlt && anyX) { + if (xm) { + m = 0; + } + p = 0; + if (gtlt === ">") { + gtlt = ">="; + if (xm) { + M = +M + 1; + m = 0; + p = 0; + } else { + m = +m + 1; + p = 0; } - cp2.on("error", (err) => { - state.processError = err.message; - state.processExited = true; - state.processClosed = true; - state.CheckComplete(); - }); - cp2.on("exit", (code) => { - state.processExitCode = code; - state.processExited = true; - this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); - state.CheckComplete(); - }); - cp2.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); - } - cp2.removeAllListeners(); - if (error) { - reject(error); - } else { - resolve(exitCode); - } - }); - if (this.options.input) { - if (!cp2.stdin) { - throw new Error("child process missing stdin"); - } - cp2.stdin.end(this.options.input); + } else if (gtlt === "<=") { + gtlt = "<"; + if (xm) { + M = +M + 1; + } else { + m = +m + 1; } - })); - }); - } - }; - exports2.ToolRunner = ToolRunner; - function argStringToArray(argString) { - const args = []; - let inQuotes = false; - let escaped = false; - let arg = ""; - function append(c) { - if (escaped && c !== '"') { - arg += "\\"; + } + ret = gtlt + M + "." + m + "." + p + pr; + } else if (xm) { + ret = ">=" + M + ".0.0" + pr + " <" + (+M + 1) + ".0.0" + pr; + } else if (xp) { + ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr; } - arg += c; - escaped = false; + debug("xRange return", ret); + return ret; + }); + } + function replaceStars(comp, options) { + debug("replaceStars", comp, options); + return comp.trim().replace(safeRe[t.STAR], ""); + } + function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = ""; + } else if (isX(fm)) { + from = ">=" + fM + ".0.0"; + } else if (isX(fp)) { + from = ">=" + fM + "." + fm + ".0"; + } else { + from = ">=" + from; } - for (let i = 0; i < argString.length; i++) { - const c = argString.charAt(i); - if (c === '"') { - if (!escaped) { - inQuotes = !inQuotes; - } else { - append(c); - } - continue; + if (isX(tM)) { + to = ""; + } else if (isX(tm)) { + to = "<" + (+tM + 1) + ".0.0"; + } else if (isX(tp)) { + to = "<" + tM + "." + (+tm + 1) + ".0"; + } else if (tpr) { + to = "<=" + tM + "." + tm + "." + tp + "-" + tpr; + } else { + to = "<=" + to; + } + return (from + " " + to).trim(); + } + Range2.prototype.test = function(version3) { + if (!version3) { + return false; + } + if (typeof version3 === "string") { + try { + version3 = new SemVer4(version3, this.options); + } catch (er) { + return false; } - if (c === "\\" && escaped) { - append(c); - continue; + } + for (var i2 = 0; i2 < this.set.length; i2++) { + if (testSet(this.set[i2], version3, this.options)) { + return true; } - if (c === "\\" && inQuotes) { - escaped = true; - continue; + } + return false; + }; + function testSet(set, version3, options) { + for (var i2 = 0; i2 < set.length; i2++) { + if (!set[i2].test(version3)) { + return false; } - if (c === " " && !inQuotes) { - if (arg.length > 0) { - args.push(arg); - arg = ""; + } + if (version3.prerelease.length && !options.includePrerelease) { + for (i2 = 0; i2 < set.length; i2++) { + debug(set[i2].semver); + if (set[i2].semver === ANY) { + continue; + } + if (set[i2].semver.prerelease.length > 0) { + var allowed = set[i2].semver; + if (allowed.major === version3.major && allowed.minor === version3.minor && allowed.patch === version3.patch) { + return true; + } } - continue; } - append(c); + return false; } - if (arg.length > 0) { - args.push(arg.trim()); + return true; + } + exports2.satisfies = satisfies; + function satisfies(version3, range, options) { + try { + range = new Range2(range, options); + } catch (er) { + return false; } - return args; + return range.test(version3); } - 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; - } + exports2.maxSatisfying = maxSatisfying; + function maxSatisfying(versions, range, options) { + var max = null; + var maxSV = null; + try { + var rangeObj = new Range2(range, options); + } catch (er) { + return null; } - CheckComplete() { - if (this.done) { - return; + versions.forEach(function(v) { + if (rangeObj.test(v)) { + if (!max || maxSV.compare(v) === -1) { + max = v; + maxSV = new SemVer4(max, options); + } } - if (this.processClosed) { - this._setResult(); - } else if (this.processExited) { - this.timeout = timers_1.setTimeout(_ExecState.HandleTimeout, this.delay, this); + }); + return max; + } + exports2.minSatisfying = minSatisfying; + function minSatisfying(versions, range, options) { + var min = null; + var minSV = null; + try { + var rangeObj = new Range2(range, options); + } catch (er) { + return null; + } + versions.forEach(function(v) { + if (rangeObj.test(v)) { + if (!min || minSV.compare(v) === 1) { + min = v; + minSV = new SemVer4(min, options); + } } + }); + return min; + } + exports2.minVersion = minVersion; + function minVersion(range, loose) { + range = new Range2(range, loose); + var minver = new SemVer4("0.0.0"); + if (range.test(minver)) { + return minver; } - _debug(message) { - this.emit("debug", message); + minver = new SemVer4("0.0.0-0"); + if (range.test(minver)) { + return minver; } - _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`); + minver = null; + for (var i2 = 0; i2 < range.set.length; ++i2) { + var comparators = range.set[i2]; + comparators.forEach(function(comparator) { + var compver = new SemVer4(comparator.semver.version); + switch (comparator.operator) { + case ">": + if (compver.prerelease.length === 0) { + compver.patch++; + } else { + compver.prerelease.push(0); + } + compver.raw = compver.format(); + case "": + case ">=": + if (!minver || gt(minver, compver)) { + minver = compver; + } + break; + case "<": + case "<=": + break; + default: + throw new Error("Unexpected operation: " + comparator.operator); + } + }); + } + if (minver && range.test(minver)) { + return minver; + } + return null; + } + exports2.validRange = validRange; + function validRange(range, options) { + try { + return new Range2(range, options).range || "*"; + } catch (er) { + return null; + } + } + exports2.ltr = ltr; + function ltr(version3, range, options) { + return outside(version3, range, "<", options); + } + exports2.gtr = gtr; + function gtr(version3, range, options) { + return outside(version3, range, ">", options); + } + exports2.outside = outside; + function outside(version3, range, hilo, options) { + version3 = new SemVer4(version3, options); + range = new Range2(range, options); + var gtfn, ltefn, ltfn, comp, ecomp; + switch (hilo) { + case ">": + gtfn = gt; + ltefn = lte; + ltfn = lt; + comp = ">"; + ecomp = ">="; + break; + case "<": + gtfn = lt; + ltefn = gte; + ltfn = gt; + comp = "<"; + ecomp = "<="; + break; + default: + throw new TypeError('Must provide a hilo val of "<" or ">"'); + } + if (satisfies(version3, range, options)) { + return false; + } + for (var i2 = 0; i2 < range.set.length; ++i2) { + var comparators = range.set[i2]; + var high = null; + var low = null; + comparators.forEach(function(comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator(">=0.0.0"); + } + high = high || comparator; + low = low || comparator; + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator; + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator; } + }); + if (high.operator === comp || high.operator === ecomp) { + return false; } - if (this.timeout) { - clearTimeout(this.timeout); - this.timeout = null; + if ((!low.operator || low.operator === comp) && ltefn(version3, low.semver)) { + return false; + } else if (low.operator === ecomp && ltfn(version3, low.semver)) { + return false; } - 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(); + return true; + } + exports2.prerelease = prerelease; + function prerelease(version3, options) { + var parsed = parse7(version3, options); + return parsed && parsed.prerelease.length ? parsed.prerelease : null; + } + exports2.intersects = intersects; + function intersects(r1, r2, options) { + r1 = new Range2(r1, options); + r2 = new Range2(r2, options); + return r1.intersects(r2); + } + exports2.coerce = coerce; + function coerce(version3, options) { + if (version3 instanceof SemVer4) { + return version3; } - }; - } -}); - -// 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); + if (typeof version3 === "number") { + version3 = String(version3); } - __setModuleDefault(result, mod); - return result; - }; - var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); + if (typeof version3 !== "string") { + return null; } - 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); + options = options || {}; + var match = null; + if (!options.rtl) { + match = version3.match(safeRe[t.COERCE]); + } else { + var next; + while ((next = safeRe[t.COERCERTL].exec(version3)) && (!match || match.index + match[0].length !== version3.length)) { + if (!match || next.index + next[0].length !== match.index + match[0].length) { + match = next; } + safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length; } - 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 exec(commandLine, args, options) { - return __awaiter(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]; - args = commandArgs.slice(1).concat(args || []); - const runner = new tr.ToolRunner(toolPath, args, options); - return runner.exec(); - }); - } - exports2.exec = exec; - function getExecOutput(commandLine, args, options) { - var _a, _b; - return __awaiter(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 exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners })); - stdout += stdoutDecoder.end(); - stderr += stderrDecoder.end(); - return { - exitCode, - stdout, - stderr - }; - }); + safeRe[t.COERCERTL].lastIndex = -1; + } + if (match === null) { + return null; + } + return parse7(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options); } - exports2.getExecOutput = getExecOutput; } }); -// node_modules/@actions/tool-cache/lib/retry-helper.js -var require_retry_helper = __commonJS({ - "node_modules/@actions/tool-cache/lib/retry-helper.js"(exports2) { +// node_modules/@actions/tool-cache/lib/manifest.js +var require_manifest = __commonJS({ + "node_modules/@actions/tool-cache/lib/manifest.js"(exports2, module2) { "use strict"; var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) @@ -6947,56 +6538,163 @@ var require_retry_helper = __commonJS({ }); }; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.RetryHelper = void 0; - var core3 = __importStar(require_core()); - var RetryHelper = class { - constructor(maxAttempts, minSeconds, maxSeconds) { - if (maxAttempts < 1) { - throw new Error("max attempts should be greater than or equal to 1"); + exports2._readLinuxVersionFile = exports2._getOsVersion = exports2._findMatch = void 0; + var semver = __importStar(require_semver2()); + var core_1 = require_core(); + var os = require("os"); + var cp2 = require("child_process"); + var fs2 = require("fs"); + function _findMatch(versionSpec, stable, candidates, archFilter) { + return __awaiter(this, void 0, void 0, function* () { + const platFilter = os.platform(); + let result; + let match; + let file; + for (const candidate of candidates) { + const version3 = candidate.version; + core_1.debug(`check ${version3} satisfies ${versionSpec}`); + if (semver.satisfies(version3, versionSpec) && (!stable || candidate.stable === stable)) { + file = candidate.files.find((item) => { + core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`); + let chk = item.arch === archFilter && item.platform === platFilter; + if (chk && item.platform_version) { + const osVersion = module2.exports._getOsVersion(); + if (osVersion === item.platform_version) { + chk = true; + } else { + chk = semver.satisfies(osVersion, item.platform_version); + } + } + return chk; + }); + if (file) { + core_1.debug(`matched ${candidate.version}`); + match = candidate; + break; + } + } } - this.maxAttempts = maxAttempts; - this.minSeconds = Math.floor(minSeconds); - this.maxSeconds = Math.floor(maxSeconds); - if (this.minSeconds > this.maxSeconds) { - throw new Error("min seconds should be less than or equal to max seconds"); + if (match && file) { + result = Object.assign({}, match); + result.files = [file]; } - } - execute(action, isRetryable) { - return __awaiter(this, void 0, void 0, function* () { - let attempt = 1; - while (attempt < this.maxAttempts) { - try { - return yield action(); - } catch (err) { - if (isRetryable && !isRetryable(err)) { - throw err; - } - core3.info(err.message); + return result; + }); + } + exports2._findMatch = _findMatch; + function _getOsVersion() { + const plat = os.platform(); + let version3 = ""; + if (plat === "darwin") { + version3 = cp2.execSync("sw_vers -productVersion").toString(); + } else if (plat === "linux") { + const lsbContents = module2.exports._readLinuxVersionFile(); + if (lsbContents) { + const lines = lsbContents.split("\n"); + for (const line of lines) { + const parts = line.split("="); + if (parts.length === 2 && (parts[0].trim() === "VERSION_ID" || parts[0].trim() === "DISTRIB_RELEASE")) { + version3 = parts[1].trim().replace(/^"/, "").replace(/"$/, ""); + break; } - const seconds = this.getSleepAmount(); - core3.info(`Waiting ${seconds} seconds before trying again`); - yield this.sleep(seconds); - attempt++; } - return yield action(); - }); - } - getSleepAmount() { - return Math.floor(Math.random() * (this.maxSeconds - this.minSeconds + 1)) + this.minSeconds; + } } - sleep(seconds) { - return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve) => setTimeout(resolve, seconds * 1e3)); - }); + return version3; + } + exports2._getOsVersion = _getOsVersion; + function _readLinuxVersionFile() { + const lsbReleaseFile = "/etc/lsb-release"; + const osReleaseFile = "/etc/os-release"; + let contents = ""; + if (fs2.existsSync(lsbReleaseFile)) { + contents = fs2.readFileSync(lsbReleaseFile).toString(); + } else if (fs2.existsSync(osReleaseFile)) { + contents = fs2.readFileSync(osReleaseFile).toString(); } + return contents; + } + exports2._readLinuxVersionFile = _readLinuxVersionFile; + } +}); + +// node_modules/@actions/tool-cache/node_modules/uuid/lib/rng.js +var require_rng = __commonJS({ + "node_modules/@actions/tool-cache/node_modules/uuid/lib/rng.js"(exports2, module2) { + var crypto4 = require("crypto"); + module2.exports = function nodeRNG() { + return crypto4.randomBytes(16); }; - exports2.RetryHelper = RetryHelper; } }); -// node_modules/@actions/tool-cache/lib/tool-cache.js -var require_tool_cache = __commonJS({ - "node_modules/@actions/tool-cache/lib/tool-cache.js"(exports2) { +// node_modules/@actions/tool-cache/node_modules/uuid/lib/bytesToUuid.js +var require_bytesToUuid = __commonJS({ + "node_modules/@actions/tool-cache/node_modules/uuid/lib/bytesToUuid.js"(exports2, module2) { + var byteToHex2 = []; + for (i = 0; i < 256; ++i) { + byteToHex2[i] = (i + 256).toString(16).substr(1); + } + var i; + function bytesToUuid(buf, offset) { + var i2 = offset || 0; + var bth = byteToHex2; + return [ + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]], + "-", + bth[buf[i2++]], + bth[buf[i2++]], + "-", + bth[buf[i2++]], + bth[buf[i2++]], + "-", + bth[buf[i2++]], + bth[buf[i2++]], + "-", + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]], + bth[buf[i2++]] + ].join(""); + } + module2.exports = bytesToUuid; + } +}); + +// node_modules/@actions/tool-cache/node_modules/uuid/v4.js +var require_v4 = __commonJS({ + "node_modules/@actions/tool-cache/node_modules/uuid/v4.js"(exports2, module2) { + var rng2 = require_rng(); + var bytesToUuid = require_bytesToUuid(); + function v42(options, buf, offset) { + var i = buf && offset || 0; + if (typeof options == "string") { + buf = options === "binary" ? new Array(16) : null; + options = null; + } + options = options || {}; + var rnds = options.random || (options.rng || rng2)(); + rnds[6] = rnds[6] & 15 | 64; + rnds[8] = rnds[8] & 63 | 128; + if (buf) { + for (var ii = 0; ii < 16; ++ii) { + buf[i + ii] = rnds[ii]; + } + } + return buf || bytesToUuid(rnds); + } + module2.exports = v42; + } +}); + +// 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) @@ -7053,898 +6751,1200 @@ var require_tool_cache = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __importDefault = exports2 && exports2.__importDefault || function(mod) { - return mod && mod.__esModule ? mod : { "default": mod }; - }; Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.evaluateVersions = exports2.isExplicitVersion = exports2.findFromManifest = exports2.getManifestFromRepo = exports2.findAllVersions = exports2.find = exports2.cacheFile = exports2.cacheDir = exports2.extractZip = exports2.extractXar = exports2.extractTar = exports2.extract7z = exports2.downloadTool = exports2.HTTPError = void 0; - var core3 = __importStar(require_core()); - var io = __importStar(require_io()); - var fs2 = __importStar(require("fs")); - var mm = __importStar(require_manifest()); + exports2.argStringToArray = exports2.ToolRunner = void 0; var os = __importStar(require("os")); + var events = __importStar(require("events")); + var child = __importStar(require("child_process")); var path3 = __importStar(require("path")); - var httpm = __importStar(require_lib()); - var semver = __importStar(require_semver()); - var stream = __importStar(require("stream")); - var util = __importStar(require("util")); - var assert_1 = require("assert"); - var v4_1 = __importDefault(require_v4()); - var exec_1 = require_exec(); - var retry_helper_1 = require_retry_helper(); - var HTTPError = class extends Error { - constructor(httpStatusCode) { - super(`Unexpected HTTP response: ${httpStatusCode}`); - this.httpStatusCode = httpStatusCode; - Object.setPrototypeOf(this, new.target.prototype); - } - }; - exports2.HTTPError = HTTPError; - var IS_WINDOWS = process.platform === "win32"; - var IS_MAC = process.platform === "darwin"; - var userAgent = "actions/tool-cache"; - function downloadTool2(url, dest, auth, headers) { - return __awaiter(this, void 0, void 0, function* () { - dest = dest || path3.join(_getTempDirectory(), v4_1.default()); - yield io.mkdirP(path3.dirname(dest)); - core3.debug(`Downloading ${url}`); - core3.debug(`Destination ${dest}`); - const maxAttempts = 3; - const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); - const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); - const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); - return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { - return yield downloadToolAttempt(url, dest || "", auth, headers); - }), (err) => { - if (err instanceof HTTPError && err.httpStatusCode) { - if (err.httpStatusCode < 500 && err.httpStatusCode !== 408 && err.httpStatusCode !== 429) { - return false; - } - } - return true; - }); - }); - } - exports2.downloadTool = downloadTool2; - function downloadToolAttempt(url, dest, auth, headers) { - return __awaiter(this, void 0, void 0, function* () { - if (fs2.existsSync(dest)) { - throw new Error(`Destination file path ${dest} already exists`); - } - const http = new httpm.HttpClient(userAgent, [], { - allowRetries: false - }); - if (auth) { - core3.debug("set auth"); - if (headers === void 0) { - headers = {}; - } - headers.authorization = auth; - } - const response = yield http.get(url, headers); - if (response.message.statusCode !== 200) { - const err = new HTTPError(response.message.statusCode); - core3.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - throw err; - } - const pipeline = util.promisify(stream.pipeline); - const responseMessageFactory = _getGlobal("TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY", () => response.message); - const readStream = responseMessageFactory(); - let succeeded = false; - try { - yield pipeline(readStream, fs2.createWriteStream(dest)); - core3.debug("download complete"); - succeeded = true; - return dest; - } finally { - if (!succeeded) { - core3.debug("download failed"); - try { - yield io.rmRF(dest); - } catch (err) { - core3.debug(`Failed to delete '${dest}'. ${err.message}`); - } - } - } - }); - } - function extract7z(file, dest, _7zPath) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_WINDOWS, "extract7z() not supported on current OS"); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - const originalCwd = process.cwd(); - process.chdir(dest); - if (_7zPath) { - try { - const logLevel = core3.isDebug() ? "-bb1" : "-bb0"; - const args = [ - "x", - logLevel, - "-bd", - "-sccUTF-8", - file - ]; - const options = { - silent: true - }; - yield exec_1.exec(`"${_7zPath}"`, args, options); - } finally { - process.chdir(originalCwd); - } - } else { - const escapedScript = path3.join(__dirname, "..", "scripts", "Invoke-7zdec.ps1").replace(/'/g, "''").replace(/"|\n|\r/g, ""); - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ""); - const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ""); - const command2 = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; - const args = [ - "-NoLogo", - "-Sta", - "-NoProfile", - "-NonInteractive", - "-ExecutionPolicy", - "Unrestricted", - "-Command", - command2 - ]; - const options = { - silent: true - }; - try { - const powershellPath = yield io.which("powershell", true); - yield exec_1.exec(`"${powershellPath}"`, args, options); - } finally { - process.chdir(originalCwd); - } + var io = __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, args, options) { + super(); + if (!toolPath) { + throw new Error("Parameter 'toolPath' cannot be null or empty."); } - return dest; - }); - } - exports2.extract7z = extract7z; - function extractTar2(file, dest, flags = "xz") { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); + this.toolPath = toolPath; + this.args = args || []; + this.options = options || {}; + } + _debug(message) { + if (this.options.listeners && this.options.listeners.debug) { + this.options.listeners.debug(message); } - dest = yield _createExtractFolder(dest); - core3.debug("Checking tar --version"); - let versionOutput = ""; - yield exec_1.exec("tar --version", [], { - ignoreReturnCode: true, - silent: true, - listeners: { - stdout: (data) => versionOutput += data.toString(), - stderr: (data) => versionOutput += data.toString() + } + _getCommandString(options, noPrefix) { + const toolPath = this._getSpawnFileName(); + const args = this._getSpawnArgs(options); + let cmd = noPrefix ? "" : "[command]"; + if (IS_WINDOWS) { + if (this._isCmdFile()) { + cmd += toolPath; + for (const a of args) { + cmd += ` ${a}`; + } + } else if (options.windowsVerbatimArguments) { + cmd += `"${toolPath}"`; + for (const a of args) { + cmd += ` ${a}`; + } + } else { + cmd += this._windowsQuoteCmdArg(toolPath); + for (const a of args) { + cmd += ` ${this._windowsQuoteCmdArg(a)}`; + } } - }); - core3.debug(versionOutput.trim()); - const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); - let args; - if (flags instanceof Array) { - args = flags; } else { - args = [flags]; + cmd += toolPath; + for (const a of args) { + cmd += ` ${a}`; + } } - if (core3.isDebug() && !flags.includes("v")) { - args.push("-v"); + return cmd; + } + _processLineBuffer(data, strBuffer, onLine) { + try { + let s = strBuffer + data.toString(); + let n = s.indexOf(os.EOL); + while (n > -1) { + const line = s.substring(0, n); + onLine(line); + s = s.substring(n + os.EOL.length); + n = s.indexOf(os.EOL); + } + return s; + } catch (err) { + this._debug(`error processing line. Failed with error ${err}`); + return ""; } - let destArg = dest; - let fileArg = file; - if (IS_WINDOWS && isGnuTar) { - args.push("--force-local"); - destArg = dest.replace(/\\/g, "/"); - fileArg = file.replace(/\\/g, "/"); + } + _getSpawnFileName() { + if (IS_WINDOWS) { + if (this._isCmdFile()) { + return process.env["COMSPEC"] || "cmd.exe"; + } } - if (isGnuTar) { - args.push("--warning=no-unknown-keyword"); - args.push("--overwrite"); + 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]; + } } - args.push("-C", destArg, "-f", fileArg); - yield exec_1.exec(`tar`, args); - return dest; - }); - } - exports2.extractTar = extractTar2; - function extractXar(file, dest, flags = []) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_MAC, "extractXar() not supported on current OS"); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - let args; - if (flags instanceof Array) { - args = flags; - } else { - args = [flags]; + 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); } - args.push("-x", "-C", dest, "-f", file); - if (core3.isDebug()) { - args.push("-v"); + if (!arg) { + return '""'; } - const xarPath = yield io.which("xar", true); - yield exec_1.exec(`"${xarPath}"`, _unique(args)); - return dest; - }); - } - exports2.extractXar = extractXar; - function extractZip(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); + const cmdSpecialChars = [ + " ", + " ", + "&", + "(", + ")", + "[", + "]", + "{", + "}", + "^", + "=", + ";", + "!", + "'", + "+", + ",", + "`", + "~", + "|", + "<", + ">", + '"' + ]; + let needsQuotes = false; + for (const char of arg) { + if (cmdSpecialChars.some((x) => x === char)) { + needsQuotes = true; + break; + } } - dest = yield _createExtractFolder(dest); - if (IS_WINDOWS) { - yield extractZipWin(file, dest); - } else { - yield extractZipNix(file, dest); + if (!needsQuotes) { + return arg; } - return dest; - }); - } - exports2.extractZip = extractZip; - function extractZipWin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ""); - const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ""); - const pwshPath = yield io.which("pwsh", false); - if (pwshPath) { - const pwshCommand = [ - `$ErrorActionPreference = 'Stop' ;`, - `try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`, - `try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`, - `catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;` - ].join(" "); - const args = [ - "-NoLogo", - "-NoProfile", - "-NonInteractive", - "-ExecutionPolicy", - "Unrestricted", - "-Command", - pwshCommand - ]; - core3.debug(`Using pwsh at path: ${pwshPath}`); - yield exec_1.exec(`"${pwshPath}"`, args); - } else { - const powershellCommand = [ - `$ErrorActionPreference = 'Stop' ;`, - `try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`, - `if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`, - `else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }` - ].join(" "); - const args = [ - "-NoLogo", - "-Sta", - "-NoProfile", - "-NonInteractive", - "-ExecutionPolicy", - "Unrestricted", - "-Command", - powershellCommand - ]; - const powershellPath = yield io.which("powershell", true); - core3.debug(`Using powershell at path: ${powershellPath}`); - yield exec_1.exec(`"${powershellPath}"`, args); + 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; + } } - }); - } - function extractZipNix(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = yield io.which("unzip", true); - const args = [file]; - if (!core3.isDebug()) { - args.unshift("-q"); + reverse += '"'; + return reverse.split("").reverse().join(""); + } + _uvQuoteCmdArg(arg) { + if (!arg) { + return '""'; } - args.unshift("-o"); - yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); - }); - } - function cacheDir2(sourceDir, tool, version3, arch) { - return __awaiter(this, void 0, void 0, function* () { - version3 = semver.clean(version3) || version3; - arch = arch || os.arch(); - core3.debug(`Caching tool ${tool} ${version3} ${arch}`); - core3.debug(`source dir: ${sourceDir}`); - if (!fs2.statSync(sourceDir).isDirectory()) { - throw new Error("sourceDir is not a directory"); + if (!arg.includes(" ") && !arg.includes(" ") && !arg.includes('"')) { + return arg; } - const destPath = yield _createToolPath(tool, version3, arch); - for (const itemName of fs2.readdirSync(sourceDir)) { - const s = path3.join(sourceDir, itemName); - yield io.cp(s, destPath, { recursive: true }); + if (!arg.includes('"') && !arg.includes("\\")) { + return `"${arg}"`; } - _completeToolPath(tool, version3, arch); - return destPath; - }); - } - exports2.cacheDir = cacheDir2; - function cacheFile(sourceFile, targetFile, tool, version3, arch) { - return __awaiter(this, void 0, void 0, function* () { - version3 = semver.clean(version3) || version3; - arch = arch || os.arch(); - core3.debug(`Caching tool ${tool} ${version3} ${arch}`); - core3.debug(`source file: ${sourceFile}`); - if (!fs2.statSync(sourceFile).isFile()) { - throw new Error("sourceFile is not a file"); + 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; + } } - const destFolder = yield _createToolPath(tool, version3, arch); - const destPath = path3.join(destFolder, targetFile); - core3.debug(`destination file ${destPath}`); - yield io.cp(sourceFile, destPath); - _completeToolPath(tool, version3, arch); - return destFolder; - }); - } - exports2.cacheFile = cacheFile; - function find2(toolName, versionSpec, arch) { - if (!toolName) { - throw new Error("toolName parameter is required"); - } - if (!versionSpec) { - throw new Error("versionSpec parameter is required"); + reverse += '"'; + return reverse.split("").reverse().join(""); } - arch = arch || os.arch(); - if (!isExplicitVersion(versionSpec)) { - const localVersions = findAllVersions(toolName, arch); - const match = evaluateVersions(localVersions, versionSpec); - versionSpec = match; + _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; } - let toolPath = ""; - if (versionSpec) { - versionSpec = semver.clean(versionSpec) || ""; - const cachePath = path3.join(_getCacheDirectory(), toolName, versionSpec, arch); - core3.debug(`checking cache: ${cachePath}`); - if (fs2.existsSync(cachePath) && fs2.existsSync(`${cachePath}.complete`)) { - core3.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); - toolPath = cachePath; - } else { - core3.debug("not found"); + _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; } - return toolPath; - } - exports2.find = find2; - function findAllVersions(toolName, arch) { - const versions = []; - arch = arch || os.arch(); - const toolPath = path3.join(_getCacheDirectory(), toolName); - if (fs2.existsSync(toolPath)) { - const children = fs2.readdirSync(toolPath); - for (const child of children) { - if (isExplicitVersion(child)) { - const fullPath = path3.join(toolPath, child, arch || ""); - if (fs2.existsSync(fullPath) && fs2.existsSync(`${fullPath}.complete`)) { - versions.push(child); + /** + * 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 __awaiter(this, void 0, void 0, function* () { + if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) { + this.toolPath = path3.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); + } + this.toolPath = yield io.which(this.toolPath, true); + return new Promise((resolve, reject) => __awaiter(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) + os.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 cp2 = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); + let stdbuffer = ""; + if (cp2.stdout) { + cp2.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 (cp2.stderr) { + cp2.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); + } + }); + }); + } + cp2.on("error", (err) => { + state.processError = err.message; + state.processExited = true; + state.processClosed = true; + state.CheckComplete(); + }); + cp2.on("exit", (code) => { + state.processExitCode = code; + state.processExited = true; + this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); + state.CheckComplete(); + }); + cp2.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); + } + cp2.removeAllListeners(); + if (error) { + reject(error); + } else { + resolve(exitCode); + } + }); + if (this.options.input) { + if (!cp2.stdin) { + throw new Error("child process missing stdin"); + } + cp2.stdin.end(this.options.input); } + })); + }); + } + }; + exports2.ToolRunner = ToolRunner; + function argStringToArray(argString) { + const args = []; + 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) { + args.push(arg); + arg = ""; } + continue; } + append(c); } - return versions; + if (arg.length > 0) { + args.push(arg.trim()); + } + return args; } - exports2.findAllVersions = findAllVersions; - function getManifestFromRepo(owner, repo, auth, branch = "master") { - return __awaiter(this, void 0, void 0, function* () { - let releases = []; - const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; - const http = new httpm.HttpClient("tool-cache"); - const headers = {}; - if (auth) { - core3.debug("set auth"); - headers.authorization = auth; + 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"); } - const response = yield http.getJson(treeUrl, headers); - if (!response.result) { - return releases; + this.options = options; + this.toolPath = toolPath; + if (options.delay) { + this.delay = options.delay; } - let manifestUrl = ""; - for (const item of response.result.tree) { - if (item.path === "versions-manifest.json") { - manifestUrl = item.url; - break; - } + } + CheckComplete() { + if (this.done) { + return; } - headers["accept"] = "application/vnd.github.VERSION.raw"; - let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); - if (versionsRaw) { - versionsRaw = versionsRaw.replace(/^\uFEFF/, ""); - try { - releases = JSON.parse(versionsRaw); - } catch (_a) { - core3.debug("Invalid json"); + 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`); } } - return releases; - }); - } - exports2.getManifestFromRepo = getManifestFromRepo; - function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { - return __awaiter(this, void 0, void 0, function* () { - const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); - return match; - }); - } - exports2.findFromManifest = findFromManifest; - function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - dest = path3.join(_getTempDirectory(), v4_1.default()); + if (this.timeout) { + clearTimeout(this.timeout); + this.timeout = null; } - yield io.mkdirP(dest); - return dest; - }); - } - function _createToolPath(tool, version3, arch) { - return __awaiter(this, void 0, void 0, function* () { - const folderPath = path3.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); - core3.debug(`destination ${folderPath}`); - const markerPath = `${folderPath}.complete`; - yield io.rmRF(folderPath); - yield io.rmRF(markerPath); - yield io.mkdirP(folderPath); - return folderPath; - }); - } - function _completeToolPath(tool, version3, arch) { - const folderPath = path3.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); - const markerPath = `${folderPath}.complete`; - fs2.writeFileSync(markerPath, ""); - core3.debug("finished caching tool"); - } - function isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec) || ""; - core3.debug(`isExplicit: ${c}`); - const valid = semver.valid(c) != null; - core3.debug(`explicit? ${valid}`); - return valid; - } - exports2.isExplicitVersion = isExplicitVersion; - function evaluateVersions(versions, versionSpec) { - let version3 = ""; - core3.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; + this.done = true; + this.emit("done", error, this.processExitCode); + } + static HandleTimeout(state) { + if (state.done) { + return; } - return -1; - }); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version3 = potential; - break; + 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(); } - if (version3) { - core3.debug(`matched: ${version3}`); - } else { - core3.debug("match not found"); - } - return version3; - } - exports2.evaluateVersions = evaluateVersions; - function _getCacheDirectory() { - const cacheDirectory = process.env["RUNNER_TOOL_CACHE"] || ""; - assert_1.ok(cacheDirectory, "Expected RUNNER_TOOL_CACHE to be defined"); - return cacheDirectory; - } - function _getTempDirectory() { - const tempDirectory = process.env["RUNNER_TEMP"] || ""; - assert_1.ok(tempDirectory, "Expected RUNNER_TEMP to be defined"); - return tempDirectory; - } - function _getGlobal(key, defaultValue) { - const value = global[key]; - return value !== void 0 ? value : defaultValue; - } - function _unique(values) { - return Array.from(new Set(values)); - } - } -}); - -// node_modules/semver/internal/debug.js -var require_debug = __commonJS({ - "node_modules/semver/internal/debug.js"(exports2, module2) { - var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { }; - module2.exports = debug; } }); -// node_modules/semver/internal/constants.js -var require_constants = __commonJS({ - "node_modules/semver/internal/constants.js"(exports2, module2) { - var SEMVER_SPEC_VERSION = "2.0.0"; - var MAX_LENGTH = 256; - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ - 9007199254740991; - var MAX_SAFE_COMPONENT_LENGTH = 16; - var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; - var RELEASE_TYPES = [ - "major", - "premajor", - "minor", - "preminor", - "patch", - "prepatch", - "prerelease" - ]; - module2.exports = { - MAX_LENGTH, - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_SAFE_INTEGER, - RELEASE_TYPES, - SEMVER_SPEC_VERSION, - FLAG_INCLUDE_PRERELEASE: 1, - FLAG_LOOSE: 2 +// 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 __awaiter = 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 exec(commandLine, args, options) { + return __awaiter(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]; + args = commandArgs.slice(1).concat(args || []); + const runner = new tr.ToolRunner(toolPath, args, options); + return runner.exec(); + }); + } + exports2.exec = exec; + function getExecOutput(commandLine, args, options) { + var _a, _b; + return __awaiter(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 exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners })); + stdout += stdoutDecoder.end(); + stderr += stderrDecoder.end(); + return { + exitCode, + stdout, + stderr + }; + }); + } + exports2.getExecOutput = getExecOutput; } }); -// node_modules/semver/internal/re.js -var require_re = __commonJS({ - "node_modules/semver/internal/re.js"(exports2, module2) { - var { - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_LENGTH - } = require_constants(); - var debug = require_debug(); - exports2 = module2.exports = {}; - var re = exports2.re = []; - var safeRe = exports2.safeRe = []; - var src = exports2.src = []; - var t = exports2.t = {}; - var R = 0; - var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; - var safeRegexReplacements = [ - ["\\s", 1], - ["\\d", MAX_LENGTH], - [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] - ]; - var makeSafeRegex = (value) => { - for (const [token, max] of safeRegexReplacements) { - value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); +// node_modules/@actions/tool-cache/lib/retry-helper.js +var require_retry_helper = __commonJS({ + "node_modules/@actions/tool-cache/lib/retry-helper.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); } - return value; + __setModuleDefault(result, mod); + return result; }; - var createToken = (name, value, isGlobal) => { - const safe = makeSafeRegex(value); - const index = R++; - debug(name, index, value); - t[name] = index; - src[index] = value; - re[index] = new RegExp(value, isGlobal ? "g" : void 0); - safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0); + var __awaiter = 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()); + }); }; - createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*"); - createToken("NUMERICIDENTIFIERLOOSE", "\\d+"); - createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); - createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); - createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); - createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); - createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); - createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); - createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); - createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); - createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); - createToken("FULL", `^${src[t.FULLPLAIN]}$`); - createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); - createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); - createToken("GTLT", "((?:<|>)?=?)"); - createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); - createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); - createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); - createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); - createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); - createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); - createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`); - createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`); - createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); - createToken("COERCERTL", src[t.COERCE], true); - createToken("COERCERTLFULL", src[t.COERCEFULL], true); - createToken("LONETILDE", "(?:~>?)"); - createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); - exports2.tildeTrimReplace = "$1~"; - createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); - createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); - createToken("LONECARET", "(?:\\^)"); - createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); - exports2.caretTrimReplace = "$1^"; - createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); - createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); - createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); - createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); - createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); - exports2.comparatorTrimReplace = "$1$2$3"; - createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); - createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); - createToken("STAR", "(<|>)?=?\\s*\\*"); - createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); - createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); - } -}); - -// node_modules/semver/internal/parse-options.js -var require_parse_options = __commonJS({ - "node_modules/semver/internal/parse-options.js"(exports2, module2) { - var looseOption = Object.freeze({ loose: true }); - var emptyOpts = Object.freeze({}); - var parseOptions = (options) => { - if (!options) { - return emptyOpts; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.RetryHelper = void 0; + var core3 = __importStar(require_core()); + var RetryHelper = class { + constructor(maxAttempts, minSeconds, maxSeconds) { + if (maxAttempts < 1) { + throw new Error("max attempts should be greater than or equal to 1"); + } + this.maxAttempts = maxAttempts; + this.minSeconds = Math.floor(minSeconds); + this.maxSeconds = Math.floor(maxSeconds); + if (this.minSeconds > this.maxSeconds) { + throw new Error("min seconds should be less than or equal to max seconds"); + } } - if (typeof options !== "object") { - return looseOption; + execute(action, isRetryable) { + return __awaiter(this, void 0, void 0, function* () { + let attempt = 1; + while (attempt < this.maxAttempts) { + try { + return yield action(); + } catch (err) { + if (isRetryable && !isRetryable(err)) { + throw err; + } + core3.info(err.message); + } + const seconds = this.getSleepAmount(); + core3.info(`Waiting ${seconds} seconds before trying again`); + yield this.sleep(seconds); + attempt++; + } + return yield action(); + }); + } + getSleepAmount() { + return Math.floor(Math.random() * (this.maxSeconds - this.minSeconds + 1)) + this.minSeconds; + } + sleep(seconds) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => setTimeout(resolve, seconds * 1e3)); + }); } - return options; }; - module2.exports = parseOptions; + exports2.RetryHelper = RetryHelper; } }); -// node_modules/semver/internal/identifiers.js -var require_identifiers = __commonJS({ - "node_modules/semver/internal/identifiers.js"(exports2, module2) { - var numeric = /^[0-9]+$/; - var compareIdentifiers = (a, b) => { - const anum = numeric.test(a); - const bnum = numeric.test(b); - if (anum && bnum) { - a = +a; - b = +b; +// node_modules/@actions/tool-cache/lib/tool-cache.js +var require_tool_cache = __commonJS({ + "node_modules/@actions/tool-cache/lib/tool-cache.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); } - return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; + __setModuleDefault(result, mod); + return result; }; - var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); - module2.exports = { - compareIdentifiers, - rcompareIdentifiers + var __awaiter = 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()); + }); }; - } -}); - -// node_modules/semver/classes/semver.js -var require_semver2 = __commonJS({ - "node_modules/semver/classes/semver.js"(exports2, module2) { - var debug = require_debug(); - var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(); - var { safeRe: re, t } = require_re(); - var parseOptions = require_parse_options(); - var { compareIdentifiers } = require_identifiers(); - var SemVer3 = class _SemVer { - constructor(version3, options) { - options = parseOptions(options); - if (version3 instanceof _SemVer) { - if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) { - return version3; - } else { - version3 = version3.version; + var __importDefault = exports2 && exports2.__importDefault || function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.evaluateVersions = exports2.isExplicitVersion = exports2.findFromManifest = exports2.getManifestFromRepo = exports2.findAllVersions = exports2.find = exports2.cacheFile = exports2.cacheDir = exports2.extractZip = exports2.extractXar = exports2.extractTar = exports2.extract7z = exports2.downloadTool = exports2.HTTPError = void 0; + var core3 = __importStar(require_core()); + var io = __importStar(require_io()); + var fs2 = __importStar(require("fs")); + var mm = __importStar(require_manifest()); + var os = __importStar(require("os")); + var path3 = __importStar(require("path")); + var httpm = __importStar(require_lib()); + var semver = __importStar(require_semver2()); + var stream = __importStar(require("stream")); + var util = __importStar(require("util")); + var assert_1 = require("assert"); + var v4_1 = __importDefault(require_v4()); + var exec_1 = require_exec(); + var retry_helper_1 = require_retry_helper(); + var HTTPError = class extends Error { + constructor(httpStatusCode) { + super(`Unexpected HTTP response: ${httpStatusCode}`); + this.httpStatusCode = httpStatusCode; + Object.setPrototypeOf(this, new.target.prototype); + } + }; + exports2.HTTPError = HTTPError; + var IS_WINDOWS = process.platform === "win32"; + var IS_MAC = process.platform === "darwin"; + var userAgent = "actions/tool-cache"; + function downloadTool2(url, dest, auth, headers) { + return __awaiter(this, void 0, void 0, function* () { + dest = dest || path3.join(_getTempDirectory(), v4_1.default()); + yield io.mkdirP(path3.dirname(dest)); + core3.debug(`Downloading ${url}`); + core3.debug(`Destination ${dest}`); + const maxAttempts = 3; + const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); + const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); + const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); + return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { + return yield downloadToolAttempt(url, dest || "", auth, headers); + }), (err) => { + if (err instanceof HTTPError && err.httpStatusCode) { + if (err.httpStatusCode < 500 && err.httpStatusCode !== 408 && err.httpStatusCode !== 429) { + return false; + } } - } else if (typeof version3 !== "string") { - throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version3}".`); + return true; + }); + }); + } + exports2.downloadTool = downloadTool2; + function downloadToolAttempt(url, dest, auth, headers) { + return __awaiter(this, void 0, void 0, function* () { + if (fs2.existsSync(dest)) { + throw new Error(`Destination file path ${dest} already exists`); + } + const http = new httpm.HttpClient(userAgent, [], { + allowRetries: false + }); + if (auth) { + core3.debug("set auth"); + if (headers === void 0) { + headers = {}; + } + headers.authorization = auth; + } + const response = yield http.get(url, headers); + if (response.message.statusCode !== 200) { + const err = new HTTPError(response.message.statusCode); + core3.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + throw err; + } + const pipeline = util.promisify(stream.pipeline); + const responseMessageFactory = _getGlobal("TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY", () => response.message); + const readStream = responseMessageFactory(); + let succeeded = false; + try { + yield pipeline(readStream, fs2.createWriteStream(dest)); + core3.debug("download complete"); + succeeded = true; + return dest; + } finally { + if (!succeeded) { + core3.debug("download failed"); + try { + yield io.rmRF(dest); + } catch (err) { + core3.debug(`Failed to delete '${dest}'. ${err.message}`); + } + } + } + }); + } + function extract7z(file, dest, _7zPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_WINDOWS, "extract7z() not supported on current OS"); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + const originalCwd = process.cwd(); + process.chdir(dest); + if (_7zPath) { + try { + const logLevel = core3.isDebug() ? "-bb1" : "-bb0"; + const args = [ + "x", + logLevel, + "-bd", + "-sccUTF-8", + file + ]; + const options = { + silent: true + }; + yield exec_1.exec(`"${_7zPath}"`, args, options); + } finally { + process.chdir(originalCwd); + } + } else { + const escapedScript = path3.join(__dirname, "..", "scripts", "Invoke-7zdec.ps1").replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const command2 = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; + const args = [ + "-NoLogo", + "-Sta", + "-NoProfile", + "-NonInteractive", + "-ExecutionPolicy", + "Unrestricted", + "-Command", + command2 + ]; + const options = { + silent: true + }; + try { + const powershellPath = yield io.which("powershell", true); + yield exec_1.exec(`"${powershellPath}"`, args, options); + } finally { + process.chdir(originalCwd); + } + } + return dest; + }); + } + exports2.extract7z = extract7z; + function extractTar2(file, dest, flags = "xz") { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + dest = yield _createExtractFolder(dest); + core3.debug("Checking tar --version"); + let versionOutput = ""; + yield exec_1.exec("tar --version", [], { + ignoreReturnCode: true, + silent: true, + listeners: { + stdout: (data) => versionOutput += data.toString(), + stderr: (data) => versionOutput += data.toString() + } + }); + core3.debug(versionOutput.trim()); + const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); + let args; + if (flags instanceof Array) { + args = flags; + } else { + args = [flags]; } - if (version3.length > MAX_LENGTH) { - throw new TypeError( - `version is longer than ${MAX_LENGTH} characters` - ); + if (core3.isDebug() && !flags.includes("v")) { + args.push("-v"); } - debug("SemVer", version3, options); - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - const m = version3.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); - if (!m) { - throw new TypeError(`Invalid Version: ${version3}`); + let destArg = dest; + let fileArg = file; + if (IS_WINDOWS && isGnuTar) { + args.push("--force-local"); + destArg = dest.replace(/\\/g, "/"); + fileArg = file.replace(/\\/g, "/"); } - this.raw = version3; - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); + if (isGnuTar) { + args.push("--warning=no-unknown-keyword"); + args.push("--overwrite"); } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); + args.push("-C", destArg, "-f", fileArg); + yield exec_1.exec(`tar`, args); + return dest; + }); + } + exports2.extractTar = extractTar2; + function extractXar(file, dest, flags = []) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_MAC, "extractXar() not supported on current OS"); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + let args; + if (flags instanceof Array) { + args = flags; + } else { + args = [flags]; } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); + args.push("-x", "-C", dest, "-f", file); + if (core3.isDebug()) { + args.push("-v"); } - if (!m[4]) { - this.prerelease = []; - } else { - this.prerelease = m[4].split(".").map((id) => { - if (/^[0-9]+$/.test(id)) { - const num = +id; - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; - } - } - return id; - }); + const xarPath = yield io.which("xar", true); + yield exec_1.exec(`"${xarPath}"`, _unique(args)); + return dest; + }); + } + exports2.extractXar = extractXar; + function extractZip(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); } - this.build = m[5] ? m[5].split(".") : []; - this.format(); - } - format() { - this.version = `${this.major}.${this.minor}.${this.patch}`; - if (this.prerelease.length) { - this.version += `-${this.prerelease.join(".")}`; + dest = yield _createExtractFolder(dest); + if (IS_WINDOWS) { + yield extractZipWin(file, dest); + } else { + yield extractZipNix(file, dest); } - return this.version; - } - toString() { - return this.version; - } - compare(other) { - debug("SemVer.compare", this.version, this.options, other); - if (!(other instanceof _SemVer)) { - if (typeof other === "string" && other === this.version) { - return 0; - } - other = new _SemVer(other, this.options); + return dest; + }); + } + exports2.extractZip = extractZip; + function extractZipWin(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const pwshPath = yield io.which("pwsh", false); + if (pwshPath) { + const pwshCommand = [ + `$ErrorActionPreference = 'Stop' ;`, + `try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`, + `try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`, + `catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;` + ].join(" "); + const args = [ + "-NoLogo", + "-NoProfile", + "-NonInteractive", + "-ExecutionPolicy", + "Unrestricted", + "-Command", + pwshCommand + ]; + core3.debug(`Using pwsh at path: ${pwshPath}`); + yield exec_1.exec(`"${pwshPath}"`, args); + } else { + const powershellCommand = [ + `$ErrorActionPreference = 'Stop' ;`, + `try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`, + `if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`, + `else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }` + ].join(" "); + const args = [ + "-NoLogo", + "-Sta", + "-NoProfile", + "-NonInteractive", + "-ExecutionPolicy", + "Unrestricted", + "-Command", + powershellCommand + ]; + const powershellPath = yield io.which("powershell", true); + core3.debug(`Using powershell at path: ${powershellPath}`); + yield exec_1.exec(`"${powershellPath}"`, args); } - if (other.version === this.version) { - return 0; + }); + } + function extractZipNix(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const unzipPath = yield io.which("unzip", true); + const args = [file]; + if (!core3.isDebug()) { + args.unshift("-q"); } - return this.compareMain(other) || this.comparePre(other); - } - compareMain(other) { - if (!(other instanceof _SemVer)) { - other = new _SemVer(other, this.options); + args.unshift("-o"); + yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); + }); + } + function cacheDir2(sourceDir, tool, version3, arch) { + return __awaiter(this, void 0, void 0, function* () { + version3 = semver.clean(version3) || version3; + arch = arch || os.arch(); + core3.debug(`Caching tool ${tool} ${version3} ${arch}`); + core3.debug(`source dir: ${sourceDir}`); + if (!fs2.statSync(sourceDir).isDirectory()) { + throw new Error("sourceDir is not a directory"); } - return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); - } - comparePre(other) { - if (!(other instanceof _SemVer)) { - other = new _SemVer(other, this.options); + const destPath = yield _createToolPath(tool, version3, arch); + for (const itemName of fs2.readdirSync(sourceDir)) { + const s = path3.join(sourceDir, itemName); + yield io.cp(s, destPath, { recursive: true }); } - if (this.prerelease.length && !other.prerelease.length) { - return -1; - } else if (!this.prerelease.length && other.prerelease.length) { - return 1; - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; + _completeToolPath(tool, version3, arch); + return destPath; + }); + } + exports2.cacheDir = cacheDir2; + function cacheFile(sourceFile, targetFile, tool, version3, arch) { + return __awaiter(this, void 0, void 0, function* () { + version3 = semver.clean(version3) || version3; + arch = arch || os.arch(); + core3.debug(`Caching tool ${tool} ${version3} ${arch}`); + core3.debug(`source file: ${sourceFile}`); + if (!fs2.statSync(sourceFile).isFile()) { + throw new Error("sourceFile is not a file"); } - let i = 0; - do { - const a = this.prerelease[i]; - const b = other.prerelease[i]; - debug("prerelease compare", i, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i); + const destFolder = yield _createToolPath(tool, version3, arch); + const destPath = path3.join(destFolder, targetFile); + core3.debug(`destination file ${destPath}`); + yield io.cp(sourceFile, destPath); + _completeToolPath(tool, version3, arch); + return destFolder; + }); + } + exports2.cacheFile = cacheFile; + function find2(toolName, versionSpec, arch) { + if (!toolName) { + throw new Error("toolName parameter is required"); } - compareBuild(other) { - if (!(other instanceof _SemVer)) { - other = new _SemVer(other, this.options); + if (!versionSpec) { + throw new Error("versionSpec parameter is required"); + } + arch = arch || os.arch(); + if (!isExplicitVersion(versionSpec)) { + const localVersions = findAllVersions(toolName, arch); + const match = evaluateVersions(localVersions, versionSpec); + versionSpec = match; + } + let toolPath = ""; + if (versionSpec) { + versionSpec = semver.clean(versionSpec) || ""; + const cachePath = path3.join(_getCacheDirectory(), toolName, versionSpec, arch); + core3.debug(`checking cache: ${cachePath}`); + if (fs2.existsSync(cachePath) && fs2.existsSync(`${cachePath}.complete`)) { + core3.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + toolPath = cachePath; + } else { + core3.debug("not found"); } - let i = 0; - do { - const a = this.build[i]; - const b = other.build[i]; - debug("prerelease compare", i, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i); } - // preminor will bump the version up to the next minor release, and immediately - // down to pre-release. premajor and prepatch work the same way. - inc(release, identifier, identifierBase) { - switch (release) { - case "premajor": - this.prerelease.length = 0; - this.patch = 0; - this.minor = 0; - this.major++; - this.inc("pre", identifier, identifierBase); - break; - case "preminor": - this.prerelease.length = 0; - this.patch = 0; - this.minor++; - this.inc("pre", identifier, identifierBase); - break; - case "prepatch": - this.prerelease.length = 0; - this.inc("patch", identifier, identifierBase); - this.inc("pre", identifier, identifierBase); - break; - case "prerelease": - if (this.prerelease.length === 0) { - this.inc("patch", identifier, identifierBase); - } - this.inc("pre", identifier, identifierBase); - break; - case "major": - if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { - this.major++; - } - this.minor = 0; - this.patch = 0; - this.prerelease = []; - break; - case "minor": - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++; - } - this.patch = 0; - this.prerelease = []; - break; - case "patch": - if (this.prerelease.length === 0) { - this.patch++; - } - this.prerelease = []; - break; - case "pre": { - const base = Number(identifierBase) ? 1 : 0; - if (!identifier && identifierBase === false) { - throw new Error("invalid increment argument: identifier is empty"); - } - if (this.prerelease.length === 0) { - this.prerelease = [base]; - } else { - let i = this.prerelease.length; - while (--i >= 0) { - if (typeof this.prerelease[i] === "number") { - this.prerelease[i]++; - i = -2; - } - } - if (i === -1) { - if (identifier === this.prerelease.join(".") && identifierBase === false) { - throw new Error("invalid increment argument: identifier already exists"); - } - this.prerelease.push(base); - } - } - if (identifier) { - let prerelease = [identifier, base]; - if (identifierBase === false) { - prerelease = [identifier]; - } - if (compareIdentifiers(this.prerelease[0], identifier) === 0) { - if (isNaN(this.prerelease[1])) { - this.prerelease = prerelease; - } - } else { - this.prerelease = prerelease; - } + return toolPath; + } + exports2.find = find2; + function findAllVersions(toolName, arch) { + const versions = []; + arch = arch || os.arch(); + const toolPath = path3.join(_getCacheDirectory(), toolName); + if (fs2.existsSync(toolPath)) { + const children = fs2.readdirSync(toolPath); + for (const child of children) { + if (isExplicitVersion(child)) { + const fullPath = path3.join(toolPath, child, arch || ""); + if (fs2.existsSync(fullPath) && fs2.existsSync(`${fullPath}.complete`)) { + versions.push(child); } + } + } + } + return versions; + } + exports2.findAllVersions = findAllVersions; + function getManifestFromRepo(owner, repo, auth, branch = "master") { + return __awaiter(this, void 0, void 0, function* () { + let releases = []; + const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; + const http = new httpm.HttpClient("tool-cache"); + const headers = {}; + if (auth) { + core3.debug("set auth"); + headers.authorization = auth; + } + const response = yield http.getJson(treeUrl, headers); + if (!response.result) { + return releases; + } + let manifestUrl = ""; + for (const item of response.result.tree) { + if (item.path === "versions-manifest.json") { + manifestUrl = item.url; break; } - default: - throw new Error(`invalid increment argument: ${release}`); } - this.raw = this.format(); - if (this.build.length) { - this.raw += `+${this.build.join(".")}`; + headers["accept"] = "application/vnd.github.VERSION.raw"; + let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); + if (versionsRaw) { + versionsRaw = versionsRaw.replace(/^\uFEFF/, ""); + try { + releases = JSON.parse(versionsRaw); + } catch (_a) { + core3.debug("Invalid json"); + } + } + return releases; + }); + } + exports2.getManifestFromRepo = getManifestFromRepo; + function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { + return __awaiter(this, void 0, void 0, function* () { + const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); + return match; + }); + } + exports2.findFromManifest = findFromManifest; + function _createExtractFolder(dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!dest) { + dest = path3.join(_getTempDirectory(), v4_1.default()); + } + yield io.mkdirP(dest); + return dest; + }); + } + function _createToolPath(tool, version3, arch) { + return __awaiter(this, void 0, void 0, function* () { + const folderPath = path3.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); + core3.debug(`destination ${folderPath}`); + const markerPath = `${folderPath}.complete`; + yield io.rmRF(folderPath); + yield io.rmRF(markerPath); + yield io.mkdirP(folderPath); + return folderPath; + }); + } + function _completeToolPath(tool, version3, arch) { + const folderPath = path3.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); + const markerPath = `${folderPath}.complete`; + fs2.writeFileSync(markerPath, ""); + core3.debug("finished caching tool"); + } + function isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec) || ""; + core3.debug(`isExplicit: ${c}`); + const valid = semver.valid(c) != null; + core3.debug(`explicit? ${valid}`); + return valid; + } + exports2.isExplicitVersion = isExplicitVersion; + function evaluateVersions(versions, versionSpec) { + let version3 = ""; + core3.debug(`evaluating ${versions.length} versions`); + versions = versions.sort((a, b) => { + if (semver.gt(a, b)) { + return 1; + } + return -1; + }); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version3 = potential; + break; } - return this; } - }; - module2.exports = SemVer3; + if (version3) { + core3.debug(`matched: ${version3}`); + } else { + core3.debug("match not found"); + } + return version3; + } + exports2.evaluateVersions = evaluateVersions; + function _getCacheDirectory() { + const cacheDirectory = process.env["RUNNER_TOOL_CACHE"] || ""; + assert_1.ok(cacheDirectory, "Expected RUNNER_TOOL_CACHE to be defined"); + return cacheDirectory; + } + function _getTempDirectory() { + const tempDirectory = process.env["RUNNER_TEMP"] || ""; + assert_1.ok(tempDirectory, "Expected RUNNER_TEMP to be defined"); + return tempDirectory; + } + function _getGlobal(key, defaultValue) { + const value = global[key]; + return value !== void 0 ? value : defaultValue; + } + function _unique(values) { + return Array.from(new Set(values)); + } } }); @@ -8790,6 +8790,7 @@ var ParseErrorCode; })(ParseErrorCode || (ParseErrorCode = {})); // src/main.ts +var import_semver3 = __toESM(require_semver()); var import_shell_quote2 = __toESM(require_shell_quote()); // src/helpers.ts @@ -8797,7 +8798,7 @@ var path = __toESM(require("node:path")); var core = __toESM(require_core()); var httpClient = __toESM(require_lib()); var tc = __toESM(require_tool_cache()); -var import_semver2 = __toESM(require_semver2()); +var import_semver2 = __toESM(require_semver()); var import_shell_quote = __toESM(require_shell_quote()); // package.json @@ -9818,7 +9819,7 @@ function union(...options) { } // src/schema.ts -var import_semver = __toESM(require_semver2()); +var import_semver = __toESM(require_semver()); var Position = object({ line: number(), character: number() @@ -9893,14 +9894,6 @@ var flagsWithoutCommentingSupport = /* @__PURE__ */ new Set([ "--createstub", "--dependencies" ]); -var flagsOverriddenByConfig = /* @__PURE__ */ new Set([ - "--pythonplatform", - "--pythonversion", - // pyright warns about these itself, but still takes the config file. - // Report these anyway, as the user should really stop configuring the action with these. - "--typeshedpath", - "--venvpath" -]); async function getArgs() { const pyrightInfo = await getPyrightInfo(); const pyrightPath = await downloadPyright(pyrightInfo); @@ -10092,7 +10085,7 @@ async function main() { process.chdir(workingDirectory); } try { - checkOverriddenFlags(args); + checkOverriddenFlags(pyrightVersion, args); } catch { } if (annotate.size === 0) { @@ -10186,7 +10179,23 @@ function diagnosticToString(diag, forCommand) { function pluralize(n, singular, plural) { return `${n} ${n === 1 ? singular : plural}`; } -function checkOverriddenFlags(args) { +var flagsOverriddenByConfig352AndAfter = /* @__PURE__ */ new Set([ + // pyright warns about these itself, but still takes the config file. + // Report these anyway, as the user should really stop configuring the action with these. + "--typeshedpath", + "--venvpath" +]); +var flagsOverriddenByConfig351AndBefore = /* @__PURE__ */ new Set([ + "--pythonplatform", + "--pythonversion", + ...flagsOverriddenByConfig352AndAfter +]); +function getFlagsOverriddenByConfig(version3) { + const pyrightVersion = new import_semver3.default(version3); + return pyrightVersion.compare("1.1.352") === -1 ? flagsOverriddenByConfig351AndBefore : flagsOverriddenByConfig352AndAfter; +} +function checkOverriddenFlags(version3, args) { + const flagsOverriddenByConfig = getFlagsOverriddenByConfig(version3); const overriddenFlags = new Set( args.map((arg) => arg.toLowerCase()).filter((arg) => flagsOverriddenByConfig.has(arg)) ); diff --git a/src/__snapshots__/main.test.ts.snap b/src/__snapshots__/main.test.ts.snap index 91671b7..4eaae2c 100644 --- a/src/__snapshots__/main.test.ts.snap +++ b/src/__snapshots__/main.test.ts.snap @@ -1082,6 +1082,326 @@ exports[`with overridden flags > implicit pyrightconfig.json > process.chdir 1`] ] `; +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > command.issueCommand 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > core.error 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > core.info 1`] = ` +[ + [ + "pyright 1.1.350, node v20.8.1, pyright-action 1.1.0", + ], + [ + "Working directory: /some/wd/is/deep", + ], + [ + "Running: /path/to/node --pythonplatform --pythonversion --typeshedpath --venvpath", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > core.setFailed 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > core.warning 1`] = ` +[ + [ + "pyrightconfig.json contains { pythonPlatform: 'Linux' }; --pythonplatform as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { pythonVersion: '3.9' }; --pythonversion as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { typeshedPath: '/path/to/typeshed' }; --typeshedpath as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { venvPath: '/path/to/venv' }; --venvpath as passed by pyright-action will have no effect.", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > cp.spawnSync 1`] = ` +[ + [ + "/path/to/node", + [ + "--pythonplatform", + "--pythonversion", + "--typeshedpath", + "--venvpath", + ], + { + "stdio": [ + "ignore", + "inherit", + "inherit", + ], + }, + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > fs.existsSync 1`] = ` +[ + [ + "pyrightconfig.json", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > fs.readFileSync 1`] = ` +[ + [ + "pyrightconfig.json", + "utf8", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.350 > process.chdir 1`] = ` +[ + [ + "/some/wd/is/deep", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > command.issueCommand 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > core.error 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > core.info 1`] = ` +[ + [ + "pyright 1.1.351, node v20.8.1, pyright-action 1.1.0", + ], + [ + "Working directory: /some/wd/is/deep", + ], + [ + "Running: /path/to/node --pythonplatform --pythonversion --typeshedpath --venvpath", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > core.setFailed 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > core.warning 1`] = ` +[ + [ + "pyrightconfig.json contains { pythonPlatform: 'Linux' }; --pythonplatform as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { pythonVersion: '3.9' }; --pythonversion as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { typeshedPath: '/path/to/typeshed' }; --typeshedpath as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { venvPath: '/path/to/venv' }; --venvpath as passed by pyright-action will have no effect.", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > cp.spawnSync 1`] = ` +[ + [ + "/path/to/node", + [ + "--pythonplatform", + "--pythonversion", + "--typeshedpath", + "--venvpath", + ], + { + "stdio": [ + "ignore", + "inherit", + "inherit", + ], + }, + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > fs.existsSync 1`] = ` +[ + [ + "pyrightconfig.json", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > fs.readFileSync 1`] = ` +[ + [ + "pyrightconfig.json", + "utf8", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.351 > process.chdir 1`] = ` +[ + [ + "/some/wd/is/deep", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > command.issueCommand 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > core.error 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > core.info 1`] = ` +[ + [ + "pyright 1.1.352, node v20.8.1, pyright-action 1.1.0", + ], + [ + "Working directory: /some/wd/is/deep", + ], + [ + "Running: /path/to/node --pythonplatform --pythonversion --typeshedpath --venvpath", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > core.setFailed 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > core.warning 1`] = ` +[ + [ + "pyrightconfig.json contains { typeshedPath: '/path/to/typeshed' }; --typeshedpath as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { venvPath: '/path/to/venv' }; --venvpath as passed by pyright-action will have no effect.", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > cp.spawnSync 1`] = ` +[ + [ + "/path/to/node", + [ + "--pythonplatform", + "--pythonversion", + "--typeshedpath", + "--venvpath", + ], + { + "stdio": [ + "ignore", + "inherit", + "inherit", + ], + }, + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > fs.existsSync 1`] = ` +[ + [ + "pyrightconfig.json", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > fs.readFileSync 1`] = ` +[ + [ + "pyrightconfig.json", + "utf8", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.352 > process.chdir 1`] = ` +[ + [ + "/some/wd/is/deep", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > command.issueCommand 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > core.error 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > core.info 1`] = ` +[ + [ + "pyright 1.1.353, node v20.8.1, pyright-action 1.1.0", + ], + [ + "Working directory: /some/wd/is/deep", + ], + [ + "Running: /path/to/node --pythonplatform --pythonversion --typeshedpath --venvpath", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > core.setFailed 1`] = `[]`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > core.warning 1`] = ` +[ + [ + "pyrightconfig.json contains { typeshedPath: '/path/to/typeshed' }; --typeshedpath as passed by pyright-action will have no effect.", + ], + [ + "pyrightconfig.json contains { venvPath: '/path/to/venv' }; --venvpath as passed by pyright-action will have no effect.", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > cp.spawnSync 1`] = ` +[ + [ + "/path/to/node", + [ + "--pythonplatform", + "--pythonversion", + "--typeshedpath", + "--venvpath", + ], + { + "stdio": [ + "ignore", + "inherit", + "inherit", + ], + }, + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > fs.existsSync 1`] = ` +[ + [ + "pyrightconfig.json", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > fs.readFileSync 1`] = ` +[ + [ + "pyrightconfig.json", + "utf8", + ], +] +`; + +exports[`with overridden flags > implicit pyrightconfig.json 1.1.353 > process.chdir 1`] = ` +[ + [ + "/some/wd/is/deep", + ], +] +`; + exports[`with overridden flags > pyproject.toml > command.issueCommand 1`] = `[]`; exports[`with overridden flags > pyproject.toml > core.error 1`] = `[]`; diff --git a/src/helpers.ts b/src/helpers.ts index c597846..1053e7e 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -42,17 +42,6 @@ const flagsWithoutCommentingSupport = new Set([ "--dependencies", ]); -// These settings have no effect when also set in a pyrightconfig.json. -// https://github.com/microsoft/pyright/issues/7330 -export const flagsOverriddenByConfig = new Set([ - "--pythonplatform", - "--pythonversion", - // pyright warns about these itself, but still takes the config file. - // Report these anyway, as the user should really stop configuring the action with these. - "--typeshedpath", - "--venvpath", -]); - // TODO: allow non-dashed forms to be passed as inputs. A long time ago, I // went with dashed names as pyright was not fully consistent, and dashes were // consistent with other GitHub actions. However, pyright has now gone the diff --git a/src/main.test.ts b/src/main.test.ts index 3ac0ee3..321812e 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -30,7 +30,7 @@ const mockedProcessCwd = vitest.spyOn(process, "cwd"); let currentWorkingDirectory = "/some/default/cwd"; -import { main } from "./main"; +import { flagsOverriddenByConfig351AndBefore, main } from "./main"; import type { Report } from "./schema"; beforeEach(() => { @@ -406,7 +406,7 @@ describe("with overridden flags", () => { }, }); - const flags = [...helpers.flagsOverriddenByConfig]; + const flags = [...flagsOverriddenByConfig351AndBefore]; beforeEach(() => { mockedCp.spawnSync.mockImplementation(() => ({ @@ -442,6 +442,98 @@ describe("with overridden flags", () => { await main(); }); + test("implicit pyrightconfig.json 1.1.350", async () => { + mockedHelpers.getArgs.mockResolvedValue({ + annotate: new Set(), + workingDirectory: wd, + pyrightVersion: "1.1.350", + args: flags, + }); + + mockedFs.readFileSync.mockImplementation( + ((p) => { + expect(p).toBe("pyrightconfig.json"); + return configJSON; + }) as typeof fs.readFileSync, + ); + + mockedFs.existsSync.mockImplementation((p) => { + expect(p).toBe("pyrightconfig.json"); + return true; + }); + + await main(); + }); + + test("implicit pyrightconfig.json 1.1.351", async () => { + mockedHelpers.getArgs.mockResolvedValue({ + annotate: new Set(), + workingDirectory: wd, + pyrightVersion: "1.1.351", + args: flags, + }); + + mockedFs.readFileSync.mockImplementation( + ((p) => { + expect(p).toBe("pyrightconfig.json"); + return configJSON; + }) as typeof fs.readFileSync, + ); + + mockedFs.existsSync.mockImplementation((p) => { + expect(p).toBe("pyrightconfig.json"); + return true; + }); + + await main(); + }); + + test("implicit pyrightconfig.json 1.1.352", async () => { + mockedHelpers.getArgs.mockResolvedValue({ + annotate: new Set(), + workingDirectory: wd, + pyrightVersion: "1.1.352", + args: flags, + }); + + mockedFs.readFileSync.mockImplementation( + ((p) => { + expect(p).toBe("pyrightconfig.json"); + return configJSON; + }) as typeof fs.readFileSync, + ); + + mockedFs.existsSync.mockImplementation((p) => { + expect(p).toBe("pyrightconfig.json"); + return true; + }); + + await main(); + }); + + test("implicit pyrightconfig.json 1.1.353", async () => { + mockedHelpers.getArgs.mockResolvedValue({ + annotate: new Set(), + workingDirectory: wd, + pyrightVersion: "1.1.353", + args: flags, + }); + + mockedFs.readFileSync.mockImplementation( + ((p) => { + expect(p).toBe("pyrightconfig.json"); + return configJSON; + }) as typeof fs.readFileSync, + ); + + mockedFs.existsSync.mockImplementation((p) => { + expect(p).toBe("pyrightconfig.json"); + return true; + }); + + await main(); + }); + test("explicit pyrightconfig.json", async () => { mockedHelpers.getArgs.mockResolvedValue({ annotate: new Set(), diff --git a/src/main.ts b/src/main.ts index 97304f8..6ddf14b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,9 +8,10 @@ import * as core from "@actions/core"; import * as command from "@actions/core/lib/command"; import * as TOML from "@iarna/toml"; import * as JSONC from "jsonc-parser"; +import SemVer from "semver/classes/semver"; import { quote } from "shell-quote"; -import { flagsOverriddenByConfig, getActionVersion, getArgs, getNodeInfo, type NodeInfo } from "./helpers"; +import { getActionVersion, getArgs, getNodeInfo, type NodeInfo } from "./helpers"; import { type Diagnostic, isEmptyRange, parseReport } from "./schema"; function printInfo(pyrightVersion: string, node: NodeInfo, cwd: string, args: readonly string[]) { @@ -28,7 +29,7 @@ export async function main() { } try { - checkOverriddenFlags(args); + checkOverriddenFlags(pyrightVersion, args); } catch { // Just ignore. } @@ -146,7 +147,31 @@ function pluralize(n: number, singular: string, plural: string) { return `${n} ${n === 1 ? singular : plural}`; } -function checkOverriddenFlags(args: readonly string[]) { +const flagsOverriddenByConfig352AndAfter = new Set([ + // pyright warns about these itself, but still takes the config file. + // Report these anyway, as the user should really stop configuring the action with these. + "--typeshedpath", + "--venvpath", +]); + +// These settings have no effect when also set in a pyrightconfig.json. +// https://github.com/microsoft/pyright/issues/7330 +export const flagsOverriddenByConfig351AndBefore = new Set([ + "--pythonplatform", + "--pythonversion", + ...flagsOverriddenByConfig352AndAfter, +]); + +function getFlagsOverriddenByConfig(version: string): ReadonlySet { + const pyrightVersion = new SemVer(version); + return pyrightVersion.compare("1.1.352") === -1 + ? flagsOverriddenByConfig351AndBefore + : flagsOverriddenByConfig352AndAfter; +} + +function checkOverriddenFlags(version: string, args: readonly string[]) { + const flagsOverriddenByConfig = getFlagsOverriddenByConfig(version); + const overriddenFlags = new Set( args.map((arg) => arg.toLowerCase()).filter((arg) => flagsOverriddenByConfig.has(arg)), );