From 546aac70e33afdbefb0a3a04dcb72b8e598e809c Mon Sep 17 00:00:00 2001 From: panticmilos Date: Sun, 20 Nov 2022 18:14:07 +0100 Subject: [PATCH 01/36] Add stable and oldstable aliases --- .github/workflows/versions.yml | 32 + .gitignore | 4 + dist/cache-save/index.js | 1677 ++++++++++++------------------- dist/setup/index.js | 1712 +++++++++++++------------------- src/installer.ts | 11 +- src/main.ts | 41 +- 6 files changed, 1427 insertions(+), 2050 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index faaa439ea..e724d3b01 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -12,6 +12,38 @@ on: - cron: 0 0 * * * jobs: + stable: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: x64 + - name: Verify Go + run: go version + + oldstable: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: x64 + - name: Verify Go + run: go version + local-cache: name: Setup local-cache version runs-on: ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index f45a61fdc..422a3b2f7 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,7 @@ typings/ # DynamoDB Local files .dynamodb/ + +.vscode + +release.txt \ No newline at end of file diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 10c4ddceb..51c13a21e 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -2489,9 +2489,13 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); } - command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2509,7 +2513,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueFileCommand('PATH', inputPath); + file_command_1.issueCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2549,10 +2553,7 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - if (options && options.trimWhitespace === false) { - return inputs; - } - return inputs.map(input => input.trim()); + return inputs; } exports.getMultilineInput = getMultilineInput; /** @@ -2585,12 +2586,8 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { - const filePath = process.env['GITHUB_OUTPUT'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); - } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; /** @@ -2719,11 +2716,7 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - const filePath = process.env['GITHUB_STATE'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); - } - command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('save-state', { name }, value); } exports.saveState = saveState; /** @@ -2742,23 +2735,6 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; -/** - * Summary exports - */ -var summary_1 = __nccwpck_require__(1327); -Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); -/** - * @deprecated use core.summary - */ -var summary_2 = __nccwpck_require__(1327); -Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); -/** - * Path exports - */ -var path_utils_1 = __nccwpck_require__(2981); -Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); -Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); -Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2789,14 +2765,13 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; +exports.issueCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); -const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueFileCommand(command, message) { +function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2808,22 +2783,7 @@ function issueFileCommand(command, message) { encoding: 'utf8' }); } -exports.issueFileCommand = issueFileCommand; -function prepareKeyValueMessage(key, value) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - const convertedValue = utils_1.toCommandValue(value); - // These should realistically never happen, but just in case someone finds a - // way to exploit uuid generation let's not allow keys or values that contain - // the delimiter. - if (key.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedValue.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; -} -exports.prepareKeyValueMessage = prepareKeyValueMessage; +exports.issueCommand = issueCommand; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2844,8 +2804,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(6255); -const auth_1 = __nccwpck_require__(5526); +const http_client_1 = __nccwpck_require__(3059); +const auth_1 = __nccwpck_require__(2402); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2912,361 +2872,6 @@ exports.OidcClient = OidcClient; /***/ }), -/***/ 2981: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; -const path = __importStar(__nccwpck_require__(1017)); -/** - * toPosixPath converts the given path to the posix form. On Windows, \\ will be - * replaced with /. - * - * @param pth. Path to transform. - * @return string Posix path. - */ -function toPosixPath(pth) { - return pth.replace(/[\\]/g, '/'); -} -exports.toPosixPath = toPosixPath; -/** - * toWin32Path converts the given path to the win32 form. On Linux, / will be - * replaced with \\. - * - * @param pth. Path to transform. - * @return string Win32 path. - */ -function toWin32Path(pth) { - return pth.replace(/[/]/g, '\\'); -} -exports.toWin32Path = toWin32Path; -/** - * toPlatformPath converts the given path to a platform-specific path. It does - * this by replacing instances of / and \ with the platform-specific path - * separator. - * - * @param pth The path to platformize. - * @return string The platform-specific path. - */ -function toPlatformPath(pth) { - return pth.replace(/[/\\]/g, path.sep); -} -exports.toPlatformPath = toPlatformPath; -//# sourceMappingURL=path-utils.js.map - -/***/ }), - -/***/ 1327: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; -const os_1 = __nccwpck_require__(2037); -const fs_1 = __nccwpck_require__(7147); -const { access, appendFile, writeFile } = fs_1.promises; -exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; -exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; -class Summary { - constructor() { - this._buffer = ''; - } - /** - * Finds the summary file path from the environment, rejects if env var is not found or file does not exist - * Also checks r/w permissions. - * - * @returns step summary file path - */ - filePath() { - return __awaiter(this, void 0, void 0, function* () { - if (this._filePath) { - return this._filePath; - } - const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; - if (!pathFromEnv) { - throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); - } - try { - yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); - } - catch (_a) { - throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); - } - this._filePath = pathFromEnv; - return this._filePath; - }); - } - /** - * Wraps content in an HTML tag, adding any HTML attributes - * - * @param {string} tag HTML tag to wrap - * @param {string | null} content content within the tag - * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add - * - * @returns {string} content wrapped in HTML element - */ - wrap(tag, content, attrs = {}) { - const htmlAttrs = Object.entries(attrs) - .map(([key, value]) => ` ${key}="${value}"`) - .join(''); - if (!content) { - return `<${tag}${htmlAttrs}>`; - } - return `<${tag}${htmlAttrs}>${content}`; - } - /** - * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. - * - * @param {SummaryWriteOptions} [options] (optional) options for write operation - * - * @returns {Promise} summary instance - */ - write(options) { - return __awaiter(this, void 0, void 0, function* () { - const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); - const filePath = yield this.filePath(); - const writeFunc = overwrite ? writeFile : appendFile; - yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); - return this.emptyBuffer(); - }); - } - /** - * Clears the summary buffer and wipes the summary file - * - * @returns {Summary} summary instance - */ - clear() { - return __awaiter(this, void 0, void 0, function* () { - return this.emptyBuffer().write({ overwrite: true }); - }); - } - /** - * Returns the current summary buffer as a string - * - * @returns {string} string of summary buffer - */ - stringify() { - return this._buffer; - } - /** - * If the summary buffer is empty - * - * @returns {boolen} true if the buffer is empty - */ - isEmptyBuffer() { - return this._buffer.length === 0; - } - /** - * Resets the summary buffer without writing to summary file - * - * @returns {Summary} summary instance - */ - emptyBuffer() { - this._buffer = ''; - return this; - } - /** - * Adds raw text to the summary buffer - * - * @param {string} text content to add - * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) - * - * @returns {Summary} summary instance - */ - addRaw(text, addEOL = false) { - this._buffer += text; - return addEOL ? this.addEOL() : this; - } - /** - * Adds the operating system-specific end-of-line marker to the buffer - * - * @returns {Summary} summary instance - */ - addEOL() { - return this.addRaw(os_1.EOL); - } - /** - * Adds an HTML codeblock to the summary buffer - * - * @param {string} code content to render within fenced code block - * @param {string} lang (optional) language to syntax highlight code - * - * @returns {Summary} summary instance - */ - addCodeBlock(code, lang) { - const attrs = Object.assign({}, (lang && { lang })); - const element = this.wrap('pre', this.wrap('code', code), attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML list to the summary buffer - * - * @param {string[]} items list of items to render - * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) - * - * @returns {Summary} summary instance - */ - addList(items, ordered = false) { - const tag = ordered ? 'ol' : 'ul'; - const listItems = items.map(item => this.wrap('li', item)).join(''); - const element = this.wrap(tag, listItems); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML table to the summary buffer - * - * @param {SummaryTableCell[]} rows table rows - * - * @returns {Summary} summary instance - */ - addTable(rows) { - const tableBody = rows - .map(row => { - const cells = row - .map(cell => { - if (typeof cell === 'string') { - return this.wrap('td', cell); - } - const { header, data, colspan, rowspan } = cell; - const tag = header ? 'th' : 'td'; - const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); - return this.wrap(tag, data, attrs); - }) - .join(''); - return this.wrap('tr', cells); - }) - .join(''); - const element = this.wrap('table', tableBody); - return this.addRaw(element).addEOL(); - } - /** - * Adds a collapsable HTML details element to the summary buffer - * - * @param {string} label text for the closed state - * @param {string} content collapsable content - * - * @returns {Summary} summary instance - */ - addDetails(label, content) { - const element = this.wrap('details', this.wrap('summary', label) + content); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML image tag to the summary buffer - * - * @param {string} src path to the image you to embed - * @param {string} alt text description of the image - * @param {SummaryImageOptions} options (optional) addition image attributes - * - * @returns {Summary} summary instance - */ - addImage(src, alt, options) { - const { width, height } = options || {}; - const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); - const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML section heading element - * - * @param {string} text heading text - * @param {number | string} [level=1] (optional) the heading level, default: 1 - * - * @returns {Summary} summary instance - */ - addHeading(text, level) { - const tag = `h${level}`; - const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) - ? tag - : 'h1'; - const element = this.wrap(allowedTag, text); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML thematic break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addSeparator() { - const element = this.wrap('hr', null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML line break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addBreak() { - const element = this.wrap('br', null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML blockquote to the summary buffer - * - * @param {string} text quote text - * @param {string} cite (optional) citation url - * - * @returns {Summary} summary instance - */ - addQuote(text, cite) { - const attrs = Object.assign({}, (cite && { cite })); - const element = this.wrap('blockquote', text, attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML anchor tag to the summary buffer - * - * @param {string} text link text/content - * @param {string} href hyperlink - * - * @returns {Summary} summary instance - */ - addLink(text, href) { - const element = this.wrap('a', text, { href }); - return this.addRaw(element).addEOL(); - } -} -const _summary = new Summary(); -/** - * @deprecated use `core.summary` - */ -exports.markdownSummary = _summary; -exports.summary = _summary; -//# sourceMappingURL=summary.js.map - -/***/ }), - /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -3314,649 +2919,679 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 8974: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2402: +/***/ ((__unused_webpack_module, exports) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +class BasicCredentialHandler { + constructor(username, password) { + this.username = username; + this.password = password; + } + prepareRequest(options) { + options.headers['Authorization'] = + 'Basic ' + + Buffer.from(this.username + ':' + this.password).toString('base64'); + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.BasicCredentialHandler = BasicCredentialHandler; +class BearerCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + options.headers['Authorization'] = 'Bearer ' + this.token; + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.BearerCredentialHandler = BearerCredentialHandler; +class PersonalAccessTokenCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + options.headers['Authorization'] = + 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -Object.defineProperty(exports, "v1", ({ - enumerable: true, - get: function () { - return _v.default; - } -})); -Object.defineProperty(exports, "v3", ({ - enumerable: true, - get: function () { - return _v2.default; - } -})); -Object.defineProperty(exports, "v4", ({ - enumerable: true, - get: function () { - return _v3.default; - } -})); -Object.defineProperty(exports, "v5", ({ - enumerable: true, - get: function () { - return _v4.default; - } -})); -Object.defineProperty(exports, "NIL", ({ - enumerable: true, - get: function () { - return _nil.default; - } -})); -Object.defineProperty(exports, "version", ({ - enumerable: true, - get: function () { - return _version.default; - } -})); -Object.defineProperty(exports, "validate", ({ - enumerable: true, - get: function () { - return _validate.default; - } -})); -Object.defineProperty(exports, "stringify", ({ - enumerable: true, - get: function () { - return _stringify.default; - } -})); -Object.defineProperty(exports, "parse", ({ - enumerable: true, - get: function () { - return _parse.default; - } -})); - -var _v = _interopRequireDefault(__nccwpck_require__(1595)); - -var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); - -var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); - -var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); - -var _nil = _interopRequireDefault(__nccwpck_require__(2381)); - -var _version = _interopRequireDefault(__nccwpck_require__(427)); - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -var _parse = _interopRequireDefault(__nccwpck_require__(6385)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), -/***/ 5842: +/***/ 3059: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function md5(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('md5').update(bytes).digest(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +const http = __nccwpck_require__(3685); +const https = __nccwpck_require__(5687); +const pm = __nccwpck_require__(4437); +let tunnel; +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; } - -var _default = md5; -exports["default"] = _default; - -/***/ }), - -/***/ 2381: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = '00000000-0000-0000-0000-000000000000'; -exports["default"] = _default; - -/***/ }), - -/***/ 6385: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function parse(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - let v; - const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - - arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; - arr[1] = v >>> 16 & 0xff; - arr[2] = v >>> 8 & 0xff; - arr[3] = v & 0xff; // Parse ........-####-....-....-............ - - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 0xff; // Parse ........-....-####-....-............ - - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 0xff; // Parse ........-....-....-####-............ - - arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; - arr[9] = v & 0xff; // Parse ........-....-....-....-############ - // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) - - arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; - arr[11] = v / 0x100000000 & 0xff; - arr[12] = v >>> 24 & 0xff; - arr[13] = v >>> 16 & 0xff; - arr[14] = v >>> 8 & 0xff; - arr[15] = v & 0xff; - return arr; +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); + } } - -var _default = parse; -exports["default"] = _default; - -/***/ }), - -/***/ 6230: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; -exports["default"] = _default; - -/***/ }), - -/***/ 9784: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = rng; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate - -let poolPtr = rnds8Pool.length; - -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - _crypto.default.randomFillSync(rnds8Pool); - - poolPtr = 0; - } - - return rnds8Pool.slice(poolPtr, poolPtr += 16); +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + }); + } } - -/***/ }), - -/***/ 8844: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('sha1').update(bytes).digest(); -} - -var _default = sha1; -exports["default"] = _default; - -/***/ }), - -/***/ 1458: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - */ -const byteToHex = []; - -for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 0x100).toString(16).substr(1)); -} - -function stringify(arr, offset = 0) { - // Note: Be careful editing this code! It's been tuned for performance - // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 - const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one - // of the following: - // - One or more input array values don't map to a hex octet (leading to - // "undefined" in the uuid) - // - Invalid input values for the RFC `version` or `variant` fields - - if (!(0, _validate.default)(uuid)) { - throw TypeError('Stringified UUID is invalid'); - } - - return uuid; +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + let parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; } - -var _default = stringify; -exports["default"] = _default; - -/***/ }), - -/***/ 1595: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(9784)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html -let _nodeId; - -let _clockseq; // Previous uuid creation time - - -let _lastMSecs = 0; -let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details - -function v1(options, buf, offset) { - let i = buf && offset || 0; - const b = buf || new Array(16); - options = options || {}; - let node = options.node || _nodeId; - let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not - // specified. We do this lazily to minimize issues related to insufficient - // system entropy. See #189 - - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || _rng.default)(); - - if (node == null) { - // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) - node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } } - - if (clockseq == null) { - // Per 4.2.2, randomize (14 bit) clockseq - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + options(requestUrl, additionalHeaders) { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); } - } // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - - - let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - - let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) - - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression - - if (dt < 0 && options.clockseq === undefined) { - clockseq = clockseq + 1 & 0x3fff; - } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - - - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } // Per 4.2.1.2 Throw error if too many uuids are requested - - - if (nsecs >= 10000) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); - } - - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - - msecs += 12219292800000; // `time_low` - - const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; // `time_mid` - - const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; // `time_high_and_version` - - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - - b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - - b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - - b[i++] = clockseq & 0xff; // `node` - - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } - - return buf || (0, _stringify.default)(b); -} - -var _default = v1; -exports["default"] = _default; - -/***/ }), - -/***/ 6993: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5920)); - -var _md = _interopRequireDefault(__nccwpck_require__(5842)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v3 = (0, _v.default)('v3', 0x30, _md.default); -var _default = v3; -exports["default"] = _default; - -/***/ }), - -/***/ 5920: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = _default; -exports.URL = exports.DNS = void 0; - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -var _parse = _interopRequireDefault(__nccwpck_require__(6385)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); // UTF8 escape - - const bytes = []; - - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); - } - - return bytes; -} - -const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; -exports.DNS = DNS; -const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; -exports.URL = URL; - -function _default(name, version, hashfunc) { - function generateUUID(value, namespace, buf, offset) { - if (typeof value === 'string') { - value = stringToBytes(value); + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + } + del(requestUrl, additionalHeaders) { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + } + patch(requestUrl, data, additionalHeaders) { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + let res = await this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.'); + } + let parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + while (numTries < maxTries) { + response = await this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i]; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + let parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = await this.requestRaw(info, data); + redirectsRemaining--; + } + if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + await response.readBody(); + await this._performExponentialBackoff(numTries); + } + } + return response; + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return new Promise((resolve, reject) => { + let callbackForResult = function (err, res) { + if (err) { + reject(err); + } + resolve(res); + }; + this.requestRawWithCallback(info, data, callbackForResult); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket; + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + let handleResult = (err, res) => { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + }; + let req = info.httpModule.request(info.options, (msg) => { + let res = new HttpClientResponse(msg); + handleResult(null, res); + }); + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error('Request timeout: ' + info.options.path), null); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err, null); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); + } + else { + req.end(); + } + } + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options); + }); + } + return info; + } + _mergeHeaders(headers) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + } + return lowercaseKeys(headers || {}); + } + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; } - - if (typeof namespace === 'string') { - namespace = (0, _parse.default)(namespace); + _getAgent(parsedUrl) { + let agent; + let proxyUrl = pm.getProxyUrl(parsedUrl); + let useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (!!this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __nccwpck_require__(4294); + } + const agentOptions = { + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + ...((proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + }), + host: proxyUrl.hostname, + port: proxyUrl.port + } + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; } - - if (namespace.length !== 16) { - throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); - } // Compute hash of namespace and value, Per 4.3 - // Future: Use spread syntax when supported on all platforms, e.g. `bytes = - // hashfunc([...namespace, ... value])` - - - let bytes = new Uint8Array(16 + value.length); - bytes.set(namespace); - bytes.set(value, namespace.length); - bytes = hashfunc(bytes); - bytes[6] = bytes[6] & 0x0f | version; - bytes[8] = bytes[8] & 0x3f | 0x80; - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } - - return buf; + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); } - - return (0, _stringify.default)(bytes); - } // Function#name is not settable on some platforms (#270) - - - try { - generateUUID.name = name; // eslint-disable-next-line no-empty - } catch (err) {} // For CommonJS default export support - - - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; -} - -/***/ }), - -/***/ 1472: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(9784)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function v4(options, buf, offset) { - options = options || {}; - - const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - - - rnds[6] = rnds[6] & 0x0f | 0x40; - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode; + const response = { + statusCode: statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode == HttpCodes.NotFound) { + resolve(response); + } + let obj; + let contents; + // get the result from the body + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; + } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + }); } - - return buf; - } - - return (0, _stringify.default)(rnds); } +exports.HttpClient = HttpClient; -var _default = v4; -exports["default"] = _default; - -/***/ }), - -/***/ 6217: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5920)); - -var _sha = _interopRequireDefault(__nccwpck_require__(8844)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v5 = (0, _v.default)('v5', 0x50, _sha.default); -var _default = v5; -exports["default"] = _default; /***/ }), -/***/ 2609: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 4437: +/***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _regex = _interopRequireDefault(__nccwpck_require__(6230)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function validate(uuid) { - return typeof uuid === 'string' && _regex.default.test(uuid); +Object.defineProperty(exports, "__esModule", ({ value: true })); +function getProxyUrl(reqUrl) { + let usingSsl = reqUrl.protocol === 'https:'; + let proxyUrl; + if (checkBypass(reqUrl)) { + return proxyUrl; + } + let proxyVar; + if (usingSsl) { + proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; + } + else { + proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; + } + if (proxyVar) { + proxyUrl = new URL(proxyVar); + } + return proxyUrl; } - -var _default = validate; -exports["default"] = _default; - -/***/ }), - -/***/ 427: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function version(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - return parseInt(uuid.substr(14, 1), 16); +exports.getProxyUrl = getProxyUrl; +function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false; + } + let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; + if (!noProxy) { + return false; + } + // Determine the request port + let reqPort; + if (reqUrl.port) { + reqPort = Number(reqUrl.port); + } + else if (reqUrl.protocol === 'http:') { + reqPort = 80; + } + else if (reqUrl.protocol === 'https:') { + reqPort = 443; + } + // Format the request hostname and hostname with port + let upperReqHosts = [reqUrl.hostname.toUpperCase()]; + if (typeof reqPort === 'number') { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + } + // Compare request host against noproxy + for (let upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { + if (upperReqHosts.some(x => x === upperNoProxyItem)) { + return true; + } + } + return false; } +exports.checkBypass = checkBypass; -var _default = version; -exports["default"] = _default; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 217a6ff1e..a3d96bd90 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -2489,9 +2489,13 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); } - command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2509,7 +2513,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueFileCommand('PATH', inputPath); + file_command_1.issueCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2549,10 +2553,7 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - if (options && options.trimWhitespace === false) { - return inputs; - } - return inputs.map(input => input.trim()); + return inputs; } exports.getMultilineInput = getMultilineInput; /** @@ -2585,12 +2586,8 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { - const filePath = process.env['GITHUB_OUTPUT'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); - } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; /** @@ -2719,11 +2716,7 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - const filePath = process.env['GITHUB_STATE'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); - } - command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('save-state', { name }, value); } exports.saveState = saveState; /** @@ -2742,23 +2735,6 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; -/** - * Summary exports - */ -var summary_1 = __nccwpck_require__(1327); -Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); -/** - * @deprecated use core.summary - */ -var summary_2 = __nccwpck_require__(1327); -Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); -/** - * Path exports - */ -var path_utils_1 = __nccwpck_require__(2981); -Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); -Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); -Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2789,14 +2765,13 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; +exports.issueCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); -const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueFileCommand(command, message) { +function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2808,22 +2783,7 @@ function issueFileCommand(command, message) { encoding: 'utf8' }); } -exports.issueFileCommand = issueFileCommand; -function prepareKeyValueMessage(key, value) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - const convertedValue = utils_1.toCommandValue(value); - // These should realistically never happen, but just in case someone finds a - // way to exploit uuid generation let's not allow keys or values that contain - // the delimiter. - if (key.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedValue.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; -} -exports.prepareKeyValueMessage = prepareKeyValueMessage; +exports.issueCommand = issueCommand; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2844,8 +2804,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(6255); -const auth_1 = __nccwpck_require__(5526); +const http_client_1 = __nccwpck_require__(3059); +const auth_1 = __nccwpck_require__(2402); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2912,361 +2872,6 @@ exports.OidcClient = OidcClient; /***/ }), -/***/ 2981: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; -const path = __importStar(__nccwpck_require__(1017)); -/** - * toPosixPath converts the given path to the posix form. On Windows, \\ will be - * replaced with /. - * - * @param pth. Path to transform. - * @return string Posix path. - */ -function toPosixPath(pth) { - return pth.replace(/[\\]/g, '/'); -} -exports.toPosixPath = toPosixPath; -/** - * toWin32Path converts the given path to the win32 form. On Linux, / will be - * replaced with \\. - * - * @param pth. Path to transform. - * @return string Win32 path. - */ -function toWin32Path(pth) { - return pth.replace(/[/]/g, '\\'); -} -exports.toWin32Path = toWin32Path; -/** - * toPlatformPath converts the given path to a platform-specific path. It does - * this by replacing instances of / and \ with the platform-specific path - * separator. - * - * @param pth The path to platformize. - * @return string The platform-specific path. - */ -function toPlatformPath(pth) { - return pth.replace(/[/\\]/g, path.sep); -} -exports.toPlatformPath = toPlatformPath; -//# sourceMappingURL=path-utils.js.map - -/***/ }), - -/***/ 1327: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; -const os_1 = __nccwpck_require__(2037); -const fs_1 = __nccwpck_require__(7147); -const { access, appendFile, writeFile } = fs_1.promises; -exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; -exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; -class Summary { - constructor() { - this._buffer = ''; - } - /** - * Finds the summary file path from the environment, rejects if env var is not found or file does not exist - * Also checks r/w permissions. - * - * @returns step summary file path - */ - filePath() { - return __awaiter(this, void 0, void 0, function* () { - if (this._filePath) { - return this._filePath; - } - const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; - if (!pathFromEnv) { - throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); - } - try { - yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); - } - catch (_a) { - throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); - } - this._filePath = pathFromEnv; - return this._filePath; - }); - } - /** - * Wraps content in an HTML tag, adding any HTML attributes - * - * @param {string} tag HTML tag to wrap - * @param {string | null} content content within the tag - * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add - * - * @returns {string} content wrapped in HTML element - */ - wrap(tag, content, attrs = {}) { - const htmlAttrs = Object.entries(attrs) - .map(([key, value]) => ` ${key}="${value}"`) - .join(''); - if (!content) { - return `<${tag}${htmlAttrs}>`; - } - return `<${tag}${htmlAttrs}>${content}`; - } - /** - * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. - * - * @param {SummaryWriteOptions} [options] (optional) options for write operation - * - * @returns {Promise} summary instance - */ - write(options) { - return __awaiter(this, void 0, void 0, function* () { - const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); - const filePath = yield this.filePath(); - const writeFunc = overwrite ? writeFile : appendFile; - yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); - return this.emptyBuffer(); - }); - } - /** - * Clears the summary buffer and wipes the summary file - * - * @returns {Summary} summary instance - */ - clear() { - return __awaiter(this, void 0, void 0, function* () { - return this.emptyBuffer().write({ overwrite: true }); - }); - } - /** - * Returns the current summary buffer as a string - * - * @returns {string} string of summary buffer - */ - stringify() { - return this._buffer; - } - /** - * If the summary buffer is empty - * - * @returns {boolen} true if the buffer is empty - */ - isEmptyBuffer() { - return this._buffer.length === 0; - } - /** - * Resets the summary buffer without writing to summary file - * - * @returns {Summary} summary instance - */ - emptyBuffer() { - this._buffer = ''; - return this; - } - /** - * Adds raw text to the summary buffer - * - * @param {string} text content to add - * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) - * - * @returns {Summary} summary instance - */ - addRaw(text, addEOL = false) { - this._buffer += text; - return addEOL ? this.addEOL() : this; - } - /** - * Adds the operating system-specific end-of-line marker to the buffer - * - * @returns {Summary} summary instance - */ - addEOL() { - return this.addRaw(os_1.EOL); - } - /** - * Adds an HTML codeblock to the summary buffer - * - * @param {string} code content to render within fenced code block - * @param {string} lang (optional) language to syntax highlight code - * - * @returns {Summary} summary instance - */ - addCodeBlock(code, lang) { - const attrs = Object.assign({}, (lang && { lang })); - const element = this.wrap('pre', this.wrap('code', code), attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML list to the summary buffer - * - * @param {string[]} items list of items to render - * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) - * - * @returns {Summary} summary instance - */ - addList(items, ordered = false) { - const tag = ordered ? 'ol' : 'ul'; - const listItems = items.map(item => this.wrap('li', item)).join(''); - const element = this.wrap(tag, listItems); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML table to the summary buffer - * - * @param {SummaryTableCell[]} rows table rows - * - * @returns {Summary} summary instance - */ - addTable(rows) { - const tableBody = rows - .map(row => { - const cells = row - .map(cell => { - if (typeof cell === 'string') { - return this.wrap('td', cell); - } - const { header, data, colspan, rowspan } = cell; - const tag = header ? 'th' : 'td'; - const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); - return this.wrap(tag, data, attrs); - }) - .join(''); - return this.wrap('tr', cells); - }) - .join(''); - const element = this.wrap('table', tableBody); - return this.addRaw(element).addEOL(); - } - /** - * Adds a collapsable HTML details element to the summary buffer - * - * @param {string} label text for the closed state - * @param {string} content collapsable content - * - * @returns {Summary} summary instance - */ - addDetails(label, content) { - const element = this.wrap('details', this.wrap('summary', label) + content); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML image tag to the summary buffer - * - * @param {string} src path to the image you to embed - * @param {string} alt text description of the image - * @param {SummaryImageOptions} options (optional) addition image attributes - * - * @returns {Summary} summary instance - */ - addImage(src, alt, options) { - const { width, height } = options || {}; - const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); - const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML section heading element - * - * @param {string} text heading text - * @param {number | string} [level=1] (optional) the heading level, default: 1 - * - * @returns {Summary} summary instance - */ - addHeading(text, level) { - const tag = `h${level}`; - const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) - ? tag - : 'h1'; - const element = this.wrap(allowedTag, text); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML thematic break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addSeparator() { - const element = this.wrap('hr', null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML line break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addBreak() { - const element = this.wrap('br', null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML blockquote to the summary buffer - * - * @param {string} text quote text - * @param {string} cite (optional) citation url - * - * @returns {Summary} summary instance - */ - addQuote(text, cite) { - const attrs = Object.assign({}, (cite && { cite })); - const element = this.wrap('blockquote', text, attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML anchor tag to the summary buffer - * - * @param {string} text link text/content - * @param {string} href hyperlink - * - * @returns {Summary} summary instance - */ - addLink(text, href) { - const element = this.wrap('a', text, { href }); - return this.addRaw(element).addEOL(); - } -} -const _summary = new Summary(); -/** - * @deprecated use `core.summary` - */ -exports.markdownSummary = _summary; -exports.summary = _summary; -//# sourceMappingURL=summary.js.map - -/***/ }), - /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -3314,649 +2919,679 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 8974: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -Object.defineProperty(exports, "v1", ({ - enumerable: true, - get: function () { - return _v.default; - } -})); -Object.defineProperty(exports, "v3", ({ - enumerable: true, - get: function () { - return _v2.default; - } -})); -Object.defineProperty(exports, "v4", ({ - enumerable: true, - get: function () { - return _v3.default; - } -})); -Object.defineProperty(exports, "v5", ({ - enumerable: true, - get: function () { - return _v4.default; - } -})); -Object.defineProperty(exports, "NIL", ({ - enumerable: true, - get: function () { - return _nil.default; - } -})); -Object.defineProperty(exports, "version", ({ - enumerable: true, - get: function () { - return _version.default; - } -})); -Object.defineProperty(exports, "validate", ({ - enumerable: true, - get: function () { - return _validate.default; - } -})); -Object.defineProperty(exports, "stringify", ({ - enumerable: true, - get: function () { - return _stringify.default; - } -})); -Object.defineProperty(exports, "parse", ({ - enumerable: true, - get: function () { - return _parse.default; - } -})); - -var _v = _interopRequireDefault(__nccwpck_require__(1595)); - -var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); - -var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); - -var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); - -var _nil = _interopRequireDefault(__nccwpck_require__(2381)); - -var _version = _interopRequireDefault(__nccwpck_require__(427)); - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -var _parse = _interopRequireDefault(__nccwpck_require__(6385)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/***/ }), - -/***/ 5842: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function md5(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('md5').update(bytes).digest(); -} - -var _default = md5; -exports["default"] = _default; - -/***/ }), - -/***/ 2381: +/***/ 2402: /***/ ((__unused_webpack_module, exports) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +class BasicCredentialHandler { + constructor(username, password) { + this.username = username; + this.password = password; + } + prepareRequest(options) { + options.headers['Authorization'] = + 'Basic ' + + Buffer.from(this.username + ':' + this.password).toString('base64'); + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.BasicCredentialHandler = BasicCredentialHandler; +class BearerCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + options.headers['Authorization'] = 'Bearer ' + this.token; + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.BearerCredentialHandler = BearerCredentialHandler; +class PersonalAccessTokenCredentialHandler { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options) { + options.headers['Authorization'] = + 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); + } + // This handler cannot handle 401 + canHandleAuthentication(response) { + return false; + } + handleAuthentication(httpClient, requestInfo, objs) { + return null; + } +} +exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = '00000000-0000-0000-0000-000000000000'; -exports["default"] = _default; /***/ }), -/***/ 6385: +/***/ 3059: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function parse(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - let v; - const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - - arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; - arr[1] = v >>> 16 & 0xff; - arr[2] = v >>> 8 & 0xff; - arr[3] = v & 0xff; // Parse ........-####-....-....-............ - - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 0xff; // Parse ........-....-####-....-............ - - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 0xff; // Parse ........-....-....-####-............ - - arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; - arr[9] = v & 0xff; // Parse ........-....-....-....-############ - // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) - - arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; - arr[11] = v / 0x100000000 & 0xff; - arr[12] = v >>> 24 & 0xff; - arr[13] = v >>> 16 & 0xff; - arr[14] = v >>> 8 & 0xff; - arr[15] = v & 0xff; - return arr; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const http = __nccwpck_require__(3685); +const https = __nccwpck_require__(5687); +const pm = __nccwpck_require__(4437); +let tunnel; +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; +} +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); + } +} +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + }); + } +} +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + let parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; +} +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } + } + options(requestUrl, additionalHeaders) { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + } + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + } + del(requestUrl, additionalHeaders) { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + } + patch(requestUrl, data, additionalHeaders) { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + let res = await this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.'); + } + let parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + while (numTries < maxTries) { + response = await this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i]; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + let parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = await this.requestRaw(info, data); + redirectsRemaining--; + } + if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + await response.readBody(); + await this._performExponentialBackoff(numTries); + } + } + return response; + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return new Promise((resolve, reject) => { + let callbackForResult = function (err, res) { + if (err) { + reject(err); + } + resolve(res); + }; + this.requestRawWithCallback(info, data, callbackForResult); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket; + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + let handleResult = (err, res) => { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + }; + let req = info.httpModule.request(info.options, (msg) => { + let res = new HttpClientResponse(msg); + handleResult(null, res); + }); + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error('Request timeout: ' + info.options.path), null); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err, null); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); + } + else { + req.end(); + } + } + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options); + }); + } + return info; + } + _mergeHeaders(headers) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + } + return lowercaseKeys(headers || {}); + } + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + let proxyUrl = pm.getProxyUrl(parsedUrl); + let useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (!!this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __nccwpck_require__(4294); + } + const agentOptions = { + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + ...((proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + }), + host: proxyUrl.hostname, + port: proxyUrl.port + } + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; + } + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); + } + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode; + const response = { + statusCode: statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode == HttpCodes.NotFound) { + resolve(response); + } + let obj; + let contents; + // get the result from the body + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; + } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + }); + } } +exports.HttpClient = HttpClient; -var _default = parse; -exports["default"] = _default; /***/ }), -/***/ 6230: +/***/ 4437: /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; -exports["default"] = _default; - -/***/ }), - -/***/ 9784: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = rng; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate - -let poolPtr = rnds8Pool.length; - -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - _crypto.default.randomFillSync(rnds8Pool); - - poolPtr = 0; - } - - return rnds8Pool.slice(poolPtr, poolPtr += 16); -} - -/***/ }), - -/***/ 8844: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('sha1').update(bytes).digest(); -} - -var _default = sha1; -exports["default"] = _default; - -/***/ }), - -/***/ 1458: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - */ -const byteToHex = []; - -for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 0x100).toString(16).substr(1)); -} - -function stringify(arr, offset = 0) { - // Note: Be careful editing this code! It's been tuned for performance - // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 - const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one - // of the following: - // - One or more input array values don't map to a hex octet (leading to - // "undefined" in the uuid) - // - Invalid input values for the RFC `version` or `variant` fields - - if (!(0, _validate.default)(uuid)) { - throw TypeError('Stringified UUID is invalid'); - } - - return uuid; -} - -var _default = stringify; -exports["default"] = _default; - -/***/ }), - -/***/ 1595: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(9784)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html -let _nodeId; - -let _clockseq; // Previous uuid creation time - - -let _lastMSecs = 0; -let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details - -function v1(options, buf, offset) { - let i = buf && offset || 0; - const b = buf || new Array(16); - options = options || {}; - let node = options.node || _nodeId; - let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not - // specified. We do this lazily to minimize issues related to insufficient - // system entropy. See #189 - - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || _rng.default)(); - - if (node == null) { - // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) - node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; +Object.defineProperty(exports, "__esModule", ({ value: true })); +function getProxyUrl(reqUrl) { + let usingSsl = reqUrl.protocol === 'https:'; + let proxyUrl; + if (checkBypass(reqUrl)) { + return proxyUrl; } - - if (clockseq == null) { - // Per 4.2.2, randomize (14 bit) clockseq - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + let proxyVar; + if (usingSsl) { + proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; } - } // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - - - let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - - let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) - - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression - - if (dt < 0 && options.clockseq === undefined) { - clockseq = clockseq + 1 & 0x3fff; - } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - - - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } // Per 4.2.1.2 Throw error if too many uuids are requested - - - if (nsecs >= 10000) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); - } - - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - - msecs += 12219292800000; // `time_low` - - const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; // `time_mid` - - const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; // `time_high_and_version` - - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - - b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - - b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - - b[i++] = clockseq & 0xff; // `node` - - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } - - return buf || (0, _stringify.default)(b); -} - -var _default = v1; -exports["default"] = _default; - -/***/ }), - -/***/ 6993: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5920)); - -var _md = _interopRequireDefault(__nccwpck_require__(5842)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v3 = (0, _v.default)('v3', 0x30, _md.default); -var _default = v3; -exports["default"] = _default; - -/***/ }), - -/***/ 5920: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = _default; -exports.URL = exports.DNS = void 0; - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -var _parse = _interopRequireDefault(__nccwpck_require__(6385)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); // UTF8 escape - - const bytes = []; - - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); - } - - return bytes; + else { + proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; + } + if (proxyVar) { + proxyUrl = new URL(proxyVar); + } + return proxyUrl; } - -const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; -exports.DNS = DNS; -const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; -exports.URL = URL; - -function _default(name, version, hashfunc) { - function generateUUID(value, namespace, buf, offset) { - if (typeof value === 'string') { - value = stringToBytes(value); +exports.getProxyUrl = getProxyUrl; +function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false; } - - if (typeof namespace === 'string') { - namespace = (0, _parse.default)(namespace); + let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; + if (!noProxy) { + return false; } - - if (namespace.length !== 16) { - throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); - } // Compute hash of namespace and value, Per 4.3 - // Future: Use spread syntax when supported on all platforms, e.g. `bytes = - // hashfunc([...namespace, ... value])` - - - let bytes = new Uint8Array(16 + value.length); - bytes.set(namespace); - bytes.set(value, namespace.length); - bytes = hashfunc(bytes); - bytes[6] = bytes[6] & 0x0f | version; - bytes[8] = bytes[8] & 0x3f | 0x80; - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } - - return buf; + // Determine the request port + let reqPort; + if (reqUrl.port) { + reqPort = Number(reqUrl.port); } - - return (0, _stringify.default)(bytes); - } // Function#name is not settable on some platforms (#270) - - - try { - generateUUID.name = name; // eslint-disable-next-line no-empty - } catch (err) {} // For CommonJS default export support - - - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; -} - -/***/ }), - -/***/ 1472: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(9784)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function v4(options, buf, offset) { - options = options || {}; - - const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - - - rnds[6] = rnds[6] & 0x0f | 0x40; - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; + else if (reqUrl.protocol === 'http:') { + reqPort = 80; } - - return buf; - } - - return (0, _stringify.default)(rnds); -} - -var _default = v4; -exports["default"] = _default; - -/***/ }), - -/***/ 6217: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5920)); - -var _sha = _interopRequireDefault(__nccwpck_require__(8844)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v5 = (0, _v.default)('v5', 0x50, _sha.default); -var _default = v5; -exports["default"] = _default; - -/***/ }), - -/***/ 2609: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _regex = _interopRequireDefault(__nccwpck_require__(6230)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function validate(uuid) { - return typeof uuid === 'string' && _regex.default.test(uuid); -} - -var _default = validate; -exports["default"] = _default; - -/***/ }), - -/***/ 427: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(2609)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function version(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - return parseInt(uuid.substr(14, 1), 16); + else if (reqUrl.protocol === 'https:') { + reqPort = 443; + } + // Format the request hostname and hostname with port + let upperReqHosts = [reqUrl.hostname.toUpperCase()]; + if (typeof reqPort === 'number') { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + } + // Compare request host against noproxy + for (let upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { + if (upperReqHosts.some(x => x === upperNoProxyItem)) { + return true; + } + } + return false; } +exports.checkBypass = checkBypass; -var _default = version; -exports["default"] = _default; /***/ }), @@ -63213,7 +62848,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63302,6 +62937,7 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch) { } }); } +exports.resolveVersionFromManifest = resolveVersionFromManifest; function installGoVersion(info, auth, arch) { return __awaiter(this, void 0, void 0, function* () { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); @@ -63341,7 +62977,13 @@ function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch let info = null; const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); core.info(`matching ${versionSpec}...`); - const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + let rel; + if (versionSpec === 'stable') { + rel = releases[0]; + } + else { + rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + } if (rel && rel.files.length > 0) { info = {}; info.type = 'manifest'; @@ -63511,7 +63153,7 @@ function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - const versionSpec = resolveVersionInput(); + let versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); let arch = core.getInput('architecture'); @@ -63522,6 +63164,9 @@ function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); + if (versionSpec === 'stable' || versionSpec === 'oldstable') { + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch); + } const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); @@ -63614,6 +63259,21 @@ function resolveVersionInput() { } return version; } +function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let resolvedVersion = yield installer.resolveVersionFromManifest('stable', true, auth, arch); + core.info(`Stable version resolved as ${resolvedVersion}`); + if (versionSpec === 'oldstable') { + if (resolvedVersion) { + const minorVersion = semver.minor(resolvedVersion); + const semverExpression = `<${semver.major(resolvedVersion)}.${minorVersion}.0`; + resolvedVersion = yield installer.resolveVersionFromManifest(semverExpression, true, auth, arch); + core.info(`Oldstable version resolved as ${resolvedVersion}`); + } + } + return resolvedVersion ? resolvedVersion : versionSpec; + }); +} /***/ }), diff --git a/src/installer.ts b/src/installer.ts index 94c5411dd..3897deb8a 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -114,7 +114,7 @@ export async function getGo( return downloadPath; } -async function resolveVersionFromManifest( +export async function resolveVersionFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, @@ -188,7 +188,14 @@ export async function getInfoFromManifest( 'main' ); core.info(`matching ${versionSpec}...`); - const rel = await tc.findFromManifest(versionSpec, stable, releases, arch); + + let rel: tc.IToolRelease | undefined; + + if (versionSpec === 'stable') { + rel = releases[0]; + } else { + rel = await tc.findFromManifest(versionSpec, stable, releases, arch); + } if (rel && rel.files.length > 0) { info = {}; diff --git a/src/main.ts b/src/main.ts index 1ddf51149..521b7a955 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,7 +15,7 @@ export async function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - const versionSpec = resolveVersionInput(); + let versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); @@ -31,6 +31,11 @@ export async function run() { let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); + + if (versionSpec === 'stable' || versionSpec === 'oldstable') { + versionSpec = await resolveStableVersionInput(versionSpec, auth, arch); + } + const installDir = await installer.getGo( versionSpec, checkLatest, @@ -143,3 +148,37 @@ function resolveVersionInput(): string { return version; } + +async function resolveStableVersionInput( + versionSpec: string, + auth: string | undefined, + arch = os.arch() +): Promise { + let resolvedVersion = await installer.resolveVersionFromManifest( + 'stable', + true, + auth, + arch + ); + + core.info(`Stable version resolved as ${resolvedVersion}`); + + if (versionSpec === 'oldstable') { + if (resolvedVersion) { + const minorVersion = semver.minor(resolvedVersion); + const semverExpression = `<${semver.major( + resolvedVersion + )}.${minorVersion}.0`; + resolvedVersion = await installer.resolveVersionFromManifest( + semverExpression, + true, + auth, + arch + ); + + core.info(`Oldstable version resolved as ${resolvedVersion}`); + } + } + + return resolvedVersion ? resolvedVersion : versionSpec; +} From 4fd17ff3759e4f4b0c3fc808871e05984c792abc Mon Sep 17 00:00:00 2001 From: panticmilos Date: Sun, 20 Nov 2022 18:19:55 +0100 Subject: [PATCH 02/36] Remove .gitignore changes --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 422a3b2f7..f45a61fdc 100644 --- a/.gitignore +++ b/.gitignore @@ -89,7 +89,3 @@ typings/ # DynamoDB Local files .dynamodb/ - -.vscode - -release.txt \ No newline at end of file From e0cb28be4c7bf958cf73a84e94b874f389b1a01c Mon Sep 17 00:00:00 2001 From: panticmilos Date: Sun, 20 Nov 2022 18:37:15 +0100 Subject: [PATCH 03/36] Update package lock json --- dist/cache-save/index.js | 1697 +++++++++++++++++++++++--------------- dist/setup/index.js | 1695 ++++++++++++++++++++++--------------- 2 files changed, 2061 insertions(+), 1331 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 51c13a21e..10c4ddceb 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -2489,13 +2489,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2513,7 +2509,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2553,7 +2549,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -2586,8 +2585,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -2716,7 +2719,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -2735,6 +2742,23 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; +/** + * Summary exports + */ +var summary_1 = __nccwpck_require__(1327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(1327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); +/** + * Path exports + */ +var path_utils_1 = __nccwpck_require__(2981); +Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); +Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); +Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2765,13 +2789,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2783,7 +2808,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2804,8 +2844,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(3059); -const auth_1 = __nccwpck_require__(2402); +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2872,6 +2912,361 @@ exports.OidcClient = OidcClient; /***/ }), +/***/ 2981: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(1017)); +/** + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. + * + * @param pth. Path to transform. + * @return string Posix path. + */ +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); +} +exports.toPosixPath = toPosixPath; +/** + * toWin32Path converts the given path to the win32 form. On Linux, / will be + * replaced with \\. + * + * @param pth. Path to transform. + * @return string Win32 path. + */ +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); +} +exports.toWin32Path = toWin32Path; +/** + * toPlatformPath converts the given path to a platform-specific path. It does + * this by replacing instances of / and \ with the platform-specific path + * separator. + * + * @param pth The path to platformize. + * @return string The platform-specific path. + */ +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); +} +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map + +/***/ }), + +/***/ 1327: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2037); +const fs_1 = __nccwpck_require__(7147); +const { access, appendFile, writeFile } = fs_1.promises; +exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { + constructor() { + this._buffer = ''; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } + catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ''; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, (lang && { lang })); + const element = this.wrap('pre', this.wrap('code', code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? 'ol' : 'ul'; + const listItems = items.map(item => this.wrap('li', item)).join(''); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows + .map(row => { + const cells = row + .map(cell => { + if (typeof cell === 'string') { + return this.wrap('td', cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? 'th' : 'td'; + const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); + return this.wrap(tag, data, attrs); + }) + .join(''); + return this.wrap('tr', cells); + }) + .join(''); + const element = this.wrap('table', tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap('details', this.wrap('summary', label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options) { + const { width, height } = options || {}; + const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); + const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) + ? tag + : 'h1'; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap('hr', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap('br', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, (cite && { cite })); + const element = this.wrap('blockquote', text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap('a', text, { href }); + return this.addRaw(element).addEOL(); + } +} +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -2919,679 +3314,649 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 2402: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -class BasicCredentialHandler { - constructor(username, password) { - this.username = username; - this.password = password; - } - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + - Buffer.from(this.username + ':' + this.password).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BasicCredentialHandler = BasicCredentialHandler; -class BearerCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = 'Bearer ' + this.token; - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BearerCredentialHandler = BearerCredentialHandler; -class PersonalAccessTokenCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; - - -/***/ }), - -/***/ 3059: +/***/ 8974: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const http = __nccwpck_require__(3685); -const https = __nccwpck_require__(5687); -const pm = __nccwpck_require__(4437); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } -} -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(1595)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); + +var _nil = _interopRequireDefault(__nccwpck_require__(2381)); + +var _version = _interopRequireDefault(__nccwpck_require__(427)); + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/***/ }), + +/***/ 5842: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); } -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); - } - } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); - } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); - } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __nccwpck_require__(4294); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - ...((proxyUrl.username || proxyUrl.password) && { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` - }), - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); - } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 2381: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 6385: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +var _default = parse; +exports["default"] = _default; + +/***/ }), + +/***/ 6230: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 9784: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 8844: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 1458: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; + +let _clockseq; // Previous uuid creation time + + +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 + + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); + + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + + + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression + + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + + + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested + + + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + + msecs += 12219292800000; // `time_low` + + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` + + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + + return buf || (0, _stringify.default)(b); } -exports.HttpClient = HttpClient; +var _default = v1; +exports["default"] = _default; /***/ }), -/***/ 4437: -/***/ ((__unused_webpack_module, exports) => { +/***/ 6993: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; - } - else { - proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; - } - if (proxyVar) { - proxyUrl = new URL(proxyVar); - } - return proxyUrl; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _md = _interopRequireDefault(__nccwpck_require__(5842)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), + +/***/ 5920: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; } -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; - if (!noProxy) { - return false; - } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; + + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy - .split(',') - .map(x => x.trim().toUpperCase()) - .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; - } + + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +/***/ }), + +/***/ 1472: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; } - return false; + + return buf; + } + + return (0, _stringify.default)(rnds); } -exports.checkBypass = checkBypass; +var _default = v4; +exports["default"] = _default; + +/***/ }), + +/***/ 6217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _sha = _interopRequireDefault(__nccwpck_require__(8844)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), + +/***/ 2609: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(6230)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + +/***/ }), + +/***/ 427: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + return parseInt(uuid.substr(14, 1), 16); +} + +var _default = version; +exports["default"] = _default; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index a3d96bd90..5c05a8f78 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -2489,13 +2489,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2513,7 +2509,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2553,7 +2549,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -2586,8 +2585,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -2716,7 +2719,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -2735,6 +2742,23 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; +/** + * Summary exports + */ +var summary_1 = __nccwpck_require__(1327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(1327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); +/** + * Path exports + */ +var path_utils_1 = __nccwpck_require__(2981); +Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); +Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); +Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2765,13 +2789,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2783,7 +2808,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2804,8 +2844,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(3059); -const auth_1 = __nccwpck_require__(2402); +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2872,6 +2912,361 @@ exports.OidcClient = OidcClient; /***/ }), +/***/ 2981: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(1017)); +/** + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. + * + * @param pth. Path to transform. + * @return string Posix path. + */ +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); +} +exports.toPosixPath = toPosixPath; +/** + * toWin32Path converts the given path to the win32 form. On Linux, / will be + * replaced with \\. + * + * @param pth. Path to transform. + * @return string Win32 path. + */ +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); +} +exports.toWin32Path = toWin32Path; +/** + * toPlatformPath converts the given path to a platform-specific path. It does + * this by replacing instances of / and \ with the platform-specific path + * separator. + * + * @param pth The path to platformize. + * @return string The platform-specific path. + */ +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); +} +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map + +/***/ }), + +/***/ 1327: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2037); +const fs_1 = __nccwpck_require__(7147); +const { access, appendFile, writeFile } = fs_1.promises; +exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { + constructor() { + this._buffer = ''; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } + catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ''; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, (lang && { lang })); + const element = this.wrap('pre', this.wrap('code', code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? 'ol' : 'ul'; + const listItems = items.map(item => this.wrap('li', item)).join(''); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows + .map(row => { + const cells = row + .map(cell => { + if (typeof cell === 'string') { + return this.wrap('td', cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? 'th' : 'td'; + const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); + return this.wrap(tag, data, attrs); + }) + .join(''); + return this.wrap('tr', cells); + }) + .join(''); + const element = this.wrap('table', tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap('details', this.wrap('summary', label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options) { + const { width, height } = options || {}; + const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); + const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) + ? tag + : 'h1'; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap('hr', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap('br', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, (cite && { cite })); + const element = this.wrap('blockquote', text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap('a', text, { href }); + return this.addRaw(element).addEOL(); + } +} +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -2919,679 +3314,649 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 2402: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -class BasicCredentialHandler { - constructor(username, password) { - this.username = username; - this.password = password; - } - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + - Buffer.from(this.username + ':' + this.password).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BasicCredentialHandler = BasicCredentialHandler; -class BearerCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = 'Bearer ' + this.token; - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BearerCredentialHandler = BearerCredentialHandler; -class PersonalAccessTokenCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; - - -/***/ }), - -/***/ 3059: +/***/ 8974: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const http = __nccwpck_require__(3685); -const https = __nccwpck_require__(5687); -const pm = __nccwpck_require__(4437); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } -} -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(1595)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); + +var _nil = _interopRequireDefault(__nccwpck_require__(2381)); + +var _version = _interopRequireDefault(__nccwpck_require__(427)); + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/***/ }), + +/***/ 5842: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); } -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 2381: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 6385: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; } -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); - } - } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); - } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); - } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __nccwpck_require__(4294); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - ...((proxyUrl.username || proxyUrl.password) && { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` - }), - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); - } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; + +var _default = parse; +exports["default"] = _default; + +/***/ }), + +/***/ 6230: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 9784: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 8844: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 1458: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; + +let _clockseq; // Previous uuid creation time + + +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 + + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); + + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + + + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression + + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + + + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested + + + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + + msecs += 12219292800000; // `time_low` + + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` + + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + + return buf || (0, _stringify.default)(b); } -exports.HttpClient = HttpClient; +var _default = v1; +exports["default"] = _default; /***/ }), -/***/ 4437: -/***/ ((__unused_webpack_module, exports) => { +/***/ 6993: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; - } - else { - proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; - } - if (proxyVar) { - proxyUrl = new URL(proxyVar); - } - return proxyUrl; + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _md = _interopRequireDefault(__nccwpck_require__(5842)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), + +/***/ 5920: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; } -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; - if (!noProxy) { - return false; - } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; + + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy - .split(',') - .map(x => x.trim().toUpperCase()) - .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; - } + + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +/***/ }), + +/***/ 1472: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; } - return false; + + return buf; + } + + return (0, _stringify.default)(rnds); } -exports.checkBypass = checkBypass; +var _default = v4; +exports["default"] = _default; + +/***/ }), + +/***/ 6217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _sha = _interopRequireDefault(__nccwpck_require__(8844)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), + +/***/ 2609: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(6230)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + +/***/ }), + +/***/ 427: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + return parseInt(uuid.substr(14, 1), 16); +} + +var _default = version; +exports["default"] = _default; /***/ }), From d33323e2b9d27945f1262711f59326f9290568e1 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Sun, 20 Nov 2022 18:46:41 +0100 Subject: [PATCH 04/36] Remove unnecessary variables --- dist/setup/index.js | 4 ++-- src/main.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 5c05a8f78..ccdd32268 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63630,8 +63630,8 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() core.info(`Stable version resolved as ${resolvedVersion}`); if (versionSpec === 'oldstable') { if (resolvedVersion) { - const minorVersion = semver.minor(resolvedVersion); - const semverExpression = `<${semver.major(resolvedVersion)}.${minorVersion}.0`; + // example: if version is 1.19.4, semver expression will be: <1.19.0 + const semverExpression = `<${semver.major(resolvedVersion)}.${semver.minor(resolvedVersion)}.0`; resolvedVersion = yield installer.resolveVersionFromManifest(semverExpression, true, auth, arch); core.info(`Oldstable version resolved as ${resolvedVersion}`); } diff --git a/src/main.ts b/src/main.ts index 521b7a955..9c2f3986b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -165,10 +165,11 @@ async function resolveStableVersionInput( if (versionSpec === 'oldstable') { if (resolvedVersion) { - const minorVersion = semver.minor(resolvedVersion); + // example: if version is 1.19.4, semver expression will be: <1.19.0 const semverExpression = `<${semver.major( resolvedVersion - )}.${minorVersion}.0`; + )}.${semver.minor(resolvedVersion)}.0`; + resolvedVersion = await installer.resolveVersionFromManifest( semverExpression, true, From 5552b45f54464a8db1ad3f83c74fc3ef645ca138 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Sun, 20 Nov 2022 19:13:39 +0100 Subject: [PATCH 05/36] Introduce new stable alias type --- src/installer.ts | 3 ++- src/main.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index 3897deb8a..d924eae9b 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -8,6 +8,7 @@ import fs from 'fs'; import os from 'os'; type InstallationType = 'dist' | 'manifest'; +export type StableAliasType = 'stable' | 'oldstable'; export interface IGoVersionFile { filename: string; @@ -175,7 +176,7 @@ export async function extractGoArchive(archivePath: string): Promise { } export async function getInfoFromManifest( - versionSpec: string, + versionSpec: string | StableAliasType, stable: boolean, auth: string | undefined, arch = os.arch() diff --git a/src/main.ts b/src/main.ts index 9c2f3986b..012088f52 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ import * as installer from './installer'; import * as semver from 'semver'; import path from 'path'; import {restoreCache} from './cache-restore'; -import {isGhes, isCacheFeatureAvailable} from './cache-utils'; +import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; @@ -150,7 +150,7 @@ function resolveVersionInput(): string { } async function resolveStableVersionInput( - versionSpec: string, + versionSpec: installer.StableAliasType, auth: string | undefined, arch = os.arch() ): Promise { From 317adaa2cbd2fe3f04bd4397884888305beec2c0 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 17:09:26 +0100 Subject: [PATCH 06/36] Apply PR suggestions --- __tests__/setup-go.test.ts | 3 ++ dist/setup/index.js | 76 ++++++++++++++++++++++++-------------- src/installer.ts | 43 +++++++++++---------- src/main.ts | 73 +++++++++++++++++++++--------------- src/utils.ts | 4 ++ 5 files changed, 122 insertions(+), 77 deletions(-) create mode 100644 src/utils.ts diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index c7b3a2259..01ad99f1d 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -41,6 +41,7 @@ describe('setup-go', () => { let mkdirpSpy: jest.SpyInstance; let execSpy: jest.SpyInstance; let getManifestSpy: jest.SpyInstance; + let getAllVersionsSpy: jest.SpyInstance; beforeAll(async () => { process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible) @@ -83,6 +84,7 @@ describe('setup-go', () => { cacheSpy = jest.spyOn(tc, 'cacheDir'); getSpy = jest.spyOn(im, 'getVersionsDist'); getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); + getAllVersionsSpy = jest.spyOn(im, 'getAllReleases'); // io whichSpy = jest.spyOn(io, 'which'); @@ -779,6 +781,7 @@ describe('setup-go', () => { getManifestSpy.mockImplementation(() => { throw new Error('Unable to download manifest'); }); + getAllVersionsSpy.mockImplementationOnce(() => undefined); dlSpy.mockImplementation(async () => '/some/temp/path'); let toolPath = path.normalize('/cache/go/1.13.7/x64'); diff --git a/dist/setup/index.js b/dist/setup/index.js index ccdd32268..566e8023f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63213,7 +63213,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getAllReleases = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63222,12 +63222,12 @@ const httpm = __importStar(__nccwpck_require__(6255)); const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), releases) { return __awaiter(this, void 0, void 0, function* () { let osPlat = os_1.default.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, releases); if (resolvedVersion) { versionSpec = resolvedVersion; core.info(`Resolved as '${versionSpec}'`); @@ -63290,10 +63290,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { }); } exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth, arch) { +function resolveVersionFromManifest(versionSpec, stable, auth, arch, releases) { return __awaiter(this, void 0, void 0, function* () { try { - const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch, releases); return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { @@ -63337,18 +63337,18 @@ function extractGoArchive(archivePath) { }); } exports.extractGoArchive = extractGoArchive; -function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { +function getAllReleases(auth) { + return __awaiter(this, void 0, void 0, function* () { + return yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + }); +} +exports.getAllReleases = getAllReleases; +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), releases) { return __awaiter(this, void 0, void 0, function* () { let info = null; - const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + releases = releases ? releases : yield getAllReleases(auth); core.info(`matching ${versionSpec}...`); - let rel; - if (versionSpec === 'stable') { - rel = releases[0]; - } - else { - rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); - } + let rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); if (rel && rel.files.length > 0) { info = {}; info.type = 'manifest'; @@ -63511,6 +63511,7 @@ const cache_utils_1 = __nccwpck_require__(1678); const child_process_1 = __importDefault(__nccwpck_require__(2081)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); +const utils_1 = __nccwpck_require__(1314); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -63528,11 +63529,13 @@ function run() { if (versionSpec) { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; + const releases = yield installer.getAllReleases(auth); const checkLatest = core.getBooleanInput('check-latest'); - if (versionSpec === 'stable' || versionSpec === 'oldstable') { - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch); + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, releases); } - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, releases); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); const version = installer.makeSemver(versionSpec); @@ -63624,19 +63627,22 @@ function resolveVersionInput() { } return version; } -function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch()) { +function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), releases) { return __awaiter(this, void 0, void 0, function* () { - let resolvedVersion = yield installer.resolveVersionFromManifest('stable', true, auth, arch); - core.info(`Stable version resolved as ${resolvedVersion}`); - if (versionSpec === 'oldstable') { - if (resolvedVersion) { - // example: if version is 1.19.4, semver expression will be: <1.19.0 - const semverExpression = `<${semver.major(resolvedVersion)}.${semver.minor(resolvedVersion)}.0`; - resolvedVersion = yield installer.resolveVersionFromManifest(semverExpression, true, auth, arch); - core.info(`Oldstable version resolved as ${resolvedVersion}`); + if (versionSpec === utils_1.StableReleaseAlias.Stable) { + core.info(`Stable version resolved as ${releases[0].version}`); + return releases[0].version; + } + else { + const versions = releases.map(release => `${semver.major(release.version)}.${semver.minor(release.version)}`); + const uniqueVersions = Array.from(new Set(versions)); + core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); + const oldstableVersion = yield installer.getInfoFromManifest(versionSpec, true, auth, arch, releases); + if (!oldstableVersion) { + return versionSpec; } + return oldstableVersion.resolvedVersion; } - return resolvedVersion ? resolvedVersion : versionSpec; }); } @@ -63703,6 +63709,22 @@ function getArch(arch) { exports.getArch = getArch; +/***/ }), + +/***/ 1314: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.StableReleaseAlias = void 0; +var StableReleaseAlias; +(function (StableReleaseAlias) { + StableReleaseAlias["Stable"] = "stable"; + StableReleaseAlias["OldStable"] = "oldstable"; +})(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {})); + + /***/ }), /***/ 2877: diff --git a/src/installer.ts b/src/installer.ts index d924eae9b..36b20c4cb 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -8,7 +8,6 @@ import fs from 'fs'; import os from 'os'; type InstallationType = 'dist' | 'manifest'; -export type StableAliasType = 'stable' | 'oldstable'; export interface IGoVersionFile { filename: string; @@ -34,7 +33,8 @@ export async function getGo( versionSpec: string, checkLatest: boolean, auth: string | undefined, - arch = os.arch() + arch = os.arch(), + releases: tc.IToolRelease[] | undefined ) { let osPlat: string = os.platform(); @@ -44,7 +44,8 @@ export async function getGo( versionSpec, true, auth, - arch + arch, + releases ); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -119,10 +120,17 @@ export async function resolveVersionFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, - arch: string + arch: string, + releases: tc.IToolRelease[] | undefined ): Promise { try { - const info = await getInfoFromManifest(versionSpec, stable, auth, arch); + const info = await getInfoFromManifest( + versionSpec, + stable, + auth, + arch, + releases + ); return info?.resolvedVersion; } catch (err) { core.info('Unable to resolve a version from the manifest...'); @@ -175,28 +183,23 @@ export async function extractGoArchive(archivePath: string): Promise { return extPath; } +export async function getAllReleases(auth: string | undefined) { + return await tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); +} + export async function getInfoFromManifest( - versionSpec: string | StableAliasType, + versionSpec: string, stable: boolean, auth: string | undefined, - arch = os.arch() + arch = os.arch(), + releases?: tc.IToolRelease[] | undefined ): Promise { let info: IGoVersionInfo | null = null; - const releases = await tc.getManifestFromRepo( - 'actions', - 'go-versions', - auth, - 'main' - ); - core.info(`matching ${versionSpec}...`); + releases = releases ? releases : await getAllReleases(auth); - let rel: tc.IToolRelease | undefined; + core.info(`matching ${versionSpec}...`); - if (versionSpec === 'stable') { - rel = releases[0]; - } else { - rel = await tc.findFromManifest(versionSpec, stable, releases, arch); - } + let rel = await tc.findFromManifest(versionSpec, stable, releases, arch); if (rel && rel.files.length > 0) { info = {}; diff --git a/src/main.ts b/src/main.ts index 012088f52..63753762e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,8 @@ import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; +import {IToolRelease} from '@actions/tool-cache'; +import {StableReleaseAlias} from './utils'; export async function run() { try { @@ -30,17 +32,28 @@ export async function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; + const releases = await installer.getAllReleases(auth); + const checkLatest = core.getBooleanInput('check-latest'); - if (versionSpec === 'stable' || versionSpec === 'oldstable') { - versionSpec = await resolveStableVersionInput(versionSpec, auth, arch); + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await resolveStableVersionInput( + versionSpec, + auth, + arch, + releases + ); } const installDir = await installer.getGo( versionSpec, checkLatest, auth, - arch + arch, + releases ); core.addPath(path.join(installDir, 'bin')); @@ -150,36 +163,36 @@ function resolveVersionInput(): string { } async function resolveStableVersionInput( - versionSpec: installer.StableAliasType, + versionSpec: string, auth: string | undefined, - arch = os.arch() + arch = os.arch(), + releases: IToolRelease[] ): Promise { - let resolvedVersion = await installer.resolveVersionFromManifest( - 'stable', - true, - auth, - arch - ); - - core.info(`Stable version resolved as ${resolvedVersion}`); - - if (versionSpec === 'oldstable') { - if (resolvedVersion) { - // example: if version is 1.19.4, semver expression will be: <1.19.0 - const semverExpression = `<${semver.major( - resolvedVersion - )}.${semver.minor(resolvedVersion)}.0`; - - resolvedVersion = await installer.resolveVersionFromManifest( - semverExpression, - true, - auth, - arch - ); + if (versionSpec === StableReleaseAlias.Stable) { + core.info(`Stable version resolved as ${releases[0].version}`); + + return releases[0].version; + } else { + const versions = releases.map( + release => + `${semver.major(release.version)}.${semver.minor(release.version)}` + ); + const uniqueVersions = Array.from(new Set(versions)); + + core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); - core.info(`Oldstable version resolved as ${resolvedVersion}`); + const oldstableVersion = await installer.getInfoFromManifest( + versionSpec, + true, + auth, + arch, + releases + ); + + if (!oldstableVersion) { + return versionSpec; } - } - return resolvedVersion ? resolvedVersion : versionSpec; + return oldstableVersion.resolvedVersion; + } } diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 000000000..79d03bcad --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,4 @@ +export enum StableReleaseAlias { + Stable = 'stable', + OldStable = 'oldstable' +} From 46c78a9b175981ddd242891d54e6498dd3b70df8 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 17:11:36 +0100 Subject: [PATCH 07/36] Apply PR suggestions --- dist/setup/index.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 566e8023f..aad1d4d50 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63637,7 +63637,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() const versions = releases.map(release => `${semver.major(release.version)}.${semver.minor(release.version)}`); const uniqueVersions = Array.from(new Set(versions)); core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); - const oldstableVersion = yield installer.getInfoFromManifest(versionSpec, true, auth, arch, releases); + const oldstableVersion = yield installer.getInfoFromManifest(uniqueVersions[1], true, auth, arch, releases); if (!oldstableVersion) { return versionSpec; } diff --git a/src/main.ts b/src/main.ts index 63753762e..389976552 100644 --- a/src/main.ts +++ b/src/main.ts @@ -182,7 +182,7 @@ async function resolveStableVersionInput( core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); const oldstableVersion = await installer.getInfoFromManifest( - versionSpec, + uniqueVersions[1], true, auth, arch, From ee153a708dcbd264d33ca2afa55a5d1ff7115831 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 18:05:23 +0100 Subject: [PATCH 08/36] Add check latest check --- .github/workflows/versions.yml | 34 ++++++++++++++++++++++++ __tests__/setup-go.test.ts | 2 +- dist/setup/index.js | 48 ++++++++++++++++++++++++---------- src/installer.ts | 12 ++++++--- src/main.ts | 47 +++++++++++++++++++++------------ 5 files changed, 108 insertions(+), 35 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index e724d3b01..67502d2d4 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -25,10 +25,44 @@ jobs: with: go-version: stable architecture: x64 + check-latest: true - name: Verify Go run: go version oldstable: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: x64 + check-latest: true + - name: Verify Go + run: go version + + stable-no-check-latest: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: x64 + - name: Verify Go + run: go version + + oldstable-no-check-latest: runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 01ad99f1d..7b87d7d4f 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -84,7 +84,7 @@ describe('setup-go', () => { cacheSpy = jest.spyOn(tc, 'cacheDir'); getSpy = jest.spyOn(im, 'getVersionsDist'); getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); - getAllVersionsSpy = jest.spyOn(im, 'getAllReleases'); + getAllVersionsSpy = jest.spyOn(im, 'getAllManifestReleases'); // io whichSpy = jest.spyOn(io, 'which'); diff --git a/dist/setup/index.js b/dist/setup/index.js index aad1d4d50..d91e47430 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63213,7 +63213,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getAllReleases = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getAllToolCacheReleases = exports.getAllManifestReleases = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63337,16 +63337,22 @@ function extractGoArchive(archivePath) { }); } exports.extractGoArchive = extractGoArchive; -function getAllReleases(auth) { +function getAllManifestReleases(auth) { return __awaiter(this, void 0, void 0, function* () { - return yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); }); } -exports.getAllReleases = getAllReleases; +exports.getAllManifestReleases = getAllManifestReleases; +function getAllToolCacheReleases(arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + return tc.findAllVersions('go', arch); + }); +} +exports.getAllToolCacheReleases = getAllToolCacheReleases; function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), releases) { return __awaiter(this, void 0, void 0, function* () { let info = null; - releases = releases ? releases : yield getAllReleases(auth); + releases = releases ? releases : yield getAllManifestReleases(auth); core.info(`matching ${versionSpec}...`); let rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); if (rel && rel.files.length > 0) { @@ -63529,11 +63535,11 @@ function run() { if (versionSpec) { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const releases = yield installer.getAllReleases(auth); + const releases = yield installer.getAllManifestReleases(auth); const checkLatest = core.getBooleanInput('check-latest'); if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, releases); + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, releases, checkLatest); } const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, releases); core.addPath(path_1.default.join(installDir, 'bin')); @@ -63627,21 +63633,35 @@ function resolveVersionInput() { } return version; } -function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), releases) { +function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), manifestReleases, checkLatest = false) { return __awaiter(this, void 0, void 0, function* () { + let releases; + if (checkLatest) { + releases = manifestReleases.map(release => release.version); + } + else { + releases = yield installer.getAllToolCacheReleases(arch); + } if (versionSpec === utils_1.StableReleaseAlias.Stable) { - core.info(`Stable version resolved as ${releases[0].version}`); - return releases[0].version; + core.info(`Stable version resolved as ${releases[0]}`); + return releases[0]; } else { - const versions = releases.map(release => `${semver.major(release.version)}.${semver.minor(release.version)}`); + const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); const uniqueVersions = Array.from(new Set(versions)); - core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); - const oldstableVersion = yield installer.getInfoFromManifest(uniqueVersions[1], true, auth, arch, releases); + let oldstableVersion; + if (checkLatest) { + oldstableVersion = yield installer.getInfoFromManifest(uniqueVersions[1], true, auth, arch, manifestReleases); + oldstableVersion = oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion; + } + else { + oldstableVersion = uniqueVersions[1]; + } + core.info(`Oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } }); } diff --git a/src/installer.ts b/src/installer.ts index 36b20c4cb..d4ce09378 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -5,7 +5,7 @@ import * as semver from 'semver'; import * as httpm from '@actions/http-client'; import * as sys from './system'; import fs from 'fs'; -import os from 'os'; +import os, {arch} from 'os'; type InstallationType = 'dist' | 'manifest'; @@ -183,8 +183,12 @@ export async function extractGoArchive(archivePath: string): Promise { return extPath; } -export async function getAllReleases(auth: string | undefined) { - return await tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); +export async function getAllManifestReleases(auth: string | undefined) { + return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); +} + +export async function getAllToolCacheReleases(arch = os.arch()) { + return tc.findAllVersions('go', arch); } export async function getInfoFromManifest( @@ -195,7 +199,7 @@ export async function getInfoFromManifest( releases?: tc.IToolRelease[] | undefined ): Promise { let info: IGoVersionInfo | null = null; - releases = releases ? releases : await getAllReleases(auth); + releases = releases ? releases : await getAllManifestReleases(auth); core.info(`matching ${versionSpec}...`); diff --git a/src/main.ts b/src/main.ts index 389976552..f3182bb78 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,7 +32,7 @@ export async function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const releases = await installer.getAllReleases(auth); + const releases = await installer.getAllManifestReleases(auth); const checkLatest = core.getBooleanInput('check-latest'); @@ -44,7 +44,8 @@ export async function run() { versionSpec, auth, arch, - releases + releases, + checkLatest ); } @@ -166,33 +167,47 @@ async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - releases: IToolRelease[] + manifestReleases: IToolRelease[], + checkLatest = false ): Promise { + let releases; + if (checkLatest) { + releases = manifestReleases.map(release => release.version); + } else { + releases = await installer.getAllToolCacheReleases(arch); + } + if (versionSpec === StableReleaseAlias.Stable) { - core.info(`Stable version resolved as ${releases[0].version}`); + core.info(`Stable version resolved as ${releases[0]}`); - return releases[0].version; + return releases[0]; } else { const versions = releases.map( - release => - `${semver.major(release.version)}.${semver.minor(release.version)}` + release => `${semver.major(release)}.${semver.minor(release)}` ); const uniqueVersions = Array.from(new Set(versions)); - core.info(`Oldstable version resolved as ${uniqueVersions[1]}`); + let oldstableVersion; - const oldstableVersion = await installer.getInfoFromManifest( - uniqueVersions[1], - true, - auth, - arch, - releases - ); + if (checkLatest) { + oldstableVersion = await installer.getInfoFromManifest( + uniqueVersions[1], + true, + auth, + arch, + manifestReleases + ); + oldstableVersion = oldstableVersion?.resolvedVersion; + } else { + oldstableVersion = uniqueVersions[1]; + } + + core.info(`Oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } } From 84f83e7f2d9811954c51f055d839382b328d434b Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 18:11:05 +0100 Subject: [PATCH 09/36] Add check latest check --- dist/setup/index.js | 1 + src/main.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index d91e47430..658ca60ec 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63641,6 +63641,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() } else { releases = yield installer.getAllToolCacheReleases(arch); + core.info(releases.join(",")); } if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`Stable version resolved as ${releases[0]}`); diff --git a/src/main.ts b/src/main.ts index f3182bb78..b94f3d4ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -175,6 +175,7 @@ async function resolveStableVersionInput( releases = manifestReleases.map(release => release.version); } else { releases = await installer.getAllToolCacheReleases(arch); + core.info(releases.join(",")); } if (versionSpec === StableReleaseAlias.Stable) { From 9b762a9fb1f0fd5897ace0f4ae80dc60f711ffde Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 18:17:25 +0100 Subject: [PATCH 10/36] Add check latest check --- dist/setup/index.js | 4 ++-- src/main.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 658ca60ec..fba3adb88 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63641,7 +63641,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() } else { releases = yield installer.getAllToolCacheReleases(arch); - core.info(releases.join(",")); + releases.reverse(); } if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`Stable version resolved as ${releases[0]}`); @@ -63656,7 +63656,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() oldstableVersion = oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion; } else { - oldstableVersion = uniqueVersions[1]; + oldstableVersion = releases[1]; } core.info(`Oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { diff --git a/src/main.ts b/src/main.ts index b94f3d4ea..fe3ecdc12 100644 --- a/src/main.ts +++ b/src/main.ts @@ -175,7 +175,7 @@ async function resolveStableVersionInput( releases = manifestReleases.map(release => release.version); } else { releases = await installer.getAllToolCacheReleases(arch); - core.info(releases.join(",")); + releases.reverse(); } if (versionSpec === StableReleaseAlias.Stable) { @@ -200,7 +200,7 @@ async function resolveStableVersionInput( ); oldstableVersion = oldstableVersion?.resolvedVersion; } else { - oldstableVersion = uniqueVersions[1]; + oldstableVersion = releases[1]; } core.info(`Oldstable version resolved as ${oldstableVersion}`); From 58547ffb8bc13fbf58bb7cd80ec87ef1b31b272d Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 20:17:19 +0100 Subject: [PATCH 11/36] Add documentation --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 8ef09d476..d244a9169 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The V3 edition of the action offers: - Proxy support - Check latest version - Caching packages dependencies +- stable and olstable aliases - Bug Fixes (including issues around version matching and semver) The action will first check the local cache for a version match. If a version is not found locally, it will pull it from the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. On miss or failure, it will fall back to downloading directly from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use the [check-latest input](#check-latest-version). @@ -95,6 +96,31 @@ steps: check-latest: true - run: go run hello.go ``` + +## stable/oldstable aliases + +Given the fact that Go doesn't use semver syntax ranges, and that many Go projects want to run tests based on `stable` and `oldstable` aliases, these aliases are introduced in this action as possible values of the input `go-version`. When alias `stable` is provided, and `check-latest` input is set to `true` action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. When `check-latest` is not provided, or set to false, the action will resolve `stable` as the most recent present version from the runners tool cache directory. In case of the `oldstable` alias, if current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. The `check-latest` rules described above will apply for `oldstable` as well. + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 'stable' + check-latest: true + - run: go run hello.go +``` + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 'oldstable' + check-latest: true + - run: go run hello.go +``` + ## Caching dependency files and build outputs: The action has a built-in functionality for caching and restoring go modules and build outputs. It uses [actions/cache](https://github.com/actions/cache) under the hood but requires less configuration settings. The `cache` input is optional, and caching is turned off by default. From 6590366b0a31bfeaad5a62700bb7800cf9df8ac1 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 20:20:13 +0100 Subject: [PATCH 12/36] Update docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d244a9169..ed70e54de 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ steps: ## stable/oldstable aliases -Given the fact that Go doesn't use semver syntax ranges, and that many Go projects want to run tests based on `stable` and `oldstable` aliases, these aliases are introduced in this action as possible values of the input `go-version`. When alias `stable` is provided, and `check-latest` input is set to `true` action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. When `check-latest` is not provided, or set to false, the action will resolve `stable` as the most recent present version from the runners tool cache directory. In case of the `oldstable` alias, if current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. The `check-latest` rules described above will apply for `oldstable` as well. +Given the fact that Go doesn't use semver syntax ranges, and that many Go projects want to run tests based on `stable` and `oldstable` aliases, these aliases are introduced in the action as possible values of the input `go-version`. When alias `stable` is provided, and `check-latest` input is set to `true` action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest. When `check-latest` is not provided, or set to false, the action will resolve `stable` as the most recent present version from the runners tool cache directory. In case of the `oldstable` alias, if current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. The `check-latest` rules described above will apply for `oldstable` as well. ```yaml steps: From 9d73e829e4d568b20075392a1e4d4cbc8ae37b34 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 21 Nov 2022 20:22:11 +0100 Subject: [PATCH 13/36] Update docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed70e54de..4ac9fd606 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ steps: - run: go run hello.go ``` -## stable/oldstable aliases +## Using stable/oldstable aliases Given the fact that Go doesn't use semver syntax ranges, and that many Go projects want to run tests based on `stable` and `oldstable` aliases, these aliases are introduced in the action as possible values of the input `go-version`. When alias `stable` is provided, and `check-latest` input is set to `true` action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest. When `check-latest` is not provided, or set to false, the action will resolve `stable` as the most recent present version from the runners tool cache directory. In case of the `oldstable` alias, if current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. The `check-latest` rules described above will apply for `oldstable` as well. From a29996aa9d458401050c312754668a1555421ea0 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Wed, 23 Nov 2022 18:39:47 +0100 Subject: [PATCH 14/36] Apply PR suggestions --- .github/workflows/versions.yml | 34 ----------- README.md | 10 ++-- __tests__/setup-go.test.ts | 29 +++++++++- dist/setup/index.js | 101 ++++++++++++++------------------- src/installer.ts | 79 ++++++++++++++++++++++---- src/main.ts | 69 +--------------------- 6 files changed, 148 insertions(+), 174 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 67502d2d4..e724d3b01 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -25,44 +25,10 @@ jobs: with: go-version: stable architecture: x64 - check-latest: true - name: Verify Go run: go version oldstable: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: oldstable - architecture: x64 - check-latest: true - - name: Verify Go - run: go version - - stable-no-check-latest: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: stable - architecture: x64 - - name: Verify Go - run: go version - - oldstable-no-check-latest: runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/README.md b/README.md index 4ac9fd606..ee24ecac2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The V3 edition of the action offers: - Proxy support - Check latest version - Caching packages dependencies -- stable and olstable aliases +- stable and oldstable aliases - Bug Fixes (including issues around version matching and semver) The action will first check the local cache for a version match. If a version is not found locally, it will pull it from the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. On miss or failure, it will fall back to downloading directly from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use the [check-latest input](#check-latest-version). @@ -99,7 +99,11 @@ steps: ## Using stable/oldstable aliases -Given the fact that Go doesn't use semver syntax ranges, and that many Go projects want to run tests based on `stable` and `oldstable` aliases, these aliases are introduced in the action as possible values of the input `go-version`. When alias `stable` is provided, and `check-latest` input is set to `true` action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest. When `check-latest` is not provided, or set to false, the action will resolve `stable` as the most recent present version from the runners tool cache directory. In case of the `oldstable` alias, if current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. The `check-latest` rules described above will apply for `oldstable` as well. +If `stable` is provided, action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest. + +If `oldstable` is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. + +**Note:** using these aliases will result in same version as using corresponding minor release with `check-latest` input set to `true` ```yaml steps: @@ -107,7 +111,6 @@ steps: - uses: actions/setup-go@v3 with: go-version: 'stable' - check-latest: true - run: go run hello.go ``` @@ -117,7 +120,6 @@ steps: - uses: actions/setup-go@v3 with: go-version: 'oldstable' - check-latest: true - run: go run hello.go ``` diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 7b87d7d4f..8ebcde043 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -84,7 +84,7 @@ describe('setup-go', () => { cacheSpy = jest.spyOn(tc, 'cacheDir'); getSpy = jest.spyOn(im, 'getVersionsDist'); getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); - getAllVersionsSpy = jest.spyOn(im, 'getAllManifestReleases'); + getAllVersionsSpy = jest.spyOn(im, 'getManifest'); // io whichSpy = jest.spyOn(io, 'which'); @@ -929,5 +929,32 @@ use . ); } }, 100000); + + it.each(['stable', 'oldstable'])( + 'acquires latest go version with %s go-version input', + async (alias: string) => { + const arch = 'x64'; + os.platform = 'darwin'; + os.arch = arch; + + inputs['go-version'] = alias; + inputs['architecture'] = os.arch; + + // ... but not in the local cache + findSpy.mockImplementation(() => ''); + + dlSpy.mockImplementation(async () => '/some/temp/path'); + let toolPath = path.normalize(`/cache/go/${alias}/${arch}`); + cacheSpy.mockImplementation(async () => toolPath); + + await main.run(); + + const releaseIndex = alias === 'stable' ? 0 : 1; + + expect(logSpy).toHaveBeenCalledWith( + `${alias} version resolved as ${goTestManifest[releaseIndex].version}` + ); + } + ); }); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index fba3adb88..233e2f67a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63213,7 +63213,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getAllToolCacheReleases = exports.getAllManifestReleases = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63222,12 +63222,13 @@ const httpm = __importStar(__nccwpck_require__(6255)); const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), releases) { +const utils_1 = __nccwpck_require__(1314); +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manifest) { return __awaiter(this, void 0, void 0, function* () { let osPlat = os_1.default.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, releases); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, manifest); if (resolvedVersion) { versionSpec = resolvedVersion; core.info(`Resolved as '${versionSpec}'`); @@ -63236,6 +63237,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), relea core.info(`Failed to resolve version ${versionSpec} from manifest`); } } + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); + } // check cache let toolPath; toolPath = tc.find('go', versionSpec, arch); @@ -63290,10 +63295,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), relea }); } exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth, arch, releases) { +function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) { return __awaiter(this, void 0, void 0, function* () { try { - const info = yield getInfoFromManifest(versionSpec, stable, auth, arch, releases); + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch, manifest); return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { @@ -63337,24 +63342,21 @@ function extractGoArchive(archivePath) { }); } exports.extractGoArchive = extractGoArchive; -function getAllManifestReleases(auth) { +function getManifest(auth) { return __awaiter(this, void 0, void 0, function* () { return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); }); } -exports.getAllManifestReleases = getAllManifestReleases; -function getAllToolCacheReleases(arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - return tc.findAllVersions('go', arch); - }); -} -exports.getAllToolCacheReleases = getAllToolCacheReleases; -function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), releases) { +exports.getManifest = getManifest; +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), manifest) { return __awaiter(this, void 0, void 0, function* () { let info = null; - releases = releases ? releases : yield getAllManifestReleases(auth); + if (!manifest) { + core.debug('No manifest cached'); + manifest = yield getManifest(auth); + } core.info(`matching ${versionSpec}...`); - let rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + const rel = yield tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { info = {}; info.type = 'manifest'; @@ -63465,6 +63467,29 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; +function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), manifest) { + return __awaiter(this, void 0, void 0, function* () { + if (!manifest) { + core.debug('No manifest cached'); + manifest = yield getManifest(auth); + } + const releases = manifest.map(release => release.version); + if (versionSpec === utils_1.StableReleaseAlias.Stable) { + core.info(`stable version resolved as ${releases[0]}`); + return releases[0]; + } + else { + const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); + const uniqueVersions = Array.from(new Set(versions)); + const oldstableVersion = yield getInfoFromManifest(uniqueVersions[1], true, auth, arch, manifest); + core.info(`oldstable version resolved as ${oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion}`); + if (!oldstableVersion) { + return versionSpec; + } + return oldstableVersion.resolvedVersion; + } + }); +} /***/ }), @@ -63517,7 +63542,6 @@ const cache_utils_1 = __nccwpck_require__(1678); const child_process_1 = __importDefault(__nccwpck_require__(2081)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); -const utils_1 = __nccwpck_require__(1314); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -63525,7 +63549,7 @@ function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - let versionSpec = resolveVersionInput(); + const versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); let arch = core.getInput('architecture'); @@ -63535,13 +63559,9 @@ function run() { if (versionSpec) { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const releases = yield installer.getAllManifestReleases(auth); + const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); - if (versionSpec === utils_1.StableReleaseAlias.Stable || - versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, releases, checkLatest); - } - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, releases); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); const version = installer.makeSemver(versionSpec); @@ -63633,39 +63653,6 @@ function resolveVersionInput() { } return version; } -function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), manifestReleases, checkLatest = false) { - return __awaiter(this, void 0, void 0, function* () { - let releases; - if (checkLatest) { - releases = manifestReleases.map(release => release.version); - } - else { - releases = yield installer.getAllToolCacheReleases(arch); - releases.reverse(); - } - if (versionSpec === utils_1.StableReleaseAlias.Stable) { - core.info(`Stable version resolved as ${releases[0]}`); - return releases[0]; - } - else { - const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); - const uniqueVersions = Array.from(new Set(versions)); - let oldstableVersion; - if (checkLatest) { - oldstableVersion = yield installer.getInfoFromManifest(uniqueVersions[1], true, auth, arch, manifestReleases); - oldstableVersion = oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion; - } - else { - oldstableVersion = releases[1]; - } - core.info(`Oldstable version resolved as ${oldstableVersion}`); - if (!oldstableVersion) { - return versionSpec; - } - return oldstableVersion; - } - }); -} /***/ }), diff --git a/src/installer.ts b/src/installer.ts index d4ce09378..39290d9b8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -6,6 +6,7 @@ import * as httpm from '@actions/http-client'; import * as sys from './system'; import fs from 'fs'; import os, {arch} from 'os'; +import {StableReleaseAlias} from './utils'; type InstallationType = 'dist' | 'manifest'; @@ -34,7 +35,7 @@ export async function getGo( checkLatest: boolean, auth: string | undefined, arch = os.arch(), - releases: tc.IToolRelease[] | undefined + manifest: tc.IToolRelease[] | undefined ) { let osPlat: string = os.platform(); @@ -45,7 +46,7 @@ export async function getGo( true, auth, arch, - releases + manifest ); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -55,6 +56,18 @@ export async function getGo( } } + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await resolveStableVersionInput( + versionSpec, + auth, + arch, + manifest + ); + } + // check cache let toolPath: string; toolPath = tc.find('go', versionSpec, arch); @@ -121,7 +134,7 @@ export async function resolveVersionFromManifest( stable: boolean, auth: string | undefined, arch: string, - releases: tc.IToolRelease[] | undefined + manifest: tc.IToolRelease[] | undefined ): Promise { try { const info = await getInfoFromManifest( @@ -129,7 +142,7 @@ export async function resolveVersionFromManifest( stable, auth, arch, - releases + manifest ); return info?.resolvedVersion; } catch (err) { @@ -183,27 +196,26 @@ export async function extractGoArchive(archivePath: string): Promise { return extPath; } -export async function getAllManifestReleases(auth: string | undefined) { +export async function getManifest(auth: string | undefined) { return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); } -export async function getAllToolCacheReleases(arch = os.arch()) { - return tc.findAllVersions('go', arch); -} - export async function getInfoFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, arch = os.arch(), - releases?: tc.IToolRelease[] | undefined + manifest?: tc.IToolRelease[] | undefined ): Promise { let info: IGoVersionInfo | null = null; - releases = releases ? releases : await getAllManifestReleases(auth); + if (!manifest) { + core.debug('No manifest cached'); + manifest = await getManifest(auth); + } core.info(`matching ${versionSpec}...`); - let rel = await tc.findFromManifest(versionSpec, stable, releases, arch); + const rel = await tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { info = {}; @@ -341,3 +353,46 @@ export function parseGoVersionFile(versionFilePath: string): string { return contents.trim(); } + +async function resolveStableVersionInput( + versionSpec: string, + auth: string | undefined, + arch = os.arch(), + manifest: tc.IToolRelease[] | undefined +): Promise { + if (!manifest) { + core.debug('No manifest cached'); + manifest = await getManifest(auth); + } + + const releases = manifest.map(release => release.version); + + if (versionSpec === StableReleaseAlias.Stable) { + core.info(`stable version resolved as ${releases[0]}`); + + return releases[0]; + } else { + const versions = releases.map( + release => `${semver.major(release)}.${semver.minor(release)}` + ); + const uniqueVersions = Array.from(new Set(versions)); + + const oldstableVersion = await getInfoFromManifest( + uniqueVersions[1], + true, + auth, + arch, + manifest + ); + + core.info( + `oldstable version resolved as ${oldstableVersion?.resolvedVersion}` + ); + + if (!oldstableVersion) { + return versionSpec; + } + + return oldstableVersion.resolvedVersion; + } +} diff --git a/src/main.ts b/src/main.ts index fe3ecdc12..138de1da8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,7 +17,7 @@ export async function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - let versionSpec = resolveVersionInput(); + const versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); @@ -32,29 +32,16 @@ export async function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const releases = await installer.getAllManifestReleases(auth); + const manifest = await installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); - if ( - versionSpec === StableReleaseAlias.Stable || - versionSpec === StableReleaseAlias.OldStable - ) { - versionSpec = await resolveStableVersionInput( - versionSpec, - auth, - arch, - releases, - checkLatest - ); - } - const installDir = await installer.getGo( versionSpec, checkLatest, auth, arch, - releases + manifest ); core.addPath(path.join(installDir, 'bin')); @@ -162,53 +149,3 @@ function resolveVersionInput(): string { return version; } - -async function resolveStableVersionInput( - versionSpec: string, - auth: string | undefined, - arch = os.arch(), - manifestReleases: IToolRelease[], - checkLatest = false -): Promise { - let releases; - if (checkLatest) { - releases = manifestReleases.map(release => release.version); - } else { - releases = await installer.getAllToolCacheReleases(arch); - releases.reverse(); - } - - if (versionSpec === StableReleaseAlias.Stable) { - core.info(`Stable version resolved as ${releases[0]}`); - - return releases[0]; - } else { - const versions = releases.map( - release => `${semver.major(release)}.${semver.minor(release)}` - ); - const uniqueVersions = Array.from(new Set(versions)); - - let oldstableVersion; - - if (checkLatest) { - oldstableVersion = await installer.getInfoFromManifest( - uniqueVersions[1], - true, - auth, - arch, - manifestReleases - ); - oldstableVersion = oldstableVersion?.resolvedVersion; - } else { - oldstableVersion = releases[1]; - } - - core.info(`Oldstable version resolved as ${oldstableVersion}`); - - if (!oldstableVersion) { - return versionSpec; - } - - return oldstableVersion; - } -} From 18c62c8dd3786d90cb9ebcc6ba443d01fcb72683 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Wed, 23 Nov 2022 18:50:03 +0100 Subject: [PATCH 15/36] Return alias condition to main --- dist/setup/index.js | 14 ++++++++------ src/installer.ts | 14 +------------- src/main.ts | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 233e2f67a..39dd9649d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63213,7 +63213,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; +exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63237,10 +63237,6 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif core.info(`Failed to resolve version ${versionSpec} from manifest`); } } - if (versionSpec === utils_1.StableReleaseAlias.Stable || - versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); - } // check cache let toolPath; toolPath = tc.find('go', versionSpec, arch); @@ -63490,6 +63486,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() } }); } +exports.resolveStableVersionInput = resolveStableVersionInput; /***/ }), @@ -63542,6 +63539,7 @@ const cache_utils_1 = __nccwpck_require__(1678); const child_process_1 = __importDefault(__nccwpck_require__(2081)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); +const utils_1 = __nccwpck_require__(1314); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -63549,7 +63547,7 @@ function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - const versionSpec = resolveVersionInput(); + let versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); let arch = core.getInput('architecture'); @@ -63561,6 +63559,10 @@ function run() { let auth = !token ? undefined : `token ${token}`; const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield installer.resolveStableVersionInput(versionSpec, auth, arch, manifest); + } const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); diff --git a/src/installer.ts b/src/installer.ts index 39290d9b8..2e2029147 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -56,18 +56,6 @@ export async function getGo( } } - if ( - versionSpec === StableReleaseAlias.Stable || - versionSpec === StableReleaseAlias.OldStable - ) { - versionSpec = await resolveStableVersionInput( - versionSpec, - auth, - arch, - manifest - ); - } - // check cache let toolPath: string; toolPath = tc.find('go', versionSpec, arch); @@ -354,7 +342,7 @@ export function parseGoVersionFile(versionFilePath: string): string { return contents.trim(); } -async function resolveStableVersionInput( +export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), diff --git a/src/main.ts b/src/main.ts index 138de1da8..9769a844e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,6 @@ import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; -import {IToolRelease} from '@actions/tool-cache'; import {StableReleaseAlias} from './utils'; export async function run() { @@ -17,7 +16,7 @@ export async function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - const versionSpec = resolveVersionInput(); + let versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); @@ -36,6 +35,18 @@ export async function run() { const checkLatest = core.getBooleanInput('check-latest'); + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await installer.resolveStableVersionInput( + versionSpec, + auth, + arch, + manifest + ); + } + const installDir = await installer.getGo( versionSpec, checkLatest, From 17fabf6bf1bed94036d5675ad6383d576d02a2c1 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Thu, 24 Nov 2022 16:13:28 +0100 Subject: [PATCH 16/36] Move condition to the installer --- __tests__/setup-go.test.ts | 4 ++-- dist/setup/index.js | 17 ++++++++++++----- src/installer.ts | 14 +++++++++++++- src/main.ts | 20 +++++++------------- src/utils.ts | 2 ++ 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 8ebcde043..f10f85cab 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -702,7 +702,7 @@ describe('setup-go', () => { findSpy.mockImplementation(() => ''); dlSpy.mockImplementation(async () => '/some/temp/path'); - const toolPath = path.normalize('/cache/go/1.17.5/x64'); + const toolPath = path.normalize('/cache/go/1.17.6/x64'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); cacheSpy.mockImplementation(async () => toolPath); @@ -722,7 +722,7 @@ describe('setup-go', () => { expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); expect(logSpy).toHaveBeenCalledWith('Added go to the path'); expect(logSpy).toHaveBeenCalledWith( - `Successfully set up Go version ${versionSpec}` + `Successfully set up Go version ${patchVersion}` ); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index 39dd9649d..12d81c8db 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63237,6 +63237,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif core.info(`Failed to resolve version ${versionSpec} from manifest`); } } + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); + } // check cache let toolPath; toolPath = tc.find('go', versionSpec, arch); @@ -63559,11 +63563,13 @@ function run() { let auth = !token ? undefined : `token ${token}`; const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); - if (versionSpec === utils_1.StableReleaseAlias.Stable || - versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield installer.resolveStableVersionInput(versionSpec, auth, arch, manifest); - } const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); + if (utils_1.IS_WINDOWS) { + versionSpec = installDir.split('\\').reverse()[1]; + } + else { + versionSpec = installDir.split('/').reverse()[1]; + } core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); const version = installer.makeSemver(versionSpec); @@ -63727,12 +63733,13 @@ exports.getArch = getArch; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.StableReleaseAlias = void 0; +exports.IS_WINDOWS = exports.StableReleaseAlias = void 0; var StableReleaseAlias; (function (StableReleaseAlias) { StableReleaseAlias["Stable"] = "stable"; StableReleaseAlias["OldStable"] = "oldstable"; })(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {})); +exports.IS_WINDOWS = process.platform === 'win32'; /***/ }), diff --git a/src/installer.ts b/src/installer.ts index 2e2029147..37fa6e638 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -5,7 +5,7 @@ import * as semver from 'semver'; import * as httpm from '@actions/http-client'; import * as sys from './system'; import fs from 'fs'; -import os, {arch} from 'os'; +import os from 'os'; import {StableReleaseAlias} from './utils'; type InstallationType = 'dist' | 'manifest'; @@ -56,6 +56,18 @@ export async function getGo( } } + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await resolveStableVersionInput( + versionSpec, + auth, + arch, + manifest + ); + } + // check cache let toolPath: string; toolPath = tc.find('go', versionSpec, arch); diff --git a/src/main.ts b/src/main.ts index 9769a844e..a5816b8a9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; -import {StableReleaseAlias} from './utils'; +import {IS_WINDOWS} from './utils'; export async function run() { try { @@ -35,18 +35,6 @@ export async function run() { const checkLatest = core.getBooleanInput('check-latest'); - if ( - versionSpec === StableReleaseAlias.Stable || - versionSpec === StableReleaseAlias.OldStable - ) { - versionSpec = await installer.resolveStableVersionInput( - versionSpec, - auth, - arch, - manifest - ); - } - const installDir = await installer.getGo( versionSpec, checkLatest, @@ -55,6 +43,12 @@ export async function run() { manifest ); + if (IS_WINDOWS) { + versionSpec = installDir.split('\\').reverse()[1]; + } else { + versionSpec = installDir.split('/').reverse()[1]; + } + core.addPath(path.join(installDir, 'bin')); core.info('Added go to the path'); diff --git a/src/utils.ts b/src/utils.ts index 79d03bcad..6f6315c70 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,3 +2,5 @@ export enum StableReleaseAlias { Stable = 'stable', OldStable = 'oldstable' } + +export const IS_WINDOWS = process.platform === 'win32'; From f1f69d49da7f85ae8f8d0d039e7478fc76a9632e Mon Sep 17 00:00:00 2001 From: panticmilos Date: Fri, 25 Nov 2022 10:50:21 +0100 Subject: [PATCH 17/36] Apply internal discussion agreements --- .github/workflows/versions.yml | 2 -- __tests__/setup-go.test.ts | 2 +- src/installer.ts | 4 ++-- src/main.ts | 11 +++-------- src/utils.ts | 2 -- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index e724d3b01..1291b08ed 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -24,7 +24,6 @@ jobs: uses: ./ with: go-version: stable - architecture: x64 - name: Verify Go run: go version @@ -40,7 +39,6 @@ jobs: uses: ./ with: go-version: oldstable - architecture: x64 - name: Verify Go run: go version diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index f10f85cab..2188fc9b2 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -722,7 +722,7 @@ describe('setup-go', () => { expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); expect(logSpy).toHaveBeenCalledWith('Added go to the path'); expect(logSpy).toHaveBeenCalledWith( - `Successfully set up Go version ${patchVersion}` + `Successfully set up Go version ${versionSpec}` ); }); diff --git a/src/installer.ts b/src/installer.ts index 37fa6e638..23b8fd02b 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -129,7 +129,7 @@ export async function getGo( return downloadPath; } -export async function resolveVersionFromManifest( +async function resolveVersionFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, @@ -358,7 +358,7 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: tc.IToolRelease[] | undefined + manifest: tc.IToolRelease[] | undefined, ): Promise { if (!manifest) { core.debug('No manifest cached'); diff --git a/src/main.ts b/src/main.ts index a5816b8a9..613cb5460 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,6 @@ import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; -import {IS_WINDOWS} from './utils'; export async function run() { try { @@ -16,7 +15,7 @@ export async function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - let versionSpec = resolveVersionInput(); + const versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); @@ -43,16 +42,12 @@ export async function run() { manifest ); - if (IS_WINDOWS) { - versionSpec = installDir.split('\\').reverse()[1]; - } else { - versionSpec = installDir.split('/').reverse()[1]; - } + const installDirVersion = path.basename(path.dirname(installDir)); core.addPath(path.join(installDir, 'bin')); core.info('Added go to the path'); - const version = installer.makeSemver(versionSpec); + const version = installer.makeSemver(installDirVersion); // Go versions less than 1.9 require GOROOT to be set if (semver.lt(version, '1.9.0')) { core.info('Setting GOROOT for Go version < 1.9'); diff --git a/src/utils.ts b/src/utils.ts index 6f6315c70..79d03bcad 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,5 +2,3 @@ export enum StableReleaseAlias { Stable = 'stable', OldStable = 'oldstable' } - -export const IS_WINDOWS = process.platform === 'win32'; From ece959cf2be1486f286fae83815e4cf2dba2bafa Mon Sep 17 00:00:00 2001 From: panticmilos Date: Fri, 25 Nov 2022 10:52:15 +0100 Subject: [PATCH 18/36] Rebuild dist --- dist/setup/index.js | 18 +++++------------- src/installer.ts | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 12d81c8db..06b72aa12 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63213,7 +63213,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.resolveVersionFromManifest = exports.getGo = void 0; +exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63307,7 +63307,6 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) { } }); } -exports.resolveVersionFromManifest = resolveVersionFromManifest; function installGoVersion(info, auth, arch) { return __awaiter(this, void 0, void 0, function* () { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); @@ -63543,7 +63542,6 @@ const cache_utils_1 = __nccwpck_require__(1678); const child_process_1 = __importDefault(__nccwpck_require__(2081)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); -const utils_1 = __nccwpck_require__(1314); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -63551,7 +63549,7 @@ function run() { // versionSpec is optional. If supplied, install / use from the tool cache // If not supplied then problem matchers will still be setup. Useful for self-hosted. // - let versionSpec = resolveVersionInput(); + const versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); let arch = core.getInput('architecture'); @@ -63564,15 +63562,10 @@ function run() { const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); - if (utils_1.IS_WINDOWS) { - versionSpec = installDir.split('\\').reverse()[1]; - } - else { - versionSpec = installDir.split('/').reverse()[1]; - } + const installDirVersion = path_1.default.basename(path_1.default.dirname(installDir)); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); - const version = installer.makeSemver(versionSpec); + const version = installer.makeSemver(installDirVersion); // Go versions less than 1.9 require GOROOT to be set if (semver.lt(version, '1.9.0')) { core.info('Setting GOROOT for Go version < 1.9'); @@ -63733,13 +63726,12 @@ exports.getArch = getArch; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.IS_WINDOWS = exports.StableReleaseAlias = void 0; +exports.StableReleaseAlias = void 0; var StableReleaseAlias; (function (StableReleaseAlias) { StableReleaseAlias["Stable"] = "stable"; StableReleaseAlias["OldStable"] = "oldstable"; })(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {})); -exports.IS_WINDOWS = process.platform === 'win32'; /***/ }), diff --git a/src/installer.ts b/src/installer.ts index 23b8fd02b..0c2cdee38 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -358,7 +358,7 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: tc.IToolRelease[] | undefined, + manifest: tc.IToolRelease[] | undefined ): Promise { if (!manifest) { core.debug('No manifest cached'); From b7bdf8dcd07ab7a64166376b995faf6238244031 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 29 Nov 2022 22:46:12 +0100 Subject: [PATCH 19/36] add type conversion --- dist/cache-save/index.js | 13 +++++++----- dist/setup/index.js | 44 +++++++++++++++++++++++++--------------- package-lock.json | 33 ++++++++++++++++-------------- package.json | 4 ++-- src/installer.ts | 42 +++++++++++++++++++++++--------------- src/main.ts | 5 +---- 6 files changed, 83 insertions(+), 58 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 10c4ddceb..e6e029d98 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60313,7 +60313,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60418,7 +60418,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60437,7 +60437,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -60447,14 +60447,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -60462,6 +60464,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; diff --git a/dist/setup/index.js b/dist/setup/index.js index 06b72aa12..5e2e0df38 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63007,7 +63007,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63032,7 +63032,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const constants_1 = __nccwpck_require__(9042); const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { +const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); @@ -63056,6 +63056,7 @@ exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __a core.saveState(constants_1.State.CacheMatchedKey, cacheKey); core.info(`Cache restored from key: ${cacheKey}`); }); +exports.restoreCache = restoreCache; const findDependencyFile = (packageManager) => { let dependencyFile = packageManager.dependencyFilePattern; const workspace = process.env.GITHUB_WORKSPACE; @@ -63090,7 +63091,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63109,7 +63110,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -63119,14 +63120,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -63134,6 +63137,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; @@ -63196,7 +63200,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63223,11 +63227,13 @@ const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); const utils_1 = __nccwpck_require__(1314); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manifest) { +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { + let manifest; let osPlat = os_1.default.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); + manifest = yield getManifest(auth); const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, manifest); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -63239,6 +63245,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif } if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { + manifest !== null && manifest !== void 0 ? manifest : (manifest = yield getManifest(auth)); versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); } // check cache @@ -63394,6 +63401,10 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { if (!candidates) { throw new Error(`golang download url did not return results`); } + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, candidates); + } let goFile; for (let i = 0; i < candidates.length; i++) { let candidate = candidates[i]; @@ -63470,9 +63481,11 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() return __awaiter(this, void 0, void 0, function* () { if (!manifest) { core.debug('No manifest cached'); - manifest = yield getManifest(auth); + manifest = (yield getManifest(auth)); } - const releases = manifest.map(release => release.version); + const releases = manifest + .filter(release => !!release.files.find(file => file.arch === arch)) + .map(release => release.version); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); return releases[0]; @@ -63480,12 +63493,12 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() else { const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); const uniqueVersions = Array.from(new Set(versions)); - const oldstableVersion = yield getInfoFromManifest(uniqueVersions[1], true, auth, arch, manifest); - core.info(`oldstable version resolved as ${oldstableVersion === null || oldstableVersion === void 0 ? void 0 : oldstableVersion.resolvedVersion}`); + const oldstableVersion = releases.find(item => item.startsWith(uniqueVersions[1])); + core.info(`oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } }); } @@ -63514,7 +63527,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__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 (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63559,9 +63572,8 @@ function run() { if (versionSpec) { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const manifest = yield installer.getManifest(auth); const checkLatest = core.getBooleanInput('check-latest'); - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); const installDirVersion = path_1.default.basename(path_1.default.dirname(installDir)); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); diff --git a/package-lock.json b/package-lock.json index 73e443dee..5d4490ca3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,9 +26,9 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^1.17.1", + "prettier": "^2.8.0", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } }, "node_modules/@actions/cache": { @@ -4062,15 +4062,18 @@ } }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { - "node": ">=4" + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/pretty-format": { @@ -4694,9 +4697,9 @@ } }, "node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8118,9 +8121,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", "dev": true }, "pretty-format": { @@ -8565,9 +8568,9 @@ } }, "typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index fbbedc0ff..9a1aa88e8 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^1.17.1", + "prettier": "^2.8.0", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } } diff --git a/src/installer.ts b/src/installer.ts index 0c2cdee38..18eab5ccf 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -34,13 +34,14 @@ export async function getGo( versionSpec: string, checkLatest: boolean, auth: string | undefined, - arch = os.arch(), - manifest: tc.IToolRelease[] | undefined + arch = os.arch() ) { + let manifest: tc.IToolRelease[] | undefined; let osPlat: string = os.platform(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); + manifest = await getManifest(auth); const resolvedVersion = await resolveVersionFromManifest( versionSpec, true, @@ -60,11 +61,12 @@ export async function getGo( versionSpec === StableReleaseAlias.Stable || versionSpec === StableReleaseAlias.OldStable ) { + manifest ??= await getManifest(auth); versionSpec = await resolveStableVersionInput( versionSpec, auth, arch, - manifest + manifest as (tc.IToolRelease & IGoVersion)[] ); } @@ -266,6 +268,18 @@ export async function findMatch( throw new Error(`golang download url did not return results`); } + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + versionSpec = await resolveStableVersionInput( + versionSpec, + undefined, + arch, + candidates as (tc.IToolRelease & IGoVersion)[] + ); + } + let goFile: IGoVersionFile | undefined; for (let i = 0; i < candidates.length; i++) { let candidate: IGoVersion = candidates[i]; @@ -358,14 +372,16 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: tc.IToolRelease[] | undefined + manifest: (tc.IToolRelease & IGoVersion)[] | undefined ): Promise { if (!manifest) { core.debug('No manifest cached'); - manifest = await getManifest(auth); + manifest = (await getManifest(auth)) as (tc.IToolRelease & IGoVersion)[]; } - const releases = manifest.map(release => release.version); + const releases = manifest + .filter(release => !!release.files.find(file => file.arch === arch)) + .map(release => release.version); if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); @@ -377,22 +393,16 @@ export async function resolveStableVersionInput( ); const uniqueVersions = Array.from(new Set(versions)); - const oldstableVersion = await getInfoFromManifest( - uniqueVersions[1], - true, - auth, - arch, - manifest + const oldstableVersion = releases.find(item => + item.startsWith(uniqueVersions[1]) ); - core.info( - `oldstable version resolved as ${oldstableVersion?.resolvedVersion}` - ); + core.info(`oldstable version resolved as ${oldstableVersion}`); if (!oldstableVersion) { return versionSpec; } - return oldstableVersion.resolvedVersion; + return oldstableVersion; } } diff --git a/src/main.ts b/src/main.ts index 613cb5460..5833f16de 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,16 +30,13 @@ export async function run() { let token = core.getInput('token'); let auth = !token ? undefined : `token ${token}`; - const manifest = await installer.getManifest(auth); - const checkLatest = core.getBooleanInput('check-latest'); const installDir = await installer.getGo( versionSpec, checkLatest, auth, - arch, - manifest + arch ); const installDirVersion = path.basename(path.dirname(installDir)); From eb4d2dd387fab6b7ee331cff7c5ceb63d1602c35 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 29 Nov 2022 23:02:50 +0100 Subject: [PATCH 20/36] possible fix --- dist/setup/index.js | 5 ++++- src/installer.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 5e2e0df38..0f9cf0e9a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63403,7 +63403,10 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { } if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { - versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, candidates); + const fixedCandidates = candidates.map(item => { + return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); + }); + versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, fixedCandidates); } let goFile; for (let i = 0; i < candidates.length; i++) { diff --git a/src/installer.ts b/src/installer.ts index 18eab5ccf..975ace211 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -272,11 +272,14 @@ export async function findMatch( versionSpec === StableReleaseAlias.Stable || versionSpec === StableReleaseAlias.OldStable ) { + const fixedCandidates = candidates.map(item => { + return {...item, version: makeSemver(item.version)}; + }); versionSpec = await resolveStableVersionInput( versionSpec, undefined, arch, - candidates as (tc.IToolRelease & IGoVersion)[] + fixedCandidates as (tc.IToolRelease & IGoVersion)[] ); } From f62329616ac0021e377503a76c0edf1c8921f049 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 15:40:29 +0100 Subject: [PATCH 21/36] minor changes --- dist/setup/index.js | 12 +++++++++--- src/installer.ts | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 0f9cf0e9a..04c53eeeb 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63484,11 +63484,17 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() return __awaiter(this, void 0, void 0, function* () { if (!manifest) { core.debug('No manifest cached'); - manifest = (yield getManifest(auth)); + manifest = yield getManifest(auth); } const releases = manifest - .filter(release => !!release.files.find(file => file.arch === arch)) - .map(release => release.version); + .map(item => { + const index = item.files.findIndex(item => item.arch === arch); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); return releases[0]; diff --git a/src/installer.ts b/src/installer.ts index 975ace211..84c9242f1 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -66,7 +66,7 @@ export async function getGo( versionSpec, auth, arch, - manifest as (tc.IToolRelease & IGoVersion)[] + manifest ); } @@ -279,7 +279,7 @@ export async function findMatch( versionSpec, undefined, arch, - fixedCandidates as (tc.IToolRelease & IGoVersion)[] + fixedCandidates ); } @@ -375,16 +375,22 @@ export async function resolveStableVersionInput( versionSpec: string, auth: string | undefined, arch = os.arch(), - manifest: (tc.IToolRelease & IGoVersion)[] | undefined + manifest: tc.IToolRelease[] | IGoVersion[] | undefined ): Promise { if (!manifest) { core.debug('No manifest cached'); - manifest = (await getManifest(auth)) as (tc.IToolRelease & IGoVersion)[]; + manifest = await getManifest(auth); } const releases = manifest - .filter(release => !!release.files.find(file => file.arch === arch)) - .map(release => release.version); + .map(item => { + const index = item.files.findIndex(item => item.arch === arch); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item); if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); From a965b3d47937dcf1a5fa6178d737715347884479 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 20:18:53 +0100 Subject: [PATCH 22/36] minor fix --- dist/setup/index.js | 15 ++++++++------- src/installer.ts | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 04c53eeeb..54b2908b7 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63231,9 +63231,13 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { let manifest; let osPlat = os_1.default.platform(); + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + manifest = yield getManifest(auth); + versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); + } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - manifest = yield getManifest(auth); const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, manifest); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -63243,11 +63247,6 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { core.info(`Failed to resolve version ${versionSpec} from manifest`); } } - if (versionSpec === utils_1.StableReleaseAlias.Stable || - versionSpec === utils_1.StableReleaseAlias.OldStable) { - manifest !== null && manifest !== void 0 ? manifest : (manifest = yield getManifest(auth)); - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); - } // check cache let toolPath; toolPath = tc.find('go', versionSpec, arch); @@ -63263,7 +63262,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { // Try download from internal distribution (popular versions only) // try { - info = yield getInfoFromManifest(versionSpec, true, auth, arch); + info = yield getInfoFromManifest(versionSpec, true, auth, arch, manifest); if (info) { downloadPath = yield installGoVersion(info, auth, arch); } @@ -63309,6 +63308,7 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) { return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { + console.log('didnt fail'); core.info('Unable to resolve a version from the manifest...'); core.debug(err.message); } @@ -63361,6 +63361,7 @@ function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch core.debug('No manifest cached'); manifest = yield getManifest(auth); } + console.log('didnt fail898998'); core.info(`matching ${versionSpec}...`); const rel = yield tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { diff --git a/src/installer.ts b/src/installer.ts index 84c9242f1..440273d84 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -39,9 +39,21 @@ export async function getGo( let manifest: tc.IToolRelease[] | undefined; let osPlat: string = os.platform(); + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + manifest = await getManifest(auth); + versionSpec = await resolveStableVersionInput( + versionSpec, + auth, + arch, + manifest + ); + } + if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - manifest = await getManifest(auth); const resolvedVersion = await resolveVersionFromManifest( versionSpec, true, @@ -57,19 +69,6 @@ export async function getGo( } } - if ( - versionSpec === StableReleaseAlias.Stable || - versionSpec === StableReleaseAlias.OldStable - ) { - manifest ??= await getManifest(auth); - versionSpec = await resolveStableVersionInput( - versionSpec, - auth, - arch, - manifest - ); - } - // check cache let toolPath: string; toolPath = tc.find('go', versionSpec, arch); @@ -86,7 +85,7 @@ export async function getGo( // Try download from internal distribution (popular versions only) // try { - info = await getInfoFromManifest(versionSpec, true, auth, arch); + info = await getInfoFromManifest(versionSpec, true, auth, arch, manifest); if (info) { downloadPath = await installGoVersion(info, auth, arch); } else { @@ -148,6 +147,7 @@ async function resolveVersionFromManifest( ); return info?.resolvedVersion; } catch (err) { + console.log('didnt fail'); core.info('Unable to resolve a version from the manifest...'); core.debug(err.message); } @@ -214,7 +214,7 @@ export async function getInfoFromManifest( core.debug('No manifest cached'); manifest = await getManifest(auth); } - + console.log('didnt fail898998'); core.info(`matching ${versionSpec}...`); const rel = await tc.findFromManifest(versionSpec, stable, manifest, arch); From 6cc33f66c0a46d93b6e722bd0a45d2e51462db58 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 20:51:30 +0100 Subject: [PATCH 23/36] change prettier version --- package-lock.json | 19 ++++++++----------- package.json | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d4490ca3..24d1487cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^2.8.0", + "prettier": "^1.17.1", "ts-jest": "^27.0.5", "typescript": "^4.3.3" } @@ -4062,18 +4062,15 @@ } }, "node_modules/prettier": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", - "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" + "node": ">=4" } }, "node_modules/pretty-format": { @@ -8121,9 +8118,9 @@ "dev": true }, "prettier": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", - "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, "pretty-format": { diff --git a/package.json b/package.json index 9a1aa88e8..a12677c09 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "jest": "^27.2.5", "jest-circus": "^27.2.5", "nock": "^10.0.6", - "prettier": "^2.8.0", + "prettier": "^1.17.1", "ts-jest": "^27.0.5", "typescript": "^4.3.3" } From 487336cf4aa836d9ee22df4a4064490f5c0f34e6 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 22:52:48 +0100 Subject: [PATCH 24/36] remove logs and rebuild --- dist/setup/index.js | 2 -- src/installer.ts | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 54b2908b7..b7bc811be 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63308,7 +63308,6 @@ function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) { return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { - console.log('didnt fail'); core.info('Unable to resolve a version from the manifest...'); core.debug(err.message); } @@ -63361,7 +63360,6 @@ function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch core.debug('No manifest cached'); manifest = yield getManifest(auth); } - console.log('didnt fail898998'); core.info(`matching ${versionSpec}...`); const rel = yield tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { diff --git a/src/installer.ts b/src/installer.ts index 440273d84..0062e76fb 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -147,7 +147,6 @@ async function resolveVersionFromManifest( ); return info?.resolvedVersion; } catch (err) { - console.log('didnt fail'); core.info('Unable to resolve a version from the manifest...'); core.debug(err.message); } @@ -214,7 +213,7 @@ export async function getInfoFromManifest( core.debug('No manifest cached'); manifest = await getManifest(auth); } - console.log('didnt fail898998'); + core.info(`matching ${versionSpec}...`); const rel = await tc.findFromManifest(versionSpec, stable, manifest, arch); From 3a18a011257c9fc49e794adfa30cee2fd84bd9d3 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 5 Dec 2022 23:08:49 +0100 Subject: [PATCH 25/36] format code --- src/installer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer.ts b/src/installer.ts index 0062e76fb..fdcfd8198 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -213,7 +213,7 @@ export async function getInfoFromManifest( core.debug('No manifest cached'); manifest = await getManifest(auth); } - + core.info(`matching ${versionSpec}...`); const rel = await tc.findFromManifest(versionSpec, stable, manifest, arch); From 7d444ba1e902988265a2ffbb3ec59a8d0fea0d53 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Tue, 6 Dec 2022 14:42:30 +0100 Subject: [PATCH 26/36] Add versions yaml e2e test for different architectures --- .github/workflows/versions.yml | 128 +++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 1291b08ed..64ebffcc0 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -42,6 +42,134 @@ jobs: - name: Verify Go run: go version + stable_arm64: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: arm64 + - name: Verify Go + run: go version + + oldstable_arm64: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: arm64 + - name: Verify Go + run: go version + + stable_x64: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: x64 + - name: Verify Go + run: go version + + oldstable_x64: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: x64 + - name: Verify Go + run: go version + + stable_arm32: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: arm + - name: Verify Go + run: go version + + oldstable_arm32: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: arm + - name: Verify Go + run: go version + + stable_x86: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: stable + architecture: x86 + - name: Verify Go + run: go version + + oldstable_x86: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: oldstable + architecture: x86 + - name: Verify Go + run: go version + local-cache: name: Setup local-cache version runs-on: ${{ matrix.os }} From 6df87edb46369cf15891be0920f10057e883eac1 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Tue, 6 Dec 2022 14:57:47 +0100 Subject: [PATCH 27/36] Cover edge cases when version doesnt exist --- dist/setup/index.js | 5 +++-- src/installer.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index b7bc811be..0294fdfe4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63405,7 +63405,7 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { const fixedCandidates = candidates.map(item => { return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); }); - versionSpec = yield resolveStableVersionInput(versionSpec, undefined, arch, fixedCandidates); + versionSpec = yield resolveStableVersionInput(versionSpec, undefined, archFilter, fixedCandidates); } let goFile; for (let i = 0; i < candidates.length; i++) { @@ -63480,6 +63480,7 @@ function parseGoVersionFile(versionFilePath) { } exports.parseGoVersionFile = parseGoVersionFile; function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), manifest) { + var _a; return __awaiter(this, void 0, void 0, function* () { if (!manifest) { core.debug('No manifest cached'); @@ -63496,7 +63497,7 @@ function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch() .filter(item => !!item); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); - return releases[0]; + return (_a = releases[0]) !== null && _a !== void 0 ? _a : versionSpec; } else { const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); diff --git a/src/installer.ts b/src/installer.ts index fdcfd8198..816f1352e 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -277,7 +277,7 @@ export async function findMatch( versionSpec = await resolveStableVersionInput( versionSpec, undefined, - arch, + archFilter, fixedCandidates ); } @@ -394,7 +394,7 @@ export async function resolveStableVersionInput( if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); - return releases[0]; + return releases[0] ?? versionSpec; } else { const versions = releases.map( release => `${semver.major(release)}.${semver.minor(release)}` From e4eab8e9e9fe8856e23314496e26299afb25fbaa Mon Sep 17 00:00:00 2001 From: panticmilos Date: Tue, 6 Dec 2022 15:00:07 +0100 Subject: [PATCH 28/36] Remove test version of version yaml architectures --- .github/workflows/versions.yml | 128 --------------------------------- 1 file changed, 128 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 64ebffcc0..1291b08ed 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -42,134 +42,6 @@ jobs: - name: Verify Go run: go version - stable_arm64: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: stable - architecture: arm64 - - name: Verify Go - run: go version - - oldstable_arm64: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: oldstable - architecture: arm64 - - name: Verify Go - run: go version - - stable_x64: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: stable - architecture: x64 - - name: Verify Go - run: go version - - oldstable_x64: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: oldstable - architecture: x64 - - name: Verify Go - run: go version - - stable_arm32: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: stable - architecture: arm - - name: Verify Go - run: go version - - oldstable_arm32: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: oldstable - architecture: arm - - name: Verify Go - run: go version - - stable_x86: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: stable - architecture: x86 - - name: Verify Go - run: go version - - oldstable_x86: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup Go and check latest - uses: ./ - with: - go-version: oldstable - architecture: x86 - - name: Verify Go - run: go version - local-cache: name: Setup local-cache version runs-on: ${{ matrix.os }} From 2a148a10b5ebe69344be4a3f1f50acee6cdcdce6 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Tue, 6 Dec 2022 15:38:15 +0100 Subject: [PATCH 29/36] Remove unnecessary fetching of manifest --- dist/setup/index.js | 10 +++------- src/installer.ts | 16 ++-------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 0294fdfe4..e056c655a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63234,7 +63234,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { manifest = yield getManifest(auth); - versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest); + versionSpec = yield resolveStableVersionInput(versionSpec, arch, manifest); } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); @@ -63405,7 +63405,7 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { const fixedCandidates = candidates.map(item => { return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); }); - versionSpec = yield resolveStableVersionInput(versionSpec, undefined, archFilter, fixedCandidates); + versionSpec = yield resolveStableVersionInput(versionSpec, archFilter, fixedCandidates); } let goFile; for (let i = 0; i < candidates.length; i++) { @@ -63479,13 +63479,9 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; -function resolveStableVersionInput(versionSpec, auth, arch = os_1.default.arch(), manifest) { +function resolveStableVersionInput(versionSpec, arch = os_1.default.arch(), manifest) { var _a; return __awaiter(this, void 0, void 0, function* () { - if (!manifest) { - core.debug('No manifest cached'); - manifest = yield getManifest(auth); - } const releases = manifest .map(item => { const index = item.files.findIndex(item => item.arch === arch); diff --git a/src/installer.ts b/src/installer.ts index 816f1352e..99f9930d1 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -44,12 +44,7 @@ export async function getGo( versionSpec === StableReleaseAlias.OldStable ) { manifest = await getManifest(auth); - versionSpec = await resolveStableVersionInput( - versionSpec, - auth, - arch, - manifest - ); + versionSpec = await resolveStableVersionInput(versionSpec, arch, manifest); } if (checkLatest) { @@ -276,7 +271,6 @@ export async function findMatch( }); versionSpec = await resolveStableVersionInput( versionSpec, - undefined, archFilter, fixedCandidates ); @@ -372,15 +366,9 @@ export function parseGoVersionFile(versionFilePath: string): string { export async function resolveStableVersionInput( versionSpec: string, - auth: string | undefined, arch = os.arch(), - manifest: tc.IToolRelease[] | IGoVersion[] | undefined + manifest: tc.IToolRelease[] | IGoVersion[] ): Promise { - if (!manifest) { - core.debug('No manifest cached'); - manifest = await getManifest(auth); - } - const releases = manifest .map(item => { const index = item.files.findIndex(item => item.arch === arch); From 3eeab9dd6de46eda218c479c5ed9289cfaad092c Mon Sep 17 00:00:00 2001 From: panticmilos Date: Wed, 7 Dec 2022 12:14:57 +0100 Subject: [PATCH 30/36] Include platform filter for aliases --- dist/setup/index.js | 8 ++++---- src/installer.ts | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index e056c655a..504e96fec 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63234,7 +63234,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { manifest = yield getManifest(auth); - versionSpec = yield resolveStableVersionInput(versionSpec, arch, manifest); + versionSpec = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); @@ -63405,7 +63405,7 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { const fixedCandidates = candidates.map(item => { return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); }); - versionSpec = yield resolveStableVersionInput(versionSpec, archFilter, fixedCandidates); + versionSpec = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); } let goFile; for (let i = 0; i < candidates.length; i++) { @@ -63479,12 +63479,12 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; -function resolveStableVersionInput(versionSpec, arch = os_1.default.arch(), manifest) { +function resolveStableVersionInput(versionSpec, arch = os_1.default.arch(), platform, manifest) { var _a; return __awaiter(this, void 0, void 0, function* () { const releases = manifest .map(item => { - const index = item.files.findIndex(item => item.arch === arch); + const index = item.files.findIndex(item => item.arch === arch && item.filename.includes(platform)); if (index === -1) { return ''; } diff --git a/src/installer.ts b/src/installer.ts index 99f9930d1..f35a2b59b 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -44,7 +44,12 @@ export async function getGo( versionSpec === StableReleaseAlias.OldStable ) { manifest = await getManifest(auth); - versionSpec = await resolveStableVersionInput(versionSpec, arch, manifest); + versionSpec = await resolveStableVersionInput( + versionSpec, + arch, + osPlat, + manifest + ); } if (checkLatest) { @@ -267,11 +272,15 @@ export async function findMatch( versionSpec === StableReleaseAlias.OldStable ) { const fixedCandidates = candidates.map(item => { - return {...item, version: makeSemver(item.version)}; + return { + ...item, + version: makeSemver(item.version) + }; }); versionSpec = await resolveStableVersionInput( versionSpec, archFilter, + platFilter, fixedCandidates ); } @@ -367,11 +376,14 @@ export function parseGoVersionFile(versionFilePath: string): string { export async function resolveStableVersionInput( versionSpec: string, arch = os.arch(), + platform: string, manifest: tc.IToolRelease[] | IGoVersion[] ): Promise { const releases = manifest .map(item => { - const index = item.files.findIndex(item => item.arch === arch); + const index = item.files.findIndex( + item => item.arch === arch && item.filename.includes(platform) + ); if (index === -1) { return ''; } From 97458b29d758efbbc9300b221d9864e1ef1189b2 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Thu, 8 Dec 2022 12:36:43 +0100 Subject: [PATCH 31/36] Remove unnecessary default value for arch argument --- dist/setup/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 504e96fec..d36d0191e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63479,7 +63479,7 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; -function resolveStableVersionInput(versionSpec, arch = os_1.default.arch(), platform, manifest) { +function resolveStableVersionInput(versionSpec, arch, platform, manifest) { var _a; return __awaiter(this, void 0, void 0, function* () { const releases = manifest diff --git a/src/installer.ts b/src/installer.ts index f35a2b59b..2b0808e13 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -375,7 +375,7 @@ export function parseGoVersionFile(versionFilePath: string): string { export async function resolveStableVersionInput( versionSpec: string, - arch = os.arch(), + arch: string, platform: string, manifest: tc.IToolRelease[] | IGoVersion[] ): Promise { From 9f0eac3260eb0afaf8b9b78b66a7c1707f1bb749 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Thu, 8 Dec 2022 16:23:00 +0100 Subject: [PATCH 32/36] Add filter for prerelease versions --- dist/setup/index.js | 2 +- src/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index d36d0191e..6e16a2ec6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63490,7 +63490,7 @@ function resolveStableVersionInput(versionSpec, arch, platform, manifest) { } return item.version; }) - .filter(item => !!item); + .filter(item => !!item && !semver.prerelease(item)); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); return (_a = releases[0]) !== null && _a !== void 0 ? _a : versionSpec; diff --git a/src/installer.ts b/src/installer.ts index 2b0808e13..9be22a993 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -389,7 +389,7 @@ export async function resolveStableVersionInput( } return item.version; }) - .filter(item => !!item); + .filter(item => !!item && !semver.prerelease(item)); if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); From 11e0301e1d18c4a82bd0463b1a1c217d18b31638 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 8 Dec 2022 21:59:01 +0100 Subject: [PATCH 33/36] fix error with toolcache --- dist/setup/index.js | 26 +++++++++++------------ src/installer.ts | 52 +++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6e16a2ec6..a49417993 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63234,7 +63234,18 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { if (versionSpec === utils_1.StableReleaseAlias.Stable || versionSpec === utils_1.StableReleaseAlias.OldStable) { manifest = yield getManifest(auth); - versionSpec = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); + let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); + if (!stableVersion) { + const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; + let candidates = yield module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + const fixedCandidates = candidates.map(item => { + return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); + }); + stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, fixedCandidates); + } } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); @@ -63400,13 +63411,6 @@ function findMatch(versionSpec, arch = os_1.default.arch()) { if (!candidates) { throw new Error(`golang download url did not return results`); } - if (versionSpec === utils_1.StableReleaseAlias.Stable || - versionSpec === utils_1.StableReleaseAlias.OldStable) { - const fixedCandidates = candidates.map(item => { - return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); - }); - versionSpec = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); - } let goFile; for (let i = 0; i < candidates.length; i++) { let candidate = candidates[i]; @@ -63480,7 +63484,6 @@ function parseGoVersionFile(versionFilePath) { } exports.parseGoVersionFile = parseGoVersionFile; function resolveStableVersionInput(versionSpec, arch, platform, manifest) { - var _a; return __awaiter(this, void 0, void 0, function* () { const releases = manifest .map(item => { @@ -63493,16 +63496,13 @@ function resolveStableVersionInput(versionSpec, arch, platform, manifest) { .filter(item => !!item && !semver.prerelease(item)); if (versionSpec === utils_1.StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); - return (_a = releases[0]) !== null && _a !== void 0 ? _a : versionSpec; + return releases[0]; } else { const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); const uniqueVersions = Array.from(new Set(versions)); const oldstableVersion = releases.find(item => item.startsWith(uniqueVersions[1])); core.info(`oldstable version resolved as ${oldstableVersion}`); - if (!oldstableVersion) { - return versionSpec; - } return oldstableVersion; } }); diff --git a/src/installer.ts b/src/installer.ts index 9be22a993..acea2ba70 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -44,12 +44,36 @@ export async function getGo( versionSpec === StableReleaseAlias.OldStable ) { manifest = await getManifest(auth); - versionSpec = await resolveStableVersionInput( + let stableVersion = await resolveStableVersionInput( versionSpec, arch, osPlat, manifest ); + + if (!stableVersion) { + const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; + let candidates: + | IGoVersion[] + | null = await module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + + const fixedCandidates = candidates.map(item => { + return { + ...item, + version: makeSemver(item.version) + }; + }); + + stableVersion = await resolveStableVersionInput( + versionSpec, + arch, + osPlat, + fixedCandidates + ); + } } if (checkLatest) { @@ -267,24 +291,6 @@ export async function findMatch( throw new Error(`golang download url did not return results`); } - if ( - versionSpec === StableReleaseAlias.Stable || - versionSpec === StableReleaseAlias.OldStable - ) { - const fixedCandidates = candidates.map(item => { - return { - ...item, - version: makeSemver(item.version) - }; - }); - versionSpec = await resolveStableVersionInput( - versionSpec, - archFilter, - platFilter, - fixedCandidates - ); - } - let goFile: IGoVersionFile | undefined; for (let i = 0; i < candidates.length; i++) { let candidate: IGoVersion = candidates[i]; @@ -378,7 +384,7 @@ export async function resolveStableVersionInput( arch: string, platform: string, manifest: tc.IToolRelease[] | IGoVersion[] -): Promise { +) { const releases = manifest .map(item => { const index = item.files.findIndex( @@ -394,7 +400,7 @@ export async function resolveStableVersionInput( if (versionSpec === StableReleaseAlias.Stable) { core.info(`stable version resolved as ${releases[0]}`); - return releases[0] ?? versionSpec; + return releases[0]; } else { const versions = releases.map( release => `${semver.major(release)}.${semver.minor(release)}` @@ -407,10 +413,6 @@ export async function resolveStableVersionInput( core.info(`oldstable version resolved as ${oldstableVersion}`); - if (!oldstableVersion) { - return versionSpec; - } - return oldstableVersion; } } From 5a5cdc8151239e38aa97416025497a8c1460f31f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 8 Dec 2022 22:10:41 +0100 Subject: [PATCH 34/36] minor fix --- dist/setup/index.js | 8 +++++++- src/installer.ts | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index a49417993..806c1b1a3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63236,6 +63236,8 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { manifest = yield getManifest(auth); let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); if (!stableVersion) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; let candidates = yield module.exports.getVersionsDist(dlUrl); if (!candidates) { @@ -63244,8 +63246,12 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { const fixedCandidates = candidates.map(item => { return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); }); - stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, fixedCandidates); + stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); + if (!stableVersion) { + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); + } } + versionSpec = stableVersion; } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); diff --git a/src/installer.ts b/src/installer.ts index acea2ba70..f6fda1cbc 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -52,6 +52,8 @@ export async function getGo( ); if (!stableVersion) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; let candidates: | IGoVersion[] @@ -69,11 +71,19 @@ export async function getGo( stableVersion = await resolveStableVersionInput( versionSpec, - arch, - osPlat, + archFilter, + platFilter, fixedCandidates ); + + if (!stableVersion) { + throw new Error( + `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.` + ); + } } + + versionSpec = stableVersion; } if (checkLatest) { From 7e3178723ab9e083a52632761f742acdcd249e8b Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 8 Dec 2022 22:20:19 +0100 Subject: [PATCH 35/36] polish code --- dist/setup/index.js | 28 ++++++++++++++---------- src/installer.ts | 53 +++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 806c1b1a3..7b0f1c428 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63236,17 +63236,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { manifest = yield getManifest(auth); let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); if (!stableVersion) { - let archFilter = sys.getArch(arch); - let platFilter = sys.getPlatform(); - const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; - let candidates = yield module.exports.getVersionsDist(dlUrl); - if (!candidates) { - throw new Error(`golang download url did not return results`); - } - const fixedCandidates = candidates.map(item => { - return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); - }); - stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); + stableVersion = yield resolveStableVersionDist(versionSpec, arch); if (!stableVersion) { throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); } @@ -63489,6 +63479,22 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; +function resolveStableVersionDist(versionSpec, arch) { + return __awaiter(this, void 0, void 0, function* () { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; + let candidates = yield module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + const fixedCandidates = candidates.map(item => { + return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); + }); + const stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); + return stableVersion; + }); +} function resolveStableVersionInput(versionSpec, arch, platform, manifest) { return __awaiter(this, void 0, void 0, function* () { const releases = manifest diff --git a/src/installer.ts b/src/installer.ts index f6fda1cbc..3657447b3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -52,30 +52,7 @@ export async function getGo( ); if (!stableVersion) { - let archFilter = sys.getArch(arch); - let platFilter = sys.getPlatform(); - const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; - let candidates: - | IGoVersion[] - | null = await module.exports.getVersionsDist(dlUrl); - if (!candidates) { - throw new Error(`golang download url did not return results`); - } - - const fixedCandidates = candidates.map(item => { - return { - ...item, - version: makeSemver(item.version) - }; - }); - - stableVersion = await resolveStableVersionInput( - versionSpec, - archFilter, - platFilter, - fixedCandidates - ); - + stableVersion = await resolveStableVersionDist(versionSpec, arch); if (!stableVersion) { throw new Error( `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.` @@ -389,6 +366,34 @@ export function parseGoVersionFile(versionFilePath: string): string { return contents.trim(); } +async function resolveStableVersionDist(versionSpec: string, arch: string) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; + let candidates: IGoVersion[] | null = await module.exports.getVersionsDist( + dlUrl + ); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + + const fixedCandidates = candidates.map(item => { + return { + ...item, + version: makeSemver(item.version) + }; + }); + + const stableVersion = await resolveStableVersionInput( + versionSpec, + archFilter, + platFilter, + fixedCandidates + ); + + return stableVersion; +} + export async function resolveStableVersionInput( versionSpec: string, arch: string, From 7cf57d7094bd25d126f6577c104c2e5b72284034 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 9 Dec 2022 01:23:08 +0100 Subject: [PATCH 36/36] add job aliases with different arch --- .github/workflows/versions.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 1291b08ed..95d1b6aa9 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -20,7 +20,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 - - name: Setup Go and check latest + - name: Setup Go Stable uses: ./ with: go-version: stable @@ -35,12 +35,33 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 - - name: Setup Go and check latest + - name: Setup Go oldStable uses: ./ with: go-version: oldstable - name: Verify Go run: go version + + aliases-arch: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + version: [stable, oldstable] + architecture: [x64, x32] + exclude: + - os: macos-latest + architecture: x32 + steps: + - uses: actions/checkout@v3 + - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} + uses: ./ + with: + go-version: ${{ matrix.version }} + architecture: ${{ matrix.architecture }} + - name: Verify Go + run: go version local-cache: name: Setup local-cache version