From cac6a2b9805a415da1a7a844fb701f4bd0ce4912 Mon Sep 17 00:00:00 2001 From: Daniel Bast <2790401+dbast@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:31:54 +0100 Subject: [PATCH] Run "npm run format" + "npm run build" --- dist/delete/index.js | 76 +- dist/setup/index.js | 1954 ++++++++++----------------- src/base-tools/index.ts | 4 +- src/base-tools/update-mamba.ts | 2 +- src/conda.ts | 14 +- src/delete.ts | 2 +- src/env/explicit.ts | 4 +- src/env/index.ts | 10 +- src/env/yaml.ts | 10 +- src/input.ts | 15 +- src/installer/base.ts | 8 +- src/installer/download-miniconda.ts | 8 +- src/installer/download-miniforge.ts | 6 +- src/installer/index.ts | 4 +- src/outputs.ts | 6 +- src/setup.ts | 26 +- src/types.ts | 14 +- 17 files changed, 787 insertions(+), 1376 deletions(-) diff --git a/dist/delete/index.js b/dist/delete/index.js index 48071eed..dd353a5d 100644 --- a/dist/delete/index.js +++ b/dist/delete/index.js @@ -558,7 +558,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { @@ -2532,11 +2532,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var _a; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; +exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; const fs = __importStar(__nccwpck_require__(147)); const path = __importStar(__nccwpck_require__(17)); -_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +_a = fs.promises +// export const {open} = 'fs' +, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +// export const {open} = 'fs' exports.IS_WINDOWS = process.platform === 'win32'; +// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691 +exports.UV_FS_O_EXLOCK = 0x10000000; +exports.READONLY = fs.constants.O_RDONLY; function exists(fsPath) { return __awaiter(this, void 0, void 0, function* () { try { @@ -2717,12 +2723,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", ({ value: true })); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; const assert_1 = __nccwpck_require__(491); -const childProcess = __importStar(__nccwpck_require__(81)); const path = __importStar(__nccwpck_require__(17)); -const util_1 = __nccwpck_require__(837); const ioUtil = __importStar(__nccwpck_require__(962)); -const exec = util_1.promisify(childProcess.exec); -const execFile = util_1.promisify(childProcess.execFile); /** * Copies a file or folder. * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js @@ -2803,61 +2805,23 @@ exports.mv = mv; function rmRF(inputPath) { return __awaiter(this, void 0, void 0, function* () { if (ioUtil.IS_WINDOWS) { - // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another - // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. // Check for invalid characters // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (/[*"<>|]/.test(inputPath)) { throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); } - try { - const cmdPath = ioUtil.getCmdPath(); - if (yield ioUtil.isDirectory(inputPath, true)) { - yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { - env: { inputPath } - }); - } - else { - yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { - env: { inputPath } - }); - } - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } - // Shelling out fails to remove a symlink folder with missing source, this unlink catches that - try { - yield ioUtil.unlink(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } } - else { - let isDir = false; - try { - isDir = yield ioUtil.isDirectory(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - return; - } - if (isDir) { - yield execFile(`rm`, [`-rf`, `${inputPath}`]); - } - else { - yield ioUtil.unlink(inputPath); - } + try { + // note if path does not exist, error is silent + yield ioUtil.rm(inputPath, { + force: true, + maxRetries: 3, + recursive: true, + retryDelay: 300 + }); + } + catch (err) { + throw new Error(`File was unable to be removed ${err}`); } }); } diff --git a/dist/setup/index.js b/dist/setup/index.js index 3276506f..b01d8f43 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -558,7 +558,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { @@ -2532,11 +2532,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var _a; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; +exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; const fs = __importStar(__nccwpck_require__(7147)); const path = __importStar(__nccwpck_require__(1017)); -_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +_a = fs.promises +// export const {open} = 'fs' +, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +// export const {open} = 'fs' exports.IS_WINDOWS = process.platform === 'win32'; +// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691 +exports.UV_FS_O_EXLOCK = 0x10000000; +exports.READONLY = fs.constants.O_RDONLY; function exists(fsPath) { return __awaiter(this, void 0, void 0, function* () { try { @@ -2717,12 +2723,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", ({ value: true })); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; const assert_1 = __nccwpck_require__(9491); -const childProcess = __importStar(__nccwpck_require__(2081)); const path = __importStar(__nccwpck_require__(1017)); -const util_1 = __nccwpck_require__(3837); const ioUtil = __importStar(__nccwpck_require__(1962)); -const exec = util_1.promisify(childProcess.exec); -const execFile = util_1.promisify(childProcess.execFile); /** * Copies a file or folder. * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js @@ -2803,61 +2805,23 @@ exports.mv = mv; function rmRF(inputPath) { return __awaiter(this, void 0, void 0, function* () { if (ioUtil.IS_WINDOWS) { - // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another - // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. // Check for invalid characters // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (/[*"<>|]/.test(inputPath)) { throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); } - try { - const cmdPath = ioUtil.getCmdPath(); - if (yield ioUtil.isDirectory(inputPath, true)) { - yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { - env: { inputPath } - }); - } - else { - yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { - env: { inputPath } - }); - } - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } - // Shelling out fails to remove a symlink folder with missing source, this unlink catches that - try { - yield ioUtil.unlink(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } } - else { - let isDir = false; - try { - isDir = yield ioUtil.isDirectory(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - return; - } - if (isDir) { - yield execFile(`rm`, [`-rf`, `${inputPath}`]); - } - else { - yield ioUtil.unlink(inputPath); - } + try { + // note if path does not exist, error is silent + yield ioUtil.rm(inputPath, { + force: true, + maxRetries: 3, + recursive: true, + retryDelay: 300 + }); + } + catch (err) { + throw new Error(`File was unable to be removed ${err}`); } }); } @@ -5658,76 +5622,6 @@ function v4(options, buf, offset) { module.exports = v4; -/***/ }), - -/***/ 1530: -/***/ ((module) => { - -"use strict"; - - -// there's 3 implementations written in increasing order of efficiency - -// 1 - no Set type is defined -function uniqNoSet(arr) { - var ret = []; - - for (var i = 0; i < arr.length; i++) { - if (ret.indexOf(arr[i]) === -1) { - ret.push(arr[i]); - } - } - - return ret; -} - -// 2 - a simple Set type is defined -function uniqSet(arr) { - var seen = new Set(); - return arr.filter(function (el) { - if (!seen.has(el)) { - seen.add(el); - return true; - } - - return false; - }); -} - -// 3 - a standard Set type is defined and it has a forEach method -function uniqSetWithForEach(arr) { - var ret = []; - - (new Set(arr)).forEach(function (el) { - ret.push(el); - }); - - return ret; -} - -// V8 currently has a broken implementation -// https://github.com/joyent/node/issues/8449 -function doesForEachActuallyWork() { - var ret = false; - - (new Set([true])).forEach(function (el) { - ret = el; - }); - - return ret === true; -} - -if ('Set' in global) { - if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { - module.exports = uniqSetWithForEach; - } else { - module.exports = uniqSet; - } -} else { - module.exports = uniqNoSet; -} - - /***/ }), /***/ 4159: @@ -14467,108 +14361,93 @@ Object.defineProperty(exports, "decodeXMLStrict", ({ enumerable: true, get: func /***/ }), -/***/ 7198: -/***/ ((module) => { - -"use strict"; -/*! - * for-in - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - - - -module.exports = function forIn(obj, fn, thisArg) { - for (var key in obj) { - if (fn.call(thisArg, obj[key], key, obj) === false) { - break; - } - } -}; - - -/***/ }), - -/***/ 7281: +/***/ 5013: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -/*! - * for-own - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - +const {URL} = __nccwpck_require__(7310); +const cheerio = __nccwpck_require__(4612); +const normalizeUrl = __nccwpck_require__(7952); -var forIn = __nccwpck_require__(7198); -var hasOwn = Object.prototype.hasOwnProperty; +const FAKE_PROTOCOL = 'fake:'; +const FAKE_HOSTNAME = 'base.url'; -module.exports = function forOwn(obj, fn, thisArg) { - forIn(obj, function(val, key) { - if (hasOwn.call(obj, key)) { - return fn.call(thisArg, obj[key], key, obj); - } - }); +const defaultNormalizeOpts = { + stripWWW: false, + defaultProtocol: '' +}; +const defaultAllowedProtocols = { + http: true, + https: true }; +const unique = arr => [...new Set(arr)]; -/***/ }), - -/***/ 5013: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; +const tryNormalize = (url, opts) => { + try { + return normalizeUrl(url, opts); + } catch (error) { + return url; + } +}; -const url = __nccwpck_require__(7310); -const cheerio = __nccwpck_require__(4612); -const normalizeUrl = __nccwpck_require__(7952); -const arrayUniq = __nccwpck_require__(1530); -const omit = __nccwpck_require__(3627); +const isFake = url => + url.protocol === FAKE_PROTOCOL && url.hostname === FAKE_HOSTNAME; -module.exports = getHrefs; +const stripFake = url => + url.slice(FAKE_PROTOCOL.length + FAKE_HOSTNAME.length + 2); -function getHrefs(html, opts) { +const getHrefs = ( + html, + { + baseUrl = `${FAKE_PROTOCOL}//${FAKE_HOSTNAME}`, + allowedProtocols, + ...normalizeOpts + } = {} +) => { if (typeof html !== 'string') { - throw new TypeError('getHrefs expected a `string` but got: `' + typeof html + '`'); + throw new TypeError( + `getHrefs expected a \`string\` but got: \`${typeof html}\`` + ); } - opts = opts || {}; + + const opts = {...defaultNormalizeOpts, ...normalizeOpts}; + const protocols = {...defaultAllowedProtocols, ...allowedProtocols}; const $ = cheerio.load(html); - let baseUrl = opts.baseUrl || ''; const base = $('base'); - const normalizeOpts = omit(opts, ['baseUrl']); if (base.length !== 0) { - baseUrl = url.resolve(baseUrl, base.first().attr('href') || ''); + baseUrl = new URL(base.first().attr('href') || '', baseUrl).toString(); } const hrefs = $('a') - .filter(function () { - /* eslint no-script-url: 0 */ - const href = $(this).attr('href'); - return href && - href !== '#' && - href.indexOf('javascript:') !== 0; - }) - .map(function () { - let href = $(this).attr('href'); - href = url.resolve(baseUrl, href); - if (hasProtocol(href)) { - return normalizeUrl(href, normalizeOpts); - } - return href; - }) + .map((_, el) => $(el).attr('href')) .get(); - return arrayUniq(hrefs); -} + const filteredHrefs = hrefs.reduce((hrefs, href) => { + if (!href || href === '#') { + return hrefs; + } -function hasProtocol(href) { - return href.indexOf('://') !== -1 || href.indexOf('//') === 0; -} + try { + const url = new URL(href, baseUrl); + if (isFake(url)) { + hrefs.push(stripFake(tryNormalize(url.toString(), opts))); + } else if (protocols[url.protocol.slice(0, -1)]) { + hrefs.push(tryNormalize(url.toString(), opts)); + } + } catch (error) { + // Ignore errors (they are caused by invalid URLs and we don't care about them anyway) + } + + return hrefs; + }, []); + + return unique(filteredHrefs); +}; + +module.exports = getHrefs; /***/ }), @@ -16110,42 +15989,6 @@ exports.parseFeed = parseFeed; exports.DomUtils = __importStar(__nccwpck_require__(1754)); //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 429: -/***/ ((module) => { - -"use strict"; -/*! - * is-extendable - * - * Copyright (c) 2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - - - -module.exports = function isExtendable(val) { - return typeof val !== 'undefined' && val !== null - && (typeof val === 'object' || typeof val === 'function'); -}; - - -/***/ }), - -/***/ 864: -/***/ ((module) => { - -"use strict"; - -var toString = Object.prototype.toString; - -module.exports = function (x) { - var prototype; - return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({})); -}; - - /***/ }), /***/ 1917: @@ -20256,236 +20099,586 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', { /***/ }), -/***/ 7952: +/***/ 7129: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var url = __nccwpck_require__(7310); -var punycode = __nccwpck_require__(5477); -var queryString = __nccwpck_require__(293); -var prependHttp = __nccwpck_require__(6143); -var sortKeys = __nccwpck_require__(4376); -var objectAssign = __nccwpck_require__(7426); - -var DEFAULT_PORTS = { - 'http:': 80, - 'https:': 443, - 'ftp:': 21 -}; - -// protocols that always contain a `//`` bit -var slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true -}; - -function testParameter(name, filters) { - return filters.some(function (filter) { - return filter instanceof RegExp ? filter.test(name) : filter === name; - }); -} - -module.exports = function (str, opts) { - opts = objectAssign({ - normalizeProtocol: true, - normalizeHttps: false, - stripFragment: true, - stripWWW: true, - removeQueryParameters: [/^utm_\w+/i], - removeTrailingSlash: true, - removeDirectoryIndex: false - }, opts); - if (typeof str !== 'string') { - throw new TypeError('Expected a string'); - } +// A linked list to keep track of recently-used-ness +const Yallist = __nccwpck_require__(665) - var hasRelativeProtocol = str.indexOf('//') === 0; +const MAX = Symbol('max') +const LENGTH = Symbol('length') +const LENGTH_CALCULATOR = Symbol('lengthCalculator') +const ALLOW_STALE = Symbol('allowStale') +const MAX_AGE = Symbol('maxAge') +const DISPOSE = Symbol('dispose') +const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') +const LRU_LIST = Symbol('lruList') +const CACHE = Symbol('cache') +const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') - // prepend protocol - str = prependHttp(str.trim()).replace(/^\/\//, 'http://'); +const naiveLength = () => 1 - var urlObj = url.parse(str); +// lruList is a yallist where the head is the youngest +// item, and the tail is the oldest. the list contains the Hit +// objects as the entries. +// Each Hit object has a reference to its Yallist.Node. This +// never changes. +// +// cache is a Map (or PseudoMap) that matches the keys to +// the Yallist.Node object. +class LRUCache { + constructor (options) { + if (typeof options === 'number') + options = { max: options } - if (opts.normalizeHttps && urlObj.protocol === 'https:') { - urlObj.protocol = 'http:'; - } + if (!options) + options = {} - if (!urlObj.hostname && !urlObj.pathname) { - throw new Error('Invalid URL'); - } + if (options.max && (typeof options.max !== 'number' || options.max < 0)) + throw new TypeError('max must be a non-negative number') + // Kind of weird to have a default max of Infinity, but oh well. + const max = this[MAX] = options.max || Infinity - // prevent these from being used by `url.format` - delete urlObj.host; - delete urlObj.query; + const lc = options.length || naiveLength + this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc + this[ALLOW_STALE] = options.stale || false + if (options.maxAge && typeof options.maxAge !== 'number') + throw new TypeError('maxAge must be a number') + this[MAX_AGE] = options.maxAge || 0 + this[DISPOSE] = options.dispose + this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false + this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false + this.reset() + } - // remove fragment - if (opts.stripFragment) { - delete urlObj.hash; - } + // resize the cache when the max changes. + set max (mL) { + if (typeof mL !== 'number' || mL < 0) + throw new TypeError('max must be a non-negative number') - // remove default port - var port = DEFAULT_PORTS[urlObj.protocol]; - if (Number(urlObj.port) === port) { - delete urlObj.port; - } + this[MAX] = mL || Infinity + trim(this) + } + get max () { + return this[MAX] + } - // remove duplicate slashes - if (urlObj.pathname) { - urlObj.pathname = urlObj.pathname.replace(/\/{2,}/g, '/'); - } + set allowStale (allowStale) { + this[ALLOW_STALE] = !!allowStale + } + get allowStale () { + return this[ALLOW_STALE] + } - // decode URI octets - if (urlObj.pathname) { - urlObj.pathname = decodeURI(urlObj.pathname); - } + set maxAge (mA) { + if (typeof mA !== 'number') + throw new TypeError('maxAge must be a non-negative number') - // remove directory index - if (opts.removeDirectoryIndex === true) { - opts.removeDirectoryIndex = [/^index\.[a-z]+$/]; - } + this[MAX_AGE] = mA + trim(this) + } + get maxAge () { + return this[MAX_AGE] + } - if (Array.isArray(opts.removeDirectoryIndex) && opts.removeDirectoryIndex.length) { - var pathComponents = urlObj.pathname.split('/'); - var lastComponent = pathComponents[pathComponents.length - 1]; + // resize the cache when the lengthCalculator changes. + set lengthCalculator (lC) { + if (typeof lC !== 'function') + lC = naiveLength - if (testParameter(lastComponent, opts.removeDirectoryIndex)) { - pathComponents = pathComponents.slice(0, pathComponents.length - 1); - urlObj.pathname = pathComponents.slice(1).join('/') + '/'; - } - } + if (lC !== this[LENGTH_CALCULATOR]) { + this[LENGTH_CALCULATOR] = lC + this[LENGTH] = 0 + this[LRU_LIST].forEach(hit => { + hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) + this[LENGTH] += hit.length + }) + } + trim(this) + } + get lengthCalculator () { return this[LENGTH_CALCULATOR] } - // resolve relative paths, but only for slashed protocols - if (slashedProtocol[urlObj.protocol]) { - var domain = urlObj.protocol + '//' + urlObj.hostname; - var relative = url.resolve(domain, urlObj.pathname); - urlObj.pathname = relative.replace(domain, ''); - } + get length () { return this[LENGTH] } + get itemCount () { return this[LRU_LIST].length } - if (urlObj.hostname) { - // IDN to Unicode - urlObj.hostname = punycode.toUnicode(urlObj.hostname).toLowerCase(); + rforEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].tail; walker !== null;) { + const prev = walker.prev + forEachStep(this, fn, walker, thisp) + walker = prev + } + } - // remove trailing dot - urlObj.hostname = urlObj.hostname.replace(/\.$/, ''); + forEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].head; walker !== null;) { + const next = walker.next + forEachStep(this, fn, walker, thisp) + walker = next + } + } - // remove `www.` - if (opts.stripWWW) { - urlObj.hostname = urlObj.hostname.replace(/^www\./, ''); - } - } + keys () { + return this[LRU_LIST].toArray().map(k => k.key) + } - // remove URL with empty query string - if (urlObj.search === '?') { - delete urlObj.search; - } + values () { + return this[LRU_LIST].toArray().map(k => k.value) + } + + reset () { + if (this[DISPOSE] && + this[LRU_LIST] && + this[LRU_LIST].length) { + this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) + } - var queryParameters = queryString.parse(urlObj.search); + this[CACHE] = new Map() // hash of items by key + this[LRU_LIST] = new Yallist() // list of items in order of use recency + this[LENGTH] = 0 // length of items in the list + } - // remove query unwanted parameters - if (Array.isArray(opts.removeQueryParameters)) { - for (var key in queryParameters) { - if (testParameter(key, opts.removeQueryParameters)) { - delete queryParameters[key]; - } - } - } + dump () { + return this[LRU_LIST].map(hit => + isStale(this, hit) ? false : { + k: hit.key, + v: hit.value, + e: hit.now + (hit.maxAge || 0) + }).toArray().filter(h => h) + } - // sort query parameters - urlObj.search = queryString.stringify(sortKeys(queryParameters)); + dumpLru () { + return this[LRU_LIST] + } - // decode query parameters - urlObj.search = decodeURIComponent(urlObj.search); + set (key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE] - // take advantage of many of the Node `url` normalizations - str = url.format(urlObj); + if (maxAge && typeof maxAge !== 'number') + throw new TypeError('maxAge must be a number') - // remove ending `/` - if (opts.removeTrailingSlash || urlObj.pathname === '/') { - str = str.replace(/\/$/, ''); - } + const now = maxAge ? Date.now() : 0 + const len = this[LENGTH_CALCULATOR](value, key) - // restore relative protocol, if applicable - if (hasRelativeProtocol && !opts.normalizeProtocol) { - str = str.replace(/^http:\/\//, '//'); - } + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)) + return false + } - return str; -}; + const node = this[CACHE].get(key) + const item = node.value + + // dispose of the old one before overwriting + // split out into 2 ifs for better coverage tracking + if (this[DISPOSE]) { + if (!this[NO_DISPOSE_ON_SET]) + this[DISPOSE](key, item.value) + } + + item.now = now + item.maxAge = maxAge + item.value = value + this[LENGTH] += len - item.length + item.length = len + this.get(key) + trim(this) + return true + } + + const hit = new Entry(key, value, len, now, maxAge) + + // oversized objects fall out of cache automatically. + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value) + + return false + } + + this[LENGTH] += hit.length + this[LRU_LIST].unshift(hit) + this[CACHE].set(key, this[LRU_LIST].head) + trim(this) + return true + } + + has (key) { + if (!this[CACHE].has(key)) return false + const hit = this[CACHE].get(key).value + return !isStale(this, hit) + } + + get (key) { + return get(this, key, true) + } + + peek (key) { + return get(this, key, false) + } + + pop () { + const node = this[LRU_LIST].tail + if (!node) + return null + + del(this, node) + return node.value + } + + del (key) { + del(this, this[CACHE].get(key)) + } + + load (arr) { + // reset the cache + this.reset() + + const now = Date.now() + // A previous serialized cache has the most recent items first + for (let l = arr.length - 1; l >= 0; l--) { + const hit = arr[l] + const expiresAt = hit.e || 0 + if (expiresAt === 0) + // the item was created without expiration in a non aged cache + this.set(hit.k, hit.v) + else { + const maxAge = expiresAt - now + // dont add already expired items + if (maxAge > 0) { + this.set(hit.k, hit.v, maxAge) + } + } + } + } + + prune () { + this[CACHE].forEach((value, key) => get(this, key, false)) + } +} + +const get = (self, key, doUse) => { + const node = self[CACHE].get(key) + if (node) { + const hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + return undefined + } else { + if (doUse) { + if (self[UPDATE_AGE_ON_GET]) + node.value.now = Date.now() + self[LRU_LIST].unshiftNode(node) + } + } + return hit.value + } +} + +const isStale = (self, hit) => { + if (!hit || (!hit.maxAge && !self[MAX_AGE])) + return false + + const diff = Date.now() - hit.now + return hit.maxAge ? diff > hit.maxAge + : self[MAX_AGE] && (diff > self[MAX_AGE]) +} + +const trim = self => { + if (self[LENGTH] > self[MAX]) { + for (let walker = self[LRU_LIST].tail; + self[LENGTH] > self[MAX] && walker !== null;) { + // We know that we're about to delete this one, and also + // what the next least recently used key will be, so just + // go ahead and set it now. + const prev = walker.prev + del(self, walker) + walker = prev + } + } +} + +const del = (self, node) => { + if (node) { + const hit = node.value + if (self[DISPOSE]) + self[DISPOSE](hit.key, hit.value) + + self[LENGTH] -= hit.length + self[CACHE].delete(hit.key) + self[LRU_LIST].removeNode(node) + } +} + +class Entry { + constructor (key, value, length, now, maxAge) { + this.key = key + this.value = value + this.length = length + this.now = now + this.maxAge = maxAge || 0 + } +} + +const forEachStep = (self, fn, node, thisp) => { + let hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + hit = undefined + } + if (hit) + fn.call(thisp, hit.value, hit.key, self) +} + +module.exports = LRUCache /***/ }), -/***/ 4376: +/***/ 7952: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var isPlainObj = __nccwpck_require__(864); +// TODO: Use the `URL` global when targeting Node.js 10 +const URLParser = typeof URL === 'undefined' ? (__nccwpck_require__(7310).URL) : URL; + +// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs +const DATA_URL_DEFAULT_MIME_TYPE = 'text/plain'; +const DATA_URL_DEFAULT_CHARSET = 'us-ascii'; + +const testParameter = (name, filters) => { + return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name); +}; + +const normalizeDataURL = (urlString, {stripHash}) => { + const parts = urlString.match(/^data:([^,]*?),([^#]*?)(?:#(.*))?$/); -module.exports = function (obj, opts) { - if (!isPlainObj(obj)) { - throw new TypeError('Expected a plain object'); + if (!parts) { + throw new Error(`Invalid URL: ${urlString}`); } - opts = opts || {}; + const mediaType = parts[1].split(';'); + const body = parts[2]; + const hash = stripHash ? '' : parts[3]; + + let base64 = false; - // DEPRECATED - if (typeof opts === 'function') { - opts = {compare: opts}; + if (mediaType[mediaType.length - 1] === 'base64') { + mediaType.pop(); + base64 = true; } - var deep = opts.deep; - var seenInput = []; - var seenOutput = []; + // Lowercase MIME type + const mimeType = (mediaType.shift() || '').toLowerCase(); + const attributes = mediaType + .map(attribute => { + let [key, value = ''] = attribute.split('=').map(string => string.trim()); - var sortKeys = function (x) { - var seenIndex = seenInput.indexOf(x); + // Lowercase `charset` + if (key === 'charset') { + value = value.toLowerCase(); - if (seenIndex !== -1) { - return seenOutput[seenIndex]; - } + if (value === DATA_URL_DEFAULT_CHARSET) { + return ''; + } + } - var ret = {}; - var keys = Object.keys(x).sort(opts.compare); + return `${key}${value ? `=${value}` : ''}`; + }) + .filter(Boolean); - seenInput.push(x); - seenOutput.push(ret); + const normalizedMediaType = [ + ...attributes + ]; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var val = x[key]; + if (base64) { + normalizedMediaType.push('base64'); + } - ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val; - } + if (normalizedMediaType.length !== 0 || (mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE)) { + normalizedMediaType.unshift(mimeType); + } + + return `data:${normalizedMediaType.join(';')},${base64 ? body.trim() : body}${hash ? `#${hash}` : ''}`; +}; - return ret; +const normalizeUrl = (urlString, options) => { + options = { + defaultProtocol: 'http:', + normalizeProtocol: true, + forceHttp: false, + forceHttps: false, + stripAuthentication: true, + stripHash: false, + stripWWW: true, + removeQueryParameters: [/^utm_\w+/i], + removeTrailingSlash: true, + removeDirectoryIndex: false, + sortQueryParameters: true, + ...options }; - return sortKeys(obj); -}; + // TODO: Remove this at some point in the future + if (Reflect.has(options, 'normalizeHttps')) { + throw new Error('options.normalizeHttps is renamed to options.forceHttp'); + } + if (Reflect.has(options, 'normalizeHttp')) { + throw new Error('options.normalizeHttp is renamed to options.forceHttps'); + } -/***/ }), + if (Reflect.has(options, 'stripFragment')) { + throw new Error('options.stripFragment is renamed to options.stripHash'); + } -/***/ 9241: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + urlString = urlString.trim(); -"use strict"; + // Data URL + if (/^data:/i.test(urlString)) { + return normalizeDataURL(urlString, options); + } -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); + const hasRelativeProtocol = urlString.startsWith('//'); + const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString); + + // Prepend protocol + if (!isRelativeUrl) { + urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol); + } + + const urlObj = new URLParser(urlString); + + if (options.forceHttp && options.forceHttps) { + throw new Error('The `forceHttp` and `forceHttps` options cannot be used together'); + } + + if (options.forceHttp && urlObj.protocol === 'https:') { + urlObj.protocol = 'http:'; + } + + if (options.forceHttps && urlObj.protocol === 'http:') { + urlObj.protocol = 'https:'; + } + + // Remove auth + if (options.stripAuthentication) { + urlObj.username = ''; + urlObj.password = ''; + } + + // Remove hash + if (options.stripHash) { + urlObj.hash = ''; + } + + // Remove duplicate slashes if not preceded by a protocol + if (urlObj.pathname) { + // TODO: Use the following instead when targeting Node.js 10 + // `urlObj.pathname = urlObj.pathname.replace(/(? { + if (/^(?!\/)/g.test(p1)) { + return `${p1}/`; + } + + return '/'; + }); + } + + // Decode URI octets + if (urlObj.pathname) { + urlObj.pathname = decodeURI(urlObj.pathname); + } + + // Remove directory index + if (options.removeDirectoryIndex === true) { + options.removeDirectoryIndex = [/^index\.[a-z]+$/]; + } + + if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) { + let pathComponents = urlObj.pathname.split('/'); + const lastComponent = pathComponents[pathComponents.length - 1]; + + if (testParameter(lastComponent, options.removeDirectoryIndex)) { + pathComponents = pathComponents.slice(0, pathComponents.length - 1); + urlObj.pathname = pathComponents.slice(1).join('/') + '/'; + } + } + + if (urlObj.hostname) { + // Remove trailing dot + urlObj.hostname = urlObj.hostname.replace(/\.$/, ''); + + // Remove `www.` + if (options.stripWWW && /^www\.([a-z\-\d]{2,63})\.([a-z.]{2,5})$/.test(urlObj.hostname)) { + // Each label should be max 63 at length (min: 2). + // The extension should be max 5 at length (min: 2). + // Source: https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names + urlObj.hostname = urlObj.hostname.replace(/^www\./, ''); + } + } + + // Remove query unwanted parameters + if (Array.isArray(options.removeQueryParameters)) { + for (const key of [...urlObj.searchParams.keys()]) { + if (testParameter(key, options.removeQueryParameters)) { + urlObj.searchParams.delete(key); + } + } + } + + // Sort query parameters + if (options.sortQueryParameters) { + urlObj.searchParams.sort(); + } + + if (options.removeTrailingSlash) { + urlObj.pathname = urlObj.pathname.replace(/\/$/, ''); + } + + // Take advantage of many of the Node `url` normalizations + urlString = urlObj.toString(); + + // Remove ending `/` + if ((options.removeTrailingSlash || urlObj.pathname === '/') && urlObj.hash === '') { + urlString = urlString.replace(/\/$/, ''); + } + + // Restore relative protocol, if applicable + if (hasRelativeProtocol && !options.normalizeProtocol) { + urlString = urlString.replace(/^http:\/\//, '//'); + } + + // Remove http/https + if (options.stripProtocol) { + urlString = urlString.replace(/^(?:https?:)?\/\//, ''); + } + + return urlString; +}; + +module.exports = normalizeUrl; +// TODO: Remove this for the next major release +module.exports["default"] = normalizeUrl; + + +/***/ }), + +/***/ 9241: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); exports.generate = exports.compile = void 0; var boolbase_1 = __importDefault(__nccwpck_require__(4159)); /** @@ -20764,387 +20957,6 @@ function parse(formula) { exports.parse = parse; //# sourceMappingURL=parse.js.map -/***/ }), - -/***/ 7426: -/***/ ((module) => { - -"use strict"; -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ - - -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; - - -/***/ }), - -/***/ 3627: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; -/*! - * object.omit - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - - - -var isObject = __nccwpck_require__(429); -var forOwn = __nccwpck_require__(7281); - -module.exports = function omit(obj, keys) { - if (!isObject(obj)) return {}; - - keys = [].concat.apply([], [].slice.call(arguments, 1)); - var last = keys[keys.length - 1]; - var res = {}, fn; - - if (typeof last === 'function') { - fn = keys.pop(); - } - - var isFunction = typeof fn === 'function'; - if (!keys.length && !isFunction) { - return obj; - } - - forOwn(obj, function(value, key) { - if (keys.indexOf(key) === -1) { - - if (!isFunction) { - res[key] = value; - } else if (fn(value, key, obj)) { - res[key] = value; - } - } - }); - return res; -}; - - -/***/ }), - -/***/ 6143: -/***/ ((module) => { - -"use strict"; - -module.exports = function (url) { - if (typeof url !== 'string') { - throw new TypeError('Expected a string, got ' + typeof url); - } - - url = url.trim(); - - if (/^\.*\/|^(?!localhost)\w+:/.test(url)) { - return url; - } - - return url.replace(/^(?!(?:\w+:)?\/\/)/, 'http://'); -}; - - -/***/ }), - -/***/ 293: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -var strictUriEncode = __nccwpck_require__(3605); -var objectAssign = __nccwpck_require__(7426); - -function encoderForArrayFormat(opts) { - switch (opts.arrayFormat) { - case 'index': - return function (key, value, index) { - return value === null ? [ - encode(key, opts), - '[', - index, - ']' - ].join('') : [ - encode(key, opts), - '[', - encode(index, opts), - ']=', - encode(value, opts) - ].join(''); - }; - - case 'bracket': - return function (key, value) { - return value === null ? encode(key, opts) : [ - encode(key, opts), - '[]=', - encode(value, opts) - ].join(''); - }; - - default: - return function (key, value) { - return value === null ? encode(key, opts) : [ - encode(key, opts), - '=', - encode(value, opts) - ].join(''); - }; - } -} - -function parserForArrayFormat(opts) { - var result; - - switch (opts.arrayFormat) { - case 'index': - return function (key, value, accumulator) { - result = /\[(\d*)\]$/.exec(key); - - key = key.replace(/\[\d*\]$/, ''); - - if (!result) { - accumulator[key] = value; - return; - } - - if (accumulator[key] === undefined) { - accumulator[key] = {}; - } - - accumulator[key][result[1]] = value; - }; - - case 'bracket': - return function (key, value, accumulator) { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ''); - - if (!result) { - accumulator[key] = value; - return; - } else if (accumulator[key] === undefined) { - accumulator[key] = [value]; - return; - } - - accumulator[key] = [].concat(accumulator[key], value); - }; - - default: - return function (key, value, accumulator) { - if (accumulator[key] === undefined) { - accumulator[key] = value; - return; - } - - accumulator[key] = [].concat(accumulator[key], value); - }; - } -} - -function encode(value, opts) { - if (opts.encode) { - return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); - } - - return value; -} - -function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } else if (typeof input === 'object') { - return keysSorter(Object.keys(input)).sort(function (a, b) { - return Number(a) - Number(b); - }).map(function (key) { - return input[key]; - }); - } - - return input; -} - -exports.extract = function (str) { - return str.split('?')[1] || ''; -}; - -exports.parse = function (str, opts) { - opts = objectAssign({arrayFormat: 'none'}, opts); - - var formatter = parserForArrayFormat(opts); - - // Create an object with no prototype - // https://github.com/sindresorhus/query-string/issues/47 - var ret = Object.create(null); - - if (typeof str !== 'string') { - return ret; - } - - str = str.trim().replace(/^(\?|#|&)/, ''); - - if (!str) { - return ret; - } - - str.split('&').forEach(function (param) { - var parts = param.replace(/\+/g, ' ').split('='); - // Firefox (pre 40) decodes `%3D` to `=` - // https://github.com/sindresorhus/query-string/pull/37 - var key = parts.shift(); - var val = parts.length > 0 ? parts.join('=') : undefined; - - // missing `=` should be `null`: - // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); - - formatter(decodeURIComponent(key), val, ret); - }); - - return Object.keys(ret).sort().reduce(function (result, key) { - var val = ret[key]; - if (Boolean(val) && typeof val === 'object' && !Array.isArray(val)) { - // Sort object keys, not values - result[key] = keysSorter(val); - } else { - result[key] = val; - } - - return result; - }, Object.create(null)); -}; - -exports.stringify = function (obj, opts) { - var defaults = { - encode: true, - strict: true, - arrayFormat: 'none' - }; - - opts = objectAssign(defaults, opts); - - var formatter = encoderForArrayFormat(opts); - - return obj ? Object.keys(obj).sort().map(function (key) { - var val = obj[key]; - - if (val === undefined) { - return ''; - } - - if (val === null) { - return encode(key, opts); - } - - if (Array.isArray(val)) { - var result = []; - - val.slice().forEach(function (val2) { - if (val2 === undefined) { - return; - } - - result.push(formatter(key, val2, result.length)); - }); - - return result.join('&'); - } - - return encode(key, opts) + '=' + encode(val, opts); - }).filter(function (x) { - return x.length > 0; - }).join('&') : ''; -}; - - /***/ }), /***/ 1532: @@ -21498,7 +21310,7 @@ class Range { module.exports = Range -const LRU = __nccwpck_require__(1196) +const LRU = __nccwpck_require__(7129) const cache = new LRU({ max: 1000 }) const parseOptions = __nccwpck_require__(785) @@ -22903,467 +22715,125 @@ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`) - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] -}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) - -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. - -// Note that the only major, minor, patch, and pre-release sections of -// the version string are capturing groups. The build metadata is not a -// capturing group, because it should not ever be used in version -// comparison. - -createToken('FULLPLAIN', `v?${src[t.MAINVERSION] -}${src[t.PRERELEASE]}?${ - src[t.BUILD]}?`) - -createToken('FULL', `^${src[t.FULLPLAIN]}$`) - -// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. -// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty -// common in the npm registry. -createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] -}${src[t.PRERELEASELOOSE]}?${ - src[t.BUILD]}?`) - -createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) - -createToken('GTLT', '((?:<|>)?=?)') - -// Something like "2.*" or "1.2.x". -// Note that "x.x" is a valid xRange identifer, meaning "any version" -// Only the first item is strictly required. -createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) -createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) - -createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + - `(?:${src[t.PRERELEASE]})?${ - src[t.BUILD]}?` + - `)?)?`) - -createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:${src[t.PRERELEASELOOSE]})?${ - src[t.BUILD]}?` + - `)?)?`) - -createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) -createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) - -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -createToken('COERCE', `${'(^|[^\\d])' + - '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:$|[^\\d])`) -createToken('COERCERTL', src[t.COERCE], true) - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -createToken('LONETILDE', '(?:~>?)') - -createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) -exports.tildeTrimReplace = '$1~' - -createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) -createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -createToken('LONECARET', '(?:\\^)') - -createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) -exports.caretTrimReplace = '$1^' - -createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) -createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) - -// A simple gt/lt/eq thing, or just "" to indicate "any version" -createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) -createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) - -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] -}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) -exports.comparatorTrimReplace = '$1$2$3' - -// Something like `1.2.3 - 1.2.4` -// Note that these all use the loose form, because they'll be -// checked against either the strict or loose comparator form -// later. -createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + - `\\s+-\\s+` + - `(${src[t.XRANGEPLAIN]})` + - `\\s*$`) - -createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + - `\\s+-\\s+` + - `(${src[t.XRANGEPLAINLOOSE]})` + - `\\s*$`) - -// Star ranges basically just allow anything at all. -createToken('STAR', '(<|>)?=?\\s*\\*') -// >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') - - -/***/ }), - -/***/ 1196: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -// A linked list to keep track of recently-used-ness -const Yallist = __nccwpck_require__(665) - -const MAX = Symbol('max') -const LENGTH = Symbol('length') -const LENGTH_CALCULATOR = Symbol('lengthCalculator') -const ALLOW_STALE = Symbol('allowStale') -const MAX_AGE = Symbol('maxAge') -const DISPOSE = Symbol('dispose') -const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') -const LRU_LIST = Symbol('lruList') -const CACHE = Symbol('cache') -const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') - -const naiveLength = () => 1 - -// lruList is a yallist where the head is the youngest -// item, and the tail is the oldest. the list contains the Hit -// objects as the entries. -// Each Hit object has a reference to its Yallist.Node. This -// never changes. -// -// cache is a Map (or PseudoMap) that matches the keys to -// the Yallist.Node object. -class LRUCache { - constructor (options) { - if (typeof options === 'number') - options = { max: options } - - if (!options) - options = {} - - if (options.max && (typeof options.max !== 'number' || options.max < 0)) - throw new TypeError('max must be a non-negative number') - // Kind of weird to have a default max of Infinity, but oh well. - const max = this[MAX] = options.max || Infinity - - const lc = options.length || naiveLength - this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc - this[ALLOW_STALE] = options.stale || false - if (options.maxAge && typeof options.maxAge !== 'number') - throw new TypeError('maxAge must be a number') - this[MAX_AGE] = options.maxAge || 0 - this[DISPOSE] = options.dispose - this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false - this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false - this.reset() - } - - // resize the cache when the max changes. - set max (mL) { - if (typeof mL !== 'number' || mL < 0) - throw new TypeError('max must be a non-negative number') - - this[MAX] = mL || Infinity - trim(this) - } - get max () { - return this[MAX] - } - - set allowStale (allowStale) { - this[ALLOW_STALE] = !!allowStale - } - get allowStale () { - return this[ALLOW_STALE] - } - - set maxAge (mA) { - if (typeof mA !== 'number') - throw new TypeError('maxAge must be a non-negative number') - - this[MAX_AGE] = mA - trim(this) - } - get maxAge () { - return this[MAX_AGE] - } - - // resize the cache when the lengthCalculator changes. - set lengthCalculator (lC) { - if (typeof lC !== 'function') - lC = naiveLength - - if (lC !== this[LENGTH_CALCULATOR]) { - this[LENGTH_CALCULATOR] = lC - this[LENGTH] = 0 - this[LRU_LIST].forEach(hit => { - hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) - this[LENGTH] += hit.length - }) - } - trim(this) - } - get lengthCalculator () { return this[LENGTH_CALCULATOR] } - - get length () { return this[LENGTH] } - get itemCount () { return this[LRU_LIST].length } - - rforEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].tail; walker !== null;) { - const prev = walker.prev - forEachStep(this, fn, walker, thisp) - walker = prev - } - } - - forEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].head; walker !== null;) { - const next = walker.next - forEachStep(this, fn, walker, thisp) - walker = next - } - } - - keys () { - return this[LRU_LIST].toArray().map(k => k.key) - } - - values () { - return this[LRU_LIST].toArray().map(k => k.value) - } - - reset () { - if (this[DISPOSE] && - this[LRU_LIST] && - this[LRU_LIST].length) { - this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) - } - - this[CACHE] = new Map() // hash of items by key - this[LRU_LIST] = new Yallist() // list of items in order of use recency - this[LENGTH] = 0 // length of items in the list - } - - dump () { - return this[LRU_LIST].map(hit => - isStale(this, hit) ? false : { - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }).toArray().filter(h => h) - } - - dumpLru () { - return this[LRU_LIST] - } - - set (key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE] - - if (maxAge && typeof maxAge !== 'number') - throw new TypeError('maxAge must be a number') - - const now = maxAge ? Date.now() : 0 - const len = this[LENGTH_CALCULATOR](value, key) +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)) - return false - } +createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`) - const node = this[CACHE].get(key) - const item = node.value +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. - // dispose of the old one before overwriting - // split out into 2 ifs for better coverage tracking - if (this[DISPOSE]) { - if (!this[NO_DISPOSE_ON_SET]) - this[DISPOSE](key, item.value) - } +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) - item.now = now - item.maxAge = maxAge - item.value = value - this[LENGTH] += len - item.length - item.length = len - this.get(key) - trim(this) - return true - } +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. - const hit = new Entry(key, value, len, now, maxAge) +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. - // oversized objects fall out of cache automatically. - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value) +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) - return false - } +createToken('FULL', `^${src[t.FULLPLAIN]}$`) - this[LENGTH] += hit.length - this[LRU_LIST].unshift(hit) - this[CACHE].set(key, this[LRU_LIST].head) - trim(this) - return true - } +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`) - has (key) { - if (!this[CACHE].has(key)) return false - const hit = this[CACHE].get(key).value - return !isStale(this, hit) - } +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) - get (key) { - return get(this, key, true) - } +createToken('GTLT', '((?:<|>)?=?)') - peek (key) { - return get(this, key, false) - } +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) - pop () { - const node = this[LRU_LIST].tail - if (!node) - return null +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) - del(this, node) - return node.value - } +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) - del (key) { - del(this, this[CACHE].get(key)) - } +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) - load (arr) { - // reset the cache - this.reset() +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`) +createToken('COERCERTL', src[t.COERCE], true) - const now = Date.now() - // A previous serialized cache has the most recent items first - for (let l = arr.length - 1; l >= 0; l--) { - const hit = arr[l] - const expiresAt = hit.e || 0 - if (expiresAt === 0) - // the item was created without expiration in a non aged cache - this.set(hit.k, hit.v) - else { - const maxAge = expiresAt - now - // dont add already expired items - if (maxAge > 0) { - this.set(hit.k, hit.v, maxAge) - } - } - } - } +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)') - prune () { - this[CACHE].forEach((value, key) => get(this, key, false)) - } -} +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) +exports.tildeTrimReplace = '$1~' -const get = (self, key, doUse) => { - const node = self[CACHE].get(key) - if (node) { - const hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - return undefined - } else { - if (doUse) { - if (self[UPDATE_AGE_ON_GET]) - node.value.now = Date.now() - self[LRU_LIST].unshiftNode(node) - } - } - return hit.value - } -} +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) -const isStale = (self, hit) => { - if (!hit || (!hit.maxAge && !self[MAX_AGE])) - return false +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)') - const diff = Date.now() - hit.now - return hit.maxAge ? diff > hit.maxAge - : self[MAX_AGE] && (diff > self[MAX_AGE]) -} +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) +exports.caretTrimReplace = '$1^' -const trim = self => { - if (self[LENGTH] > self[MAX]) { - for (let walker = self[LRU_LIST].tail; - self[LENGTH] > self[MAX] && walker !== null;) { - // We know that we're about to delete this one, and also - // what the next least recently used key will be, so just - // go ahead and set it now. - const prev = walker.prev - del(self, walker) - walker = prev - } - } -} +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) -const del = (self, node) => { - if (node) { - const hit = node.value - if (self[DISPOSE]) - self[DISPOSE](hit.key, hit.value) +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) - self[LENGTH] -= hit.length - self[CACHE].delete(hit.key) - self[LRU_LIST].removeNode(node) - } -} +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) +exports.comparatorTrimReplace = '$1$2$3' -class Entry { - constructor (key, value, length, now, maxAge) { - this.key = key - this.value = value - this.length = length - this.now = now - this.maxAge = maxAge || 0 - } -} +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`) -const forEachStep = (self, fn, node, thisp) => { - let hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - hit = undefined - } - if (hit) - fn.call(thisp, hit.value, hit.key, self) -} +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`) -module.exports = LRUCache +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*') +// >=0.0.0 is like a star +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23961,20 +23431,6 @@ const validRange = (range, options) => { module.exports = validRange -/***/ }), - -/***/ 3605: -/***/ ((module) => { - -"use strict"; - -module.exports = function (str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return '%' + c.charCodeAt(0).toString(16).toUpperCase(); - }); -}; - - /***/ }), /***/ 4294: @@ -26671,11 +26127,9 @@ const RULES = [ `'installer-url' extension '${urlExt(i.installerUrl)}' must be one of: ${constants.KNOWN_EXTENSIONS}`, (i) => !!(!i.minicondaVersion && i.architecture !== "x64") && `'architecture: ${i.architecture}' requires "miniconda-version"`, - (i // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015) - ) => !!(i.architecture === "x86" && !constants.IS_WINDOWS) && + (i) => !!(i.architecture === "x86" && !constants.IS_WINDOWS) && `'architecture: ${i.architecture}' is only available for recent versions on Windows`, - (i // We only support miniconda 4.6 or later (`conda init` and /condabin were added here, which we need) - ) => !!(!["latest", ""].includes(i.minicondaVersion) && + (i) => !!(!["latest", ""].includes(i.minicondaVersion) && semver.lt(i.minicondaVersion, "4.6.0")) && `'architecture: ${i.architecture}' requires "miniconda-version">=4.6 but you chose '${i.minicondaVersion}'`, ]; @@ -27705,14 +27159,6 @@ module.exports = require("path"); /***/ }), -/***/ 5477: -/***/ ((module) => { - -"use strict"; -module.exports = require("punycode"); - -/***/ }), - /***/ 2781: /***/ ((module) => { diff --git a/src/base-tools/index.ts b/src/base-tools/index.ts index 44ee4a9a..5d41a6bf 100644 --- a/src/base-tools/index.ts +++ b/src/base-tools/index.ts @@ -33,7 +33,7 @@ const TOOL_PROVIDERS: types.IToolProvider[] = [ */ export async function installBaseTools( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ) { let tools = []; let postInstallOptions = { ...options }; @@ -47,7 +47,7 @@ export async function installBaseTools( postInstallOptions = { ...postInstallOptions, ...toolUpdates.options }; if (provider.postInstall) { core.info( - `... we will perform post-install steps after we ${provider.label}.` + `... we will perform post-install steps after we ${provider.label}.`, ); postInstallActions.push(provider.postInstall); } diff --git a/src/base-tools/update-mamba.ts b/src/base-tools/update-mamba.ts index a3d0b24f..bb2a3531 100644 --- a/src/base-tools/update-mamba.ts +++ b/src/base-tools/update-mamba.ts @@ -15,7 +15,7 @@ export const updateMamba: types.IToolProvider = { inputs.mambaVersion !== "" || options.mambaInInstaller, toolPackages: async (inputs, options) => { core.warning( - `Mamba support is still experimental and can result in differently solved environments!` + `Mamba support is still experimental and can result in differently solved environments!`, ); return { tools: diff --git a/src/conda.ts b/src/conda.ts index f00d3e2f..a17be79f 100644 --- a/src/conda.ts +++ b/src/conda.ts @@ -46,7 +46,7 @@ export function envCommandFlag(inputs: types.IActionInputs): string[] { */ export function condaExecutable( options: types.IDynamicOptions, - subcommand?: string + subcommand?: string, ): string { const dir: string = condaBasePath(options); let condaExe: string; @@ -73,7 +73,7 @@ export function isMambaInstalled(options: types.IDynamicOptions) { */ export async function condaCommand( cmd: string[], - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { const command = [condaExecutable(options, cmd[0]), ...cmd]; return await utils.execute(command); @@ -85,7 +85,7 @@ export async function condaCommand( export async function bootstrapConfig(): Promise { await fs.promises.writeFile( constants.CONDARC_PATH, - constants.BOOTSTRAP_CONDARC + constants.BOOTSTRAP_CONDARC, ); } @@ -95,7 +95,7 @@ export async function bootstrapConfig(): Promise { export async function copyConfig(inputs: types.IActionInputs) { const sourcePath: string = path.join( process.env["GITHUB_WORKSPACE"] || "", - inputs.condaConfigFile + inputs.condaConfigFile, ); core.info(`Copying "${sourcePath}" to "${constants.CONDARC_PATH}..."`); await io.cp(sourcePath, constants.CONDARC_PATH); @@ -106,11 +106,11 @@ export async function copyConfig(inputs: types.IActionInputs) { */ export async function applyCondaConfiguration( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { const configEntries = Object.entries(inputs.condaConfig) as [ keyof types.ICondaConfig, - string + string, ][]; // Channels are special: if specified as an action input, these take priority @@ -155,7 +155,7 @@ export async function applyCondaConfiguration( */ export async function condaInit( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { let ownPath: string; const isValidActivate = !utils.isBaseEnv(inputs.activateEnvironment); diff --git a/src/delete.ts b/src/delete.ts index 27053268..1ca6a91f 100644 --- a/src/delete.ts +++ b/src/delete.ts @@ -16,7 +16,7 @@ async function run(): Promise { if (fs.existsSync(cacheFolder) && fs.lstatSync(cacheFolder).isDirectory()) { core.startGroup( - "Removing uncompressed packages to trim down cache folder..." + "Removing uncompressed packages to trim down cache folder...", ); let fullPath: string; for (let folder_or_file of fs.readdirSync(cacheFolder)) { diff --git a/src/env/explicit.ts b/src/env/explicit.ts index 5f16eea7..cbea4961 100644 --- a/src/env/explicit.ts +++ b/src/env/explicit.ts @@ -12,14 +12,14 @@ export const ensureExplicit: types.IEnvProvider = { condaArgs: async (inputs, options) => { if (inputs.pythonVersion) { throw Error( - `'python-version: ${inputs.pythonVersion}' is incompatible with an explicit 'environmentFile` + `'python-version: ${inputs.pythonVersion}' is incompatible with an explicit 'environmentFile`, ); } if (options.envSpec?.explicit) { outputs.setEnvironmentFileOutputs( inputs.environmentFile, - options.envSpec.explicit + options.envSpec.explicit, ); } diff --git a/src/env/index.ts b/src/env/index.ts index 2249a3f8..06db6ae5 100644 --- a/src/env/index.ts +++ b/src/env/index.ts @@ -33,7 +33,7 @@ const ENV_PROVIDERS: types.IEnvProvider[] = [ */ export async function ensureEnvironment( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { for (const provider of ENV_PROVIDERS) { core.info(`Can we ${provider.label}?`); @@ -42,13 +42,13 @@ export async function ensureEnvironment( const args = await provider.condaArgs(inputs, options); return await core.group( `Updating '${inputs.activateEnvironment}' env from ${provider.label}...`, - () => conda.condaCommand(args, options) + () => conda.condaCommand(args, options), ); } } throw Error( - `'activate-environment: ${inputs.activateEnvironment}' could not be created` + `'activate-environment: ${inputs.activateEnvironment}' could not be created`, ); } @@ -64,7 +64,7 @@ export async function ensureEnvironment( * multiple files, alternate inputs, etc. */ export async function getEnvSpec( - inputs: types.IActionInputs + inputs: types.IActionInputs, ): Promise { if (!inputs.environmentFile) { return {}; @@ -72,7 +72,7 @@ export async function getEnvSpec( const sourceEnvironmentPath: string = path.join( process.env["GITHUB_WORKSPACE"] || "", - inputs.environmentFile + inputs.environmentFile, ); const source = fs.readFileSync(sourceEnvironmentPath, "utf8"); diff --git a/src/env/yaml.ts b/src/env/yaml.ts index 170df4ac..b383a75b 100644 --- a/src/env/yaml.ts +++ b/src/env/yaml.ts @@ -23,7 +23,7 @@ interface IYAMLEnvPatchProvider { /** Whether this patch should be applied for the given `inputs` and `options` */ provides: ( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ) => boolean; /** A regular expression for detecting whether a spec will need to be replaced */ specMatch: RegExp; @@ -66,7 +66,7 @@ export const ensureYaml: types.IEnvProvider = { const yamlData = options.envSpec?.yaml; if (yamlData == null) { throw Error( - `'environment-file: ${inputs.environmentFile}' appears to be malformed` + `'environment-file: ${inputs.environmentFile}' appears to be malformed`, ); } @@ -112,10 +112,10 @@ export const ensureYaml: types.IEnvProvider = { const origParent = path.dirname(origPath); envFile = path.join( origParent, - `setup-miniconda-patched-${path.basename(origPath)}` + `setup-miniconda-patched-${path.basename(origPath)}`, ); core.info( - `Making patched copy of 'environment-file: ${inputs.environmentFile}'` + `Making patched copy of 'environment-file: ${inputs.environmentFile}'`, ); core.info(`Using: ${envFile}\n${patchedYaml}`); fs.writeFileSync(envFile, patchedYaml, "utf8"); @@ -124,7 +124,7 @@ export const ensureYaml: types.IEnvProvider = { core.info(`Using 'environment-file: ${inputs.environmentFile}' as-is`); outputs.setEnvironmentFileOutputs( envFile, - fs.readFileSync(inputs.environmentFile, "utf-8") + fs.readFileSync(inputs.environmentFile, "utf-8"), ); } diff --git a/src/input.ts b/src/input.ts index 041095f7..07fe2caa 100644 --- a/src/input.ts +++ b/src/input.ts @@ -15,9 +15,10 @@ import * as types from "./types"; * network calls or subprocesses). */ interface IRule { - (inputs: types.IActionInputs, condaConfig: types.ICondaConfig): - | string - | false; + ( + inputs: types.IActionInputs, + condaConfig: types.ICondaConfig, + ): string | false; } const urlExt = (url: string) => path.posix.extname(new URL(url).pathname); @@ -63,12 +64,12 @@ const RULES: IRule[] = [ !!(!i.minicondaVersion && i.architecture !== "x64") && `'architecture: ${i.architecture}' requires "miniconda-version"`, ( - i // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015) + i, // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015) ) => !!(i.architecture === "x86" && !constants.IS_WINDOWS) && `'architecture: ${i.architecture}' is only available for recent versions on Windows`, ( - i // We only support miniconda 4.6 or later (`conda init` and /condabin were added here, which we need) + i, // We only support miniconda 4.6 or later (`conda init` and /condabin were added here, which we need) ) => !!( !["latest", ""].includes(i.minicondaVersion) && @@ -99,7 +100,7 @@ export async function parseInputs(): Promise { condaConfig: Object.freeze({ add_anaconda_token: core.getInput("add-anaconda-token"), add_pip_as_python_dependency: core.getInput( - "add-pip-as-python-dependency" + "add-pip-as-python-dependency", ), allow_softlinks: core.getInput("allow-softlinks"), auto_activate_base: core.getInput("auto-activate-base"), @@ -114,7 +115,7 @@ export async function parseInputs(): Promise { changeps1: "false", }), cleanPatchedEnvironmentFile: core.getInput( - "clean-patched-environment-file" + "clean-patched-environment-file", ), runPost: core.getInput("run-post"), }); diff --git a/src/installer/base.ts b/src/installer/base.ts index b90b99af..075bfe92 100644 --- a/src/installer/base.ts +++ b/src/installer/base.ts @@ -20,7 +20,7 @@ import * as types from "../types"; * - or has been renamed during a build process */ export async function ensureLocalInstaller( - options: types.ILocalInstallerOpts + options: types.ILocalInstallerOpts, ): Promise { core.info("Ensuring Installer..."); @@ -51,7 +51,7 @@ export async function ensureLocalInstaller( let cacheDirectoryPath = tc.find( installerName, version, - ...(options.arch ? [options.arch] : []) + ...(options.arch ? [options.arch] : []), ); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); @@ -68,7 +68,7 @@ export async function ensureLocalInstaller( if (executablePath === "") { const rawDownloadPath = await tc.downloadTool(options.url); core.info( - `Downloaded ${installerName}, ensuring extension ${installerExtension}` + `Downloaded ${installerName}, ensuring extension ${installerExtension}`, ); // Always ensure the installer ends with a known path executablePath = rawDownloadPath + installerExtension; @@ -79,7 +79,7 @@ export async function ensureLocalInstaller( installerName, tool, version, - ...(options.arch ? [options.arch] : []) + ...(options.arch ? [options.arch] : []), ); core.info(`Cached ${tool}@${version}: ${cacheResult}!`); } diff --git a/src/installer/download-miniconda.ts b/src/installer/download-miniconda.ts index cc7dea27..380ab364 100644 --- a/src/installer/download-miniconda.ts +++ b/src/installer/download-miniconda.ts @@ -19,13 +19,13 @@ async function minicondaVersions(arch: string): Promise { try { let extension: string = constants.IS_UNIX ? "sh" : "exe"; const downloadPath: string = await tc.downloadTool( - constants.MINICONDA_BASE_URL + constants.MINICONDA_BASE_URL, ); const content: string = fs.readFileSync(downloadPath, "utf8"); let hrefs: string[] = getHrefs(content); hrefs = hrefs.filter((item: string) => item.startsWith("/Miniconda3")); hrefs = hrefs.filter((item: string) => - item.endsWith(`${arch}.${extension}`) + item.endsWith(`${arch}.${extension}`), ); hrefs = hrefs.map((item: string) => item.substring(1)); return hrefs; @@ -44,7 +44,7 @@ async function minicondaVersions(arch: string): Promise { */ export async function downloadMiniconda( pythonMajorVersion: number, - inputs: types.IActionInputs + inputs: types.IActionInputs, ): Promise { // Check valid arch let arch: string = @@ -67,7 +67,7 @@ export async function downloadMiniconda( if (versions) { if (!versions.includes(minicondaInstallerName)) { throw new Error( - `Invalid miniconda version!\n\nMust be among ${versions.toString()}` + `Invalid miniconda version!\n\nMust be among ${versions.toString()}`, ); } } diff --git a/src/installer/download-miniforge.ts b/src/installer/download-miniforge.ts index 0c181bbf..5bc7b19a 100644 --- a/src/installer/download-miniforge.ts +++ b/src/installer/download-miniforge.ts @@ -10,7 +10,7 @@ import * as base from "./base"; */ export async function downloadMiniforge( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { const tool = inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT; @@ -32,13 +32,13 @@ export async function downloadMiniforge( // e.g. https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh fileName = [tool, osName, `${arch}.${extension}`].join("-"); url = [constants.MINIFORGE_URL_PREFIX, version, "download", fileName].join( - "/" + "/", ); } else { // e.g. https://github.com/conda-forge/miniforge/releases/download/4.9.2-5/Miniforge3-4.9.2-5-Linux-x86_64.sh fileName = [tool, version, osName, `${arch}.${extension}`].join("-"); url = [constants.MINIFORGE_URL_PREFIX, "download", version, fileName].join( - "/" + "/", ); } diff --git a/src/installer/index.ts b/src/installer/index.ts index 1fb19913..b0189fc2 100644 --- a/src/installer/index.ts +++ b/src/installer/index.ts @@ -33,7 +33,7 @@ const INSTALLER_PROVIDERS: types.IInstallerProvider[] = [ /** See if any provider works with the given inputs and options */ export async function getLocalInstallerPath( inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ) { for (const provider of INSTALLER_PROVIDERS) { core.info(`Can we ${provider.label}?`); @@ -54,7 +54,7 @@ export async function runInstaller( installerPath: string, outputPath: string, inputs: types.IActionInputs, - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { const installerExtension = path.extname(installerPath); let command: string[]; diff --git a/src/outputs.ts b/src/outputs.ts index a7a3d3f5..16066f6b 100644 --- a/src/outputs.ts +++ b/src/outputs.ts @@ -14,7 +14,7 @@ import * as utils from "./utils"; * Add Conda executable to PATH environment variable */ export async function setPathVariables( - options: types.IDynamicOptions + options: types.IDynamicOptions, ): Promise { const condaBin: string = path.join(conda.condaBasePath(options), "condabin"); const condaPath: string = conda.condaBasePath(options); @@ -41,13 +41,13 @@ export async function setCacheVariable(options: types.IDynamicOptions) { export function setEnvironmentFileOutputs( envFile: string, envContent: string, - patched = false + patched = false, ): void { core.setOutput(constants.OUTPUT_ENV_FILE_PATH, path.resolve(envFile)); core.setOutput(constants.OUTPUT_ENV_FILE_CONTENT, envContent); core.setOutput( constants.OUTPUT_ENV_FILE_WAS_PATCHED, - patched ? "true" : "false" + patched ? "true" : "false", ); core.saveState(constants.OUTPUT_ENV_FILE_WAS_PATCHED, patched); } diff --git a/src/setup.ts b/src/setup.ts index c688f49f..3ff1b0c5 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -24,11 +24,11 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise { await core.group( `Creating bootstrap condarc file in ${constants.CONDARC_PATH}...`, - conda.bootstrapConfig + conda.bootstrapConfig, ); const installerInfo = await core.group("Ensuring installer...", () => - installer.getLocalInstallerPath(inputs, options) + installer.getLocalInstallerPath(inputs, options), ); // The desired installer may change the options @@ -42,8 +42,8 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise { installerInfo.localInstallerPath, basePath, inputs, - options - ) + options, + ), ); } @@ -54,12 +54,12 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise { "its own Miniconda installation, please specify its location with a `CONDA` " + "environment variable. If you want us to download and install Miniconda or " + 'Miniforge for you, add `miniconda-version: "latest"` or `miniforge-version: "latest"`, ' + - "respectively, to the parameters for this action." + "respectively, to the parameters for this action.", ); } await core.group("Setup environment variables...", () => - outputs.setPathVariables(options) + outputs.setPathVariables(options), ); if (inputs.condaConfigFile) { @@ -68,29 +68,29 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise { // For potential 'channels' that may alter configuration options.envSpec = await core.group("Parsing environment...", () => - env.getEnvSpec(inputs) + env.getEnvSpec(inputs), ); await core.group("Configuring conda package cache...", () => - outputs.setCacheVariable(options) + outputs.setCacheVariable(options), ); await core.group("Applying initial configuration...", () => - conda.applyCondaConfiguration(inputs, options) + conda.applyCondaConfiguration(inputs, options), ); await core.group("Initializing conda shell integration...", () => - conda.condaInit(inputs, options) + conda.condaInit(inputs, options), ); // New base tools may change options options = await core.group("Adding tools to 'base' env...", () => - baseTools.installBaseTools(inputs, options) + baseTools.installBaseTools(inputs, options), ); if (inputs.activateEnvironment) { await core.group("Ensuring environment...", () => - env.ensureEnvironment(inputs, options) + env.ensureEnvironment(inputs, options), ); } @@ -105,7 +105,7 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise { } else { core.info(`Leaving ${patchedEnv} in place`); } - } + }, ); } diff --git a/src/types.ts b/src/types.ts index 4bb0c9cb..ea674d9b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -130,12 +130,12 @@ export interface IInstallerProvider { /** Whether this set of actions and inputs entails using this provider */ provides: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; /** Provide the local file path (and any updated options) for the installer */ installerPath: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; } @@ -149,14 +149,14 @@ export interface IEnvProvider { */ provides: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; /** * The args to conda/mamba, e.g. create, update */ condaArgs: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; } @@ -176,21 +176,21 @@ export interface IToolProvider { */ provides: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; /** * Conda package specs and option updates for tools to install after updating */ toolPackages: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; /** * Steps to perform after the env is updated, and potentially reconfigured */ postInstall?: ( inputs: IActionInputs, - options: IDynamicOptions + options: IDynamicOptions, ) => Promise; }