From bb9d78a6d13dc96112f159805168b13c094543f3 Mon Sep 17 00:00:00 2001 From: Ricky Miller Date: Mon, 31 Oct 2022 12:34:47 -0400 Subject: [PATCH] update disk --- dist/index.js | 19789 +++++++++++++++++++++++++++--------------------- 1 file changed, 11061 insertions(+), 8728 deletions(-) diff --git a/dist/index.js b/dist/index.js index c955a19..4842353 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,14 +6,27 @@ "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 (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + 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.issue = exports.issueCommand = void 0; const os = __importStar(__nccwpck_require__(2087)); const utils_1 = __nccwpck_require__(5278); /** @@ -92,6 +105,25 @@ function escapeProperty(s) { "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; +}; 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) { @@ -101,19 +133,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; const command_1 = __nccwpck_require__(7351); const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2087)); const path = __importStar(__nccwpck_require__(5622)); +const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action */ @@ -142,13 +169,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; /** @@ -166,7 +189,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); @@ -175,7 +198,9 @@ function addPath(inputPath) { } exports.addPath = addPath; /** - * Gets the value of an input. The value is also trimmed. + * Gets the value of an input. + * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. + * Returns an empty string if the value is not defined. * * @param name name of the input to get * @param options optional. See InputOptions. @@ -186,9 +211,52 @@ function getInput(name, options) { if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name}`); } + if (options && options.trimWhitespace === false) { + return val; + } return val.trim(); } exports.getInput = getInput; +/** + * Gets the values of an multiline input. Each value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string[] + * + */ +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()); +} +exports.getMultilineInput = getMultilineInput; +/** + * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. + * Support boolean input list: `true | True | TRUE | false | False | FALSE` . + * The return value is also in boolean type. + * ref: https://yaml.org/spec/1.2/spec.html#id2804923 + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns boolean + */ +function getBooleanInput(name, options) { + const trueValue = ['true', 'True', 'TRUE']; + const falseValue = ['false', 'False', 'FALSE']; + const val = getInput(name, options); + if (trueValue.includes(val)) + return true; + if (falseValue.includes(val)) + return false; + throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + + `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); +} +exports.getBooleanInput = getBooleanInput; /** * Sets the value of an output. * @@ -197,8 +265,12 @@ exports.getInput = getInput; */ // 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; /** @@ -244,19 +316,30 @@ exports.debug = debug; /** * Adds an error issue * @param message error issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); +function error(message, properties = {}) { + command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.error = error; /** - * Adds an warning issue + * Adds a warning issue * @param message warning issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); +function warning(message, properties = {}) { + command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.warning = warning; +/** + * Adds a notice issue + * @param message notice issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. + */ +function notice(message, properties = {}) { + command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); +} +exports.notice = notice; /** * Writes info to log with console.log. * @param message info message @@ -316,7 +399,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; /** @@ -329,6 +416,29 @@ function getState(name) { return process.env[`STATE_${name}`] || ''; } exports.getState = getState; +function getIDToken(aud) { + return __awaiter(this, void 0, void 0, function* () { + return yield oidc_utils_1.OidcClient.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 /***/ }), @@ -339,20 +449,34 @@ exports.getState = getState; "use strict"; // For internal use, subject to change. +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 (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + 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.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__(5747)); const os = __importStar(__nccwpck_require__(2087)); +const uuid_1 = __nccwpck_require__(5840); 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}`); @@ -364,81 +488,111 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; -//# sourceMappingURL=file-command.js.map - -/***/ }), - -/***/ 5278: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Sanitizes an input into a string so it can be passed into issueCommand safely - * @param input input to sanitize into a string - */ -function toCommandValue(input) { - if (input === null || input === undefined) { - return ''; +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}"`); } - else if (typeof input === 'string' || input instanceof String) { - return input; + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); } - return JSON.stringify(input); + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; } -exports.toCommandValue = toCommandValue; -//# sourceMappingURL=utils.js.map +exports.prepareKeyValueMessage = prepareKeyValueMessage; +//# sourceMappingURL=file-command.js.map /***/ }), -/***/ 4208: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 8041: +/***/ (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.writeJsonFile = exports.readJsonObjectFile = void 0; -const fs_1 = __nccwpck_require__(5747); -/** - * Reads the assumed JSON file at the given path, attempts to parse it, and - * returns the resulting object. - * - * Throws if failing to read or parse, or if the parsed JSON value is not a - * plain object. - * - * @param paths - The path segments pointing to the JSON file. Will be passed - * to path.join(). - * @returns The object corresponding to the parsed JSON file. - */ -async function readJsonObjectFile(path) { - const obj = JSON.parse(await fs_1.promises.readFile(path, 'utf8')); - if (!obj || typeof obj !== 'object' || Array.isArray(obj)) { - throw new Error(`Assumed JSON file at path "${path}" parsed to a non-object value.`); +exports.OidcClient = void 0; +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) { + const requestOptions = { + allowRetries: allowRetry, + maxRetries: maxRetry + }; + return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); + } + static getRequestToken() { + const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; + if (!token) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); + } + return token; + } + static getIDTokenUrl() { + const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; + if (!runtimeUrl) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); + } + return runtimeUrl; + } + static getCall(id_token_url) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const httpclient = OidcClient.createHttpClient(); + const res = yield httpclient + .getJson(id_token_url) + .catch(error => { + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n + Error Message: ${error.result.message}`); + }); + const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; + if (!id_token) { + throw new Error('Response json body do not have ID Token field'); + } + return id_token; + }); + } + static getIDToken(audience) { + return __awaiter(this, void 0, void 0, function* () { + try { + // New ID Token is requested from action service + let id_token_url = OidcClient.getIDTokenUrl(); + if (audience) { + const encodedAudience = encodeURIComponent(audience); + id_token_url = `${id_token_url}&audience=${encodedAudience}`; + } + core_1.debug(`ID token url is ${id_token_url}`); + const id_token = yield OidcClient.getCall(id_token_url); + core_1.setSecret(id_token); + return id_token; + } + catch (error) { + throw new Error(`Error message: ${error.message}`); + } + }); } - return obj; -} -exports.readJsonObjectFile = readJsonObjectFile; -/** - * Attempts to write the given JSON-like value to the file at the given path. - * Adds a newline to the end of the file. - * - * @param path - The path to write the JSON file to, including the file itself. - * @param jsonValue - The JSON-like value to write to the file. Make sure that - * JSON.stringify can handle it. - */ -async function writeJsonFile(path, jsonValue) { - await fs_1.promises.writeFile(path, `${JSON.stringify(jsonValue, null, 2)}\n`); } -exports.writeJsonFile = writeJsonFile; -//# sourceMappingURL=file-utils.js.map +exports.OidcClient = OidcClient; +//# sourceMappingURL=oidc-utils.js.map /***/ }), -/***/ 1281: +/***/ 2981: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -450,864 +604,1285 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi if (k2 === undefined) k2 = k; o[k2] = m[k]; })); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +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 })); -__exportStar(__nccwpck_require__(4208), exports); -__exportStar(__nccwpck_require__(279), exports); -__exportStar(__nccwpck_require__(8609), exports); -__exportStar(__nccwpck_require__(2064), exports); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 279: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.tabs = exports.isTruthyString = exports.getStringRecordValue = void 0; -const TWO_SPACES = ' '; +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(5622)); /** - * Utility function to get the value of a key from an object known to only - * contain string values, such as process.env. + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. * - * Trims the value before returning it, and returns the empty string for any - * undefined values. - * - * @param key - The key of process.env to access. - * @returns The trimmed string value of the process.env key. Returns an empty - * string if the key is not set. + * @param pth. Path to transform. + * @return string Posix path. */ -function getStringRecordValue(key, object) { - var _a; - return ((_a = object[key]) === null || _a === void 0 ? void 0 : _a.trim()) || ''; +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); } -exports.getStringRecordValue = getStringRecordValue; +exports.toPosixPath = toPosixPath; /** - * @param value - The value to test. - * @returns Whether the value is a non-empty string. + * 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 isTruthyString(value) { - return Boolean(value) && typeof value === 'string'; +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); } -exports.isTruthyString = isTruthyString; +exports.toWin32Path = toWin32Path; /** - * @param numTabs - The number of tabs to return. A tab consists of two spaces. - * @param prefix - The prefix to prepend to the returned string, if any. - * @returns A string consisting of the prefix, if any, and the requested number - * of tabs. + * 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 tabs(numTabs, prefix) { - if (!Number.isInteger(numTabs) || numTabs < 1) { - throw new Error('Expected positive integer.'); - } - const firstTab = prefix ? `${prefix}${TWO_SPACES}` : TWO_SPACES; - if (numTabs === 1) { - return firstTab; - } - return firstTab + new Array(numTabs).join(TWO_SPACES); +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); } -exports.tabs = tabs; -//# sourceMappingURL=misc-utils.js.map +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map /***/ }), -/***/ 8609: +/***/ 1327: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +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.getWorkspaceLocations = exports.validateMonorepoPackageManifest = exports.validatePolyrepoPackageManifest = exports.validatePackageManifestName = exports.validatePackageManifestVersion = exports.getPackageManifest = exports.ManifestFieldNames = exports.ManifestDependencyFieldNames = void 0; -const path_1 = __importDefault(__nccwpck_require__(5622)); -const util_1 = __nccwpck_require__(1669); -const glob_1 = __importDefault(__nccwpck_require__(1957)); -const misc_utils_1 = __nccwpck_require__(279); -const file_utils_1 = __nccwpck_require__(4208); -const semver_utils_1 = __nccwpck_require__(2064); -const glob = util_1.promisify(glob_1.default); -const PACKAGE_JSON = 'package.json'; -var ManifestDependencyFieldNames; -(function (ManifestDependencyFieldNames) { - ManifestDependencyFieldNames["Production"] = "dependencies"; - ManifestDependencyFieldNames["Development"] = "devDependencies"; - ManifestDependencyFieldNames["Peer"] = "peerDependencies"; - ManifestDependencyFieldNames["Bundled"] = "bundledDependencies"; - ManifestDependencyFieldNames["Optional"] = "optionalDependencies"; -})(ManifestDependencyFieldNames = exports.ManifestDependencyFieldNames || (exports.ManifestDependencyFieldNames = {})); -var ManifestFieldNames; -(function (ManifestFieldNames) { - ManifestFieldNames["Name"] = "name"; - ManifestFieldNames["Private"] = "private"; - ManifestFieldNames["Version"] = "version"; - ManifestFieldNames["Workspaces"] = "workspaces"; -})(ManifestFieldNames = exports.ManifestFieldNames || (exports.ManifestFieldNames = {})); -/** - * Read, parse, validate, and return the object corresponding to the - * package.json file in the given directory. - * - * An error is thrown if validation fails. - * - * @param containingDirPath - The complete path to the directory containing - * the package.json file. - * @returns The object corresponding to the parsed package.json file. - */ -async function getPackageManifest(containingDirPath) { - return await file_utils_1.readJsonObjectFile(path_1.default.join(containingDirPath, PACKAGE_JSON)); -} -exports.getPackageManifest = getPackageManifest; -/** - * Type guard to ensure that the given manifest has a valid "name" field. - * - * @param manifest - The manifest object to validate. - * @returns Whether the manifest has a valid "name" field. - */ -function hasValidNameField(manifest) { - return misc_utils_1.isTruthyString(manifest[ManifestFieldNames.Name]); -} -/** - * Type guard to ensure that the given manifest has a valid "private" field. - * - * @param manifest - The manifest object to validate. - * @returns Whether the manifest has a valid "private" field. - */ -function hasValidPrivateField(manifest) { - return manifest[ManifestFieldNames.Private] === true; -} -/** - * Type guard to ensure that the given manifest has a valid "version" field. - * - * @param manifest - The manifest object to validate. - * @returns Whether the manifest has a valid "version" field. - */ -function hasValidVersionField(manifest) { - return semver_utils_1.isValidSemver(manifest[ManifestFieldNames.Version]); -} -/** - * Type guard to ensure that the given manifest has a valid "worksapces" field. - * - * @param manifest - The manifest object to validate. - * @returns Whether the manifest has a valid "worksapces" field. - */ -function hasValidWorkspacesField(manifest) { - return (Array.isArray(manifest[ManifestFieldNames.Workspaces]) && - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - manifest[ManifestFieldNames.Workspaces].length > 0); -} -/** - * Validates the "version" field of a package manifest object, i.e. a parsed - * "package.json" file. - * - * @param manifest - The manifest to validate. - * @param manifestDirPath - The path to the directory containing the - * manifest file relative to the root directory. - * @returns The unmodified manifest, with the "version" field typed correctly. - */ -function validatePackageManifestVersion(manifest, manifestDirPath) { - if (!hasValidVersionField(manifest)) { - throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Version, manifest, manifestDirPath)} is not a valid SemVer version: ${manifest[ManifestFieldNames.Version]}`); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2087); +const fs_1 = __nccwpck_require__(5747); +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 = ''; } - return manifest; -} -exports.validatePackageManifestVersion = validatePackageManifestVersion; -/** - * Validates the "name" field of a package manifest object, i.e. a parsed - * "package.json" file. - * - * @param manifest - The manifest to validate. - * @param manifestDirPath - The path to the directory containing the - * manifest file relative to the root directory. - * @returns The unmodified manifest, with the "name" field typed correctly. - */ -function validatePackageManifestName(manifest, manifestDirPath) { - if (!hasValidNameField(manifest)) { - throw new Error(`Manifest in "${manifestDirPath}" does not have a valid "${ManifestFieldNames.Name}" field.`); + /** + * 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(); } - return manifest; } -exports.validatePackageManifestName = validatePackageManifestName; +const _summary = new Summary(); /** - * Validates the "version" and "name" fields of a package manifest object, - * i.e. a parsed "package.json" file. - * - * @param manifest - The manifest to validate. - * @param manifestDirPath - The path to the directory containing the - * manifest file relative to the root directory. - * @returns The unmodified manifest, with the "version" and "name" fields typed - * correctly. + * @deprecated use `core.summary` */ -function validatePolyrepoPackageManifest(manifest, manifestDirPath) { - return validatePackageManifestName(validatePackageManifestVersion(manifest, manifestDirPath), manifestDirPath); -} -exports.validatePolyrepoPackageManifest = validatePolyrepoPackageManifest; +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + +/***/ 5278: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toCommandProperties = exports.toCommandValue = void 0; /** - * Validates the "workspaces" and "private" fields of a package manifest object, - * i.e. a parsed "package.json" file. - * - * Assumes that the manifest's "version" field is already validated. - * - * @param manifest - The manifest to validate. - * @param manifestDirPath - The path to the directory containing the - * manifest file relative to the root directory. - * @returns The unmodified manifest, with the "workspaces" and "private" fields - * typed correctly. + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string */ -function validateMonorepoPackageManifest(manifest, manifestDirPath) { - if (!hasValidWorkspacesField(manifest)) { - throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Workspaces, manifest, manifestDirPath)} must be a non-empty array if present. Received: ${manifest[ManifestFieldNames.Workspaces]}`); +function toCommandValue(input) { + if (input === null || input === undefined) { + return ''; } - if (!hasValidPrivateField(manifest)) { - throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Private, manifest, manifestDirPath)} must be "true" if "${ManifestFieldNames.Workspaces}" is present. Received: ${manifest[ManifestFieldNames.Private]}`); + else if (typeof input === 'string' || input instanceof String) { + return input; } - return manifest; -} -exports.validateMonorepoPackageManifest = validateMonorepoPackageManifest; -/** - * Gets the prefix of an error message for a manifest file validation error. - * - * @param invalidField - The name of the invalid field. - * @param manifest - The manifest object that's invalid. - * @param manifestDirPath - The path to the directory of the manifest file - * relative to the root directory. - * @returns The prefix of a manifest validation error message. - */ -function getManifestErrorMessagePrefix(invalidField, manifest, manifestDirPath) { - return `${manifest[ManifestFieldNames.Name] - ? `"${manifest[ManifestFieldNames.Name]}" manifest "${invalidField}"` - : `"${invalidField}" of manifest in "${manifestDirPath}"`}`; + return JSON.stringify(input); } +exports.toCommandValue = toCommandValue; /** - * Get workspace directory locations, given the set of workspace patterns - * specified in the `workspaces` field of the root `package.json` file. * - * @param workspaces - The list of workspace patterns given in the root manifest. - * @param rootDir - The monorepo root directory. - * @returns The location of each workspace directory relative to the root directory + * @param annotationProperties + * @returns The command properties to send with the actual annotation command + * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 */ -async function getWorkspaceLocations(workspaces, rootDir) { - const resolvedWorkspaces = await Promise.all(workspaces.map((pattern) => glob(pattern, { cwd: rootDir }))); - return resolvedWorkspaces.flat(); +function toCommandProperties(annotationProperties) { + if (!Object.keys(annotationProperties).length) { + return {}; + } + return { + title: annotationProperties.title, + file: annotationProperties.file, + line: annotationProperties.startLine, + endLine: annotationProperties.endLine, + col: annotationProperties.startColumn, + endColumn: annotationProperties.endColumn + }; } -exports.getWorkspaceLocations = getWorkspaceLocations; -//# sourceMappingURL=package-utils.js.map +exports.toCommandProperties = toCommandProperties; +//# sourceMappingURL=utils.js.map /***/ }), -/***/ 2064: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 5526: +/***/ (function(__unused_webpack_module, exports) { "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isMajorSemverDiff = exports.isValidSemver = exports.SemverReleaseTypes = void 0; -const parse_1 = __importDefault(__nccwpck_require__(5925)); -var SemverReleaseTypes; -(function (SemverReleaseTypes) { - SemverReleaseTypes["Major"] = "major"; - SemverReleaseTypes["Premajor"] = "premajor"; - SemverReleaseTypes["Minor"] = "minor"; - SemverReleaseTypes["Preminor"] = "preminor"; - SemverReleaseTypes["Patch"] = "patch"; - SemverReleaseTypes["Prepatch"] = "prepatch"; - SemverReleaseTypes["Prerelease"] = "prerelease"; -})(SemverReleaseTypes = exports.SemverReleaseTypes || (exports.SemverReleaseTypes = {})); -/** - * Checks whether the given value is a valid, unprefixed SemVer version string. - * The string must begin with the numerical major version. - * - * (The semver package has a similar function, but it permits v-prefixes.) - * - * @param value - The value to check. - * @returns Whether the given value is a valid, unprefixed SemVer version - * string. - */ -function isValidSemver(value) { - var _a; - if (typeof value !== 'string') { +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.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; +class BasicCredentialHandler { + constructor(username, password) { + this.username = username; + this.password = password; + } + prepareRequest(options) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { return false; } - return ((_a = parse_1.default(value, { loose: false })) === null || _a === void 0 ? void 0 : _a.version) === value; + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } } -exports.isValidSemver = isValidSemver; -/** - * Checks whether the given SemVer diff is a major diff, i.e. "major" or - * "premajor". - * - * @param diff - The SemVer diff to check. - * @returns Whether the given SemVer diff is a major diff. - */ -function isMajorSemverDiff(diff) { - return diff.includes(SemverReleaseTypes.Major); +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) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Bearer ${this.token}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } } -exports.isMajorSemverDiff = isMajorSemverDiff; -//# sourceMappingURL=semver-utils.js.map +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) { + if (!options.headers) { + throw Error('The request has no headers'); + } + options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('not implemented'); + }); + } +} +exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; +//# sourceMappingURL=auth.js.map /***/ }), -/***/ 1610: +/***/ 6255: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +/* eslint-disable @typescript-eslint/no-explicit-any */ +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; +}; +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 })); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const constants_1 = __nccwpck_require__(1373); -const changelogTitle = '# Changelog'; -const changelogDescription = `All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).`; -// Stringification helpers -function stringifyCategory(category, changes) { - const categoryHeader = `### ${category}`; - if (changes.length === 0) { - return categoryHeader; +exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; +const http = __importStar(__nccwpck_require__(8605)); +const https = __importStar(__nccwpck_require__(7211)); +const pm = __importStar(__nccwpck_require__(9835)); +const tunnel = __importStar(__nccwpck_require__(4294)); +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) { + const 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; } - const changeDescriptions = changes - .map((description) => `- ${description}`) - .join('\n'); - return `${categoryHeader}\n${changeDescriptions}`; -} -function stringifyRelease(version, categories, { date, status } = {}) { - const releaseHeader = `## [${version}]${date ? ` - ${date}` : ''}${status ? ` [${status}]` : ''}`; - const categorizedChanges = constants_1.orderedChangeCategories - .filter((category) => categories[category]) - .map((category) => { - const changes = categories[category]; - return stringifyCategory(category, changes); - }) - .join('\n\n'); - if (categorizedChanges === '') { - return releaseHeader; + readBody() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + })); + }); } - return `${releaseHeader}\n${categorizedChanges}`; -} -function stringifyReleases(releases, changes) { - const stringifiedUnreleased = stringifyRelease(constants_1.unreleased, changes[constants_1.unreleased]); - const stringifiedReleases = releases.map(({ version, date, status }) => { - const categories = changes[version]; - return stringifyRelease(version, categories, { date, status }); - }); - return [stringifiedUnreleased, ...stringifiedReleases].join('\n\n'); -} -function withTrailingSlash(url) { - return url.endsWith('/') ? url : `${url}/`; -} -function getCompareUrl(repoUrl, firstRef, secondRef) { - return `${withTrailingSlash(repoUrl)}compare/${firstRef}...${secondRef}`; -} -function getTagUrl(repoUrl, tag) { - return `${withTrailingSlash(repoUrl)}releases/tag/${tag}`; } -function stringifyLinkReferenceDefinitions(repoUrl, releases) { - // A list of release versions in descending SemVer order - const descendingSemverVersions = releases - .map(({ version }) => version) - .sort((a, b) => { - return semver_1.default.gt(a, b) ? -1 : 1; - }); - const latestSemverVersion = descendingSemverVersions[0]; - // A list of release versions in chronological order - const chronologicalVersions = releases.map(({ version }) => version); - const hasReleases = chronologicalVersions.length > 0; - // The "Unreleased" section represents all changes made since the *highest* - // release, not the most recent release. This is to accomodate patch releases - // of older versions that don't represent the latest set of changes. - // - // For example, if a library has a v2.0.0 but the v1.0.0 release needed a - // security update, the v1.0.1 release would then be the most recent, but the - // range of unreleased changes would remain `v2.0.0...HEAD`. - // - // If there have not been any releases yet, the repo URL is used directly as - // the link definition. - const unreleasedLinkReferenceDefinition = `[${constants_1.unreleased}]: ${hasReleases - ? getCompareUrl(repoUrl, `v${latestSemverVersion}`, 'HEAD') - : withTrailingSlash(repoUrl)}`; - // The "previous" release that should be used for comparison is not always - // the most recent release chronologically. The _highest_ version that is - // lower than the current release is used as the previous release, so that - // patch releases on older releases can be accomodated. - const releaseLinkReferenceDefinitions = releases - .map(({ version }) => { - let diffUrl; - if (version === chronologicalVersions[chronologicalVersions.length - 1]) { - diffUrl = getTagUrl(repoUrl, `v${version}`); - } - else { - const versionIndex = chronologicalVersions.indexOf(version); - const previousVersion = chronologicalVersions - .slice(versionIndex) - .find((releaseVersion) => { - return semver_1.default.gt(version, releaseVersion); - }); - diffUrl = previousVersion - ? getCompareUrl(repoUrl, `v${previousVersion}`, `v${version}`) - : getTagUrl(repoUrl, `v${version}`); +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + const 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; + } } - return `[${version}]: ${diffUrl}`; - }) - .join('\n'); - return `${unreleasedLinkReferenceDefinition}\n${releaseLinkReferenceDefinitions}${releases.length > 0 ? '\n' : ''}`; -} -/** - * A changelog that complies with the - * ["Keep a Changelog" v1.1.0 guidelines](https://keepachangelog.com/en/1.0.0/). - * - * This changelog starts out completely empty, and allows new releases and - * changes to be added such that the changelog remains compliant at all times. - * This can be used to help validate the contents of a changelog, normalize - * formatting, update a changelog, or build one from scratch. - */ -class Changelog { + } + options(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + }); + } + get(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + }); + } + del(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + }); + } + post(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + }); + } + patch(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + }); + } + put(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + }); + } + head(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + }); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request(verb, requestUrl, stream, additionalHeaders); + }); + } /** - * Construct an empty changelog - * - * @param options - * @param options.repoUrl - The GitHub repository URL for the current project + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise */ - constructor({ repoUrl }) { - this._releases = []; - this._changes = { [constants_1.unreleased]: {} }; - this._repoUrl = repoUrl; + getJson(requestUrl, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + const res = yield this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + postJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + putJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + patchJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); } /** - * Add a release to the changelog. - * - * @param options - * @param options.addToStart - Determines whether the change is added to the - * top or bottom of the list of changes in this category. This defaults to - * `true` because changes should be in reverse-chronological order. This - * should be set to `false` when parsing a changelog top-to-bottom. - * @param options.date - An ISO-8601 formatted date, representing the release - * date. - * @param options.status - The status of the release (e.g. 'WITHDRAWN', - * 'DEPRECATED') - * @param options.version - The version of the current release, which should - * be a [SemVer](https://semver.org/spec/v2.0.0.html)-compatible version. + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch */ - addRelease({ addToStart = true, date, status, version }) { - if (!version) { - throw new Error('Version required'); - } - else if (semver_1.default.valid(version) === null) { - throw new Error(`Not a valid semver version: '${version}'`); + request(verb, requestUrl, data, headers) { + return __awaiter(this, void 0, void 0, function* () { + if (this._disposed) { + throw new Error('Client has already been disposed.'); + } + const parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + do { + response = yield this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (const handler of this.handlers) { + if (handler.canHandleAuthentication(response)) { + authenticationHandler = handler; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // 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 (response.message.statusCode && + HttpRedirectCodes.includes(response.message.statusCode) && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + const parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol === 'https:' && + parsedUrl.protocol !== parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + yield response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (const 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 = yield this.requestRaw(info, data); + redirectsRemaining--; + } + if (!response.message.statusCode || + !HttpResponseRetryCodes.includes(response.message.statusCode)) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + yield response.readBody(); + yield this._performExponentialBackoff(numTries); + } + } while (numTries < maxTries); + return response; + }); + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); } - else if (this._changes[version]) { - throw new Error(`Release already exists: '${version}'`); + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => { + function callbackForResult(err, res) { + if (err) { + reject(err); + } + else if (!res) { + // If `err` is not passed, then `res` must be passed. + reject(new Error('Unknown error')); + } + else { + resolve(res); + } + } + this.requestRawWithCallback(info, data, callbackForResult); + }); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + if (typeof data === 'string') { + if (!info.options.headers) { + info.options.headers = {}; + } + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); } - this._changes[version] = {}; - const newRelease = { version, date, status }; - if (addToStart) { - this._releases.unshift(newRelease); + let callbackCalled = false; + function handleResult(err, res) { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + } + const req = info.httpModule.request(info.options, (msg) => { + const res = new HttpClientResponse(msg); + handleResult(undefined, res); + }); + let socket; + 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}`)); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); } else { - this._releases.push(newRelease); + req.end(); } } /** - * Add a change to the changelog. - * - * @param options - * @param options.addToStart - Determines whether the change is added to the - * top or bottom of the list of changes in this category. This defaults to - * `true` because changes should be in reverse-chronological order. This - * should be set to `false` when parsing a changelog top-to-bottom. - * @param options.category - The category of the change. - * @param options.description - The description of the change. - * @param options.version - The version this change was released in. If this - * is not given, the change is assumed to be unreleased. + * 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 */ - addChange({ addToStart = true, category, description, version, }) { - if (!category) { - throw new Error('Category required'); + getAgent(serverUrl) { + const parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; } - else if (!constants_1.orderedChangeCategories.includes(category)) { - throw new Error(`Unrecognized category: '${category}'`); + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + for (const handler of this.handlers) { + handler.prepareRequest(info.options); + } } - else if (!description) { - throw new Error('Description required'); + return info; + } + _mergeHeaders(headers) { + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); } - else if (version !== undefined && !this._changes[version]) { - throw new Error(`Specified release version does not exist: '${version}'`); + return lowercaseKeys(headers || {}); + } + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; } - const release = version - ? this._changes[version] - : this._changes[constants_1.unreleased]; - if (!release[category]) { - release[category] = []; + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + const proxyUrl = pm.getProxyUrl(parsedUrl); + const useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; } - if (addToStart) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - release[category].unshift(description); + if (this._keepAlive && !useProxy) { + agent = this._agent; } - else { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - release[category].push(description); + // if agent is already assigned use that agent. + if (agent) { + return agent; } - } - /** - * Migrate all unreleased changes to a release section. - * - * Changes are migrated in their existing categories, and placed above any - * pre-existing changes in that category. - * - * @param version - The release version to migrate unreleased changes to. - */ - migrateUnreleasedChangesToRelease(version) { - const releaseChanges = this._changes[version]; - if (!releaseChanges) { - throw new Error(`Specified release version does not exist: '${version}'`); + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; } - const unreleasedChanges = this._changes[constants_1.unreleased]; - for (const category of Object.keys(unreleasedChanges)) { - if (releaseChanges[category]) { - releaseChanges[category] = [ - ...unreleasedChanges[category], - ...releaseChanges[category], - ]; + // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. + if (proxyUrl && proxyUrl.hostname) { + const agentOptions = { + maxSockets, + keepAlive: this._keepAlive, + proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + })), { host: proxyUrl.hostname, port: proxyUrl.port }) + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; } else { - releaseChanges[category] = unreleasedChanges[category]; + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; } - this._changes[constants_1.unreleased] = {}; + // 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 }; + 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; } - /** - * Gets the metadata for all releases. - * - * @returns The metadata for each release. - */ - getReleases() { - return this._releases; + _performExponentialBackoff(retryNumber) { + return __awaiter(this, void 0, void 0, function* () { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); + }); } - /** - * Gets the release of the given version. - * - * @param version - The version of the release to retrieve. - * @returns The specified release, or undefined if no such release exists. - */ - getRelease(version) { - return this.getReleases().find(({ version: _version }) => _version === version); + _processResponse(res, options) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + const statusCode = res.message.statusCode || 0; + const response = { + statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode === HttpCodes.NotFound) { + resolve(response); + } + // get the result from the body + function dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + const a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + let obj; + let contents; + try { + contents = yield res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // 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})`; + } + const err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + })); + }); } - /** - * Gets the stringified release of the given version. - * Throws an error if no such release exists. - * - * @param version - The version of the release to stringify. - * @returns The stringified release, as it appears in the changelog. - */ - getStringifiedRelease(version) { - const release = this.getRelease(version); - if (!release) { - throw new Error(`Specified release version does not exist: '${version}'`); +} +exports.HttpClient = HttpClient; +const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 9835: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.checkBypass = exports.getProxyUrl = void 0; +function getProxyUrl(reqUrl) { + const usingSsl = reqUrl.protocol === 'https:'; + if (checkBypass(reqUrl)) { + return undefined; + } + const proxyVar = (() => { + if (usingSsl) { + return process.env['https_proxy'] || process.env['HTTPS_PROXY']; } - const releaseChanges = this.getReleaseChanges(version); - return stringifyRelease(version, releaseChanges, release); + else { + return process.env['http_proxy'] || process.env['HTTP_PROXY']; + } + })(); + if (proxyVar) { + return new URL(proxyVar); } - /** - * Gets the changes in the given release, organized by category. - * - * @param version - The version of the release being retrieved. - * @returns The changes included in the given released. - */ - getReleaseChanges(version) { - return this._changes[version]; + else { + return undefined; } - /** - * Gets all changes that have not yet been released - * - * @returns The changes that have not yet been released. - */ - getUnreleasedChanges() { - return this._changes[constants_1.unreleased]; +} +exports.getProxyUrl = getProxyUrl; +function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false; } - /** - * The stringified changelog, formatted according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - * - * @returns The stringified changelog. - */ - toString() { - return `${changelogTitle} -${changelogDescription} - -${stringifyReleases(this._releases, this._changes)} - -${stringifyLinkReferenceDefinitions(this._repoUrl, this._releases)}`; + const 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 + const upperReqHosts = [reqUrl.hostname.toUpperCase()]; + if (typeof reqPort === 'number') { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + } + // Compare request host against noproxy + for (const upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { + if (upperReqHosts.some(x => x === upperNoProxyItem)) { + return true; + } + } + return false; } -exports.default = Changelog; -//# sourceMappingURL=changelog.js.map +exports.checkBypass = checkBypass; +//# sourceMappingURL=proxy.js.map /***/ }), -/***/ 1373: -/***/ ((__unused_webpack_module, exports) => { +/***/ 4208: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.unreleased = exports.orderedChangeCategories = exports.ChangeCategory = void 0; +exports.writeJsonFile = exports.readJsonObjectFile = void 0; +const fs_1 = __nccwpck_require__(5747); /** - * Change categories. + * Reads the assumed JSON file at the given path, attempts to parse it, and + * returns the resulting object. * - * Most of these categories are from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - * The "Uncategorized" category was added because we have many changes from - * older releases that would be difficult to categorize. + * Throws if failing to read or parse, or if the parsed JSON value is not a + * plain object. + * + * @param paths - The path segments pointing to the JSON file. Will be passed + * to path.join(). + * @returns The object corresponding to the parsed JSON file. */ -var ChangeCategory; -(function (ChangeCategory) { - /** - * For new features. - */ - ChangeCategory["Added"] = "Added"; - /** - * For changes in existing functionality. - */ - ChangeCategory["Changed"] = "Changed"; - /** - * For soon-to-be-removed features. - */ - ChangeCategory["Deprecated"] = "Deprecated"; - /** - * For bug fixes. - */ - ChangeCategory["Fixed"] = "Fixed"; - /** - * For now removed features. - */ - ChangeCategory["Removed"] = "Removed"; - /** - * In case of vulnerabilities. - */ - ChangeCategory["Security"] = "Security"; - /** - * For any changes that have yet to be categorized. - */ - ChangeCategory["Uncategorized"] = "Uncategorized"; -})(ChangeCategory = exports.ChangeCategory || (exports.ChangeCategory = {})); -/** - * Change categories in the order in which they should be listed in the - * changelog. - */ -exports.orderedChangeCategories = [ - ChangeCategory.Uncategorized, - ChangeCategory.Added, - ChangeCategory.Changed, - ChangeCategory.Deprecated, - ChangeCategory.Removed, - ChangeCategory.Fixed, - ChangeCategory.Security, -]; +async function readJsonObjectFile(path) { + const obj = JSON.parse(await fs_1.promises.readFile(path, 'utf8')); + if (!obj || typeof obj !== 'object' || Array.isArray(obj)) { + throw new Error(`Assumed JSON file at path "${path}" parsed to a non-object value.`); + } + return obj; +} +exports.readJsonObjectFile = readJsonObjectFile; /** - * The header for the section of the changelog listing unreleased changes. + * Attempts to write the given JSON-like value to the file at the given path. + * Adds a newline to the end of the file. + * + * @param path - The path to write the JSON file to, including the file itself. + * @param jsonValue - The JSON-like value to write to the file. Make sure that + * JSON.stringify can handle it. */ -exports.unreleased = 'Unreleased'; -//# sourceMappingURL=constants.js.map +async function writeJsonFile(path, jsonValue) { + await fs_1.promises.writeFile(path, `${JSON.stringify(jsonValue, null, 2)}\n`); +} +exports.writeJsonFile = writeJsonFile; +//# sourceMappingURL=file-utils.js.map /***/ }), -/***/ 9272: +/***/ 1281: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +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 __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.validateChangelog = exports.ChangelogFormattingError = exports.updateChangelog = exports.parseChangelog = exports.createEmptyChangelog = exports.Changelog = void 0; -var changelog_1 = __nccwpck_require__(1610); -Object.defineProperty(exports, "Changelog", ({ enumerable: true, get: function () { return __importDefault(changelog_1).default; } })); -var init_1 = __nccwpck_require__(3725); -Object.defineProperty(exports, "createEmptyChangelog", ({ enumerable: true, get: function () { return init_1.createEmptyChangelog; } })); -var parse_changelog_1 = __nccwpck_require__(7607); -Object.defineProperty(exports, "parseChangelog", ({ enumerable: true, get: function () { return parse_changelog_1.parseChangelog; } })); -var update_changelog_1 = __nccwpck_require__(9437); -Object.defineProperty(exports, "updateChangelog", ({ enumerable: true, get: function () { return update_changelog_1.updateChangelog; } })); -var validate_changelog_1 = __nccwpck_require__(4933); -Object.defineProperty(exports, "ChangelogFormattingError", ({ enumerable: true, get: function () { return validate_changelog_1.ChangelogFormattingError; } })); -Object.defineProperty(exports, "validateChangelog", ({ enumerable: true, get: function () { return validate_changelog_1.validateChangelog; } })); +__exportStar(__nccwpck_require__(4208), exports); +__exportStar(__nccwpck_require__(279), exports); +__exportStar(__nccwpck_require__(8609), exports); +__exportStar(__nccwpck_require__(2064), exports); //# sourceMappingURL=index.js.map /***/ }), -/***/ 3725: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 279: +/***/ ((__unused_webpack_module, exports) => { "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.createEmptyChangelog = void 0; -const changelog_1 = __importDefault(__nccwpck_require__(1610)); +exports.tabs = exports.isTruthyString = exports.getStringRecordValue = void 0; +const TWO_SPACES = ' '; /** - * Creates a new empty changelog. + * Utility function to get the value of a key from an object known to only + * contain string values, such as process.env. * - * @param options - * @param options.repoUrl - The GitHub repository URL for the current project. - * @returns The initial changelog text. + * Trims the value before returning it, and returns the empty string for any + * undefined values. + * + * @param key - The key of process.env to access. + * @returns The trimmed string value of the process.env key. Returns an empty + * string if the key is not set. */ -function createEmptyChangelog({ repoUrl }) { - const changelog = new changelog_1.default({ repoUrl }); - return changelog.toString(); -} -exports.createEmptyChangelog = createEmptyChangelog; -//# sourceMappingURL=init.js.map - -/***/ }), - -/***/ 7607: -/***/ (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.parseChangelog = void 0; -const changelog_1 = __importDefault(__nccwpck_require__(1610)); -const constants_1 = __nccwpck_require__(1373); -function truncated(line) { - return line.length > 80 ? `${line.slice(0, 80)}...` : line; +function getStringRecordValue(key, object) { + var _a; + return ((_a = object[key]) === null || _a === void 0 ? void 0 : _a.trim()) || ''; } -function isValidChangeCategory(category) { - return constants_1.ChangeCategory[category] !== undefined; +exports.getStringRecordValue = getStringRecordValue; +/** + * @param value - The value to test. + * @returns Whether the value is a non-empty string. + */ +function isTruthyString(value) { + return Boolean(value) && typeof value === 'string'; } +exports.isTruthyString = isTruthyString; /** - * Constructs a Changelog instance that represents the given changelog, which - * is parsed for release and change information. - * @param options - * @param options.changelogContent - The changelog to parse - * @param options.repoUrl - The GitHub repository URL for the current project. - * @returns A changelog instance that reflects the changelog text provided. + * @param numTabs - The number of tabs to return. A tab consists of two spaces. + * @param prefix - The prefix to prepend to the returned string, if any. + * @returns A string consisting of the prefix, if any, and the requested number + * of tabs. */ -function parseChangelog({ changelogContent, repoUrl, }) { - const changelogLines = changelogContent.split('\n'); - const changelog = new changelog_1.default({ repoUrl }); - const unreleasedHeaderIndex = changelogLines.indexOf(`## [${constants_1.unreleased}]`); - if (unreleasedHeaderIndex === -1) { - throw new Error(`Failed to find ${constants_1.unreleased} header`); - } - const unreleasedLinkReferenceDefinition = changelogLines.findIndex((line) => { - return line.startsWith(`[${constants_1.unreleased}]:`); - }); - if (unreleasedLinkReferenceDefinition === -1) { - throw new Error(`Failed to find ${constants_1.unreleased} link reference definition`); - } - const contentfulChangelogLines = changelogLines.slice(unreleasedHeaderIndex + 1, unreleasedLinkReferenceDefinition); - let mostRecentRelease; - let mostRecentCategory; - let currentChangeEntry; - /** - * Finalize a change entry, adding it to the changelog. - * - * This is required because change entries can span multiple lines. - * - * @param options - * @param options.removeTrailingNewline - Indicates that the trailing newline - * is not a part of the change description, and should therefore be removed. - */ - function finalizePreviousChange({ removeTrailingNewline = false, } = {}) { - if (!currentChangeEntry) { - return; - } - // This should never happen in practice, because `mostRecentCategory` is - // guaranteed to be set if `currentChangeEntry` is set. - /* istanbul ignore next */ - if (!mostRecentCategory) { - throw new Error('Cannot finalize change without most recent category.'); - } - if (removeTrailingNewline && currentChangeEntry.endsWith('\n')) { - currentChangeEntry = currentChangeEntry.slice(0, currentChangeEntry.length - 1); - } - changelog.addChange({ - addToStart: false, - category: mostRecentCategory, - description: currentChangeEntry, - version: mostRecentRelease, - }); - currentChangeEntry = undefined; +function tabs(numTabs, prefix) { + if (!Number.isInteger(numTabs) || numTabs < 1) { + throw new Error('Expected positive integer.'); } - for (const line of contentfulChangelogLines) { - if (line.startsWith('## [')) { - const results = line.match(/^## \[(\d+\.\d+\.\d+)\](?: - (\d\d\d\d-\d\d-\d\d))?(?: \[(\w+)\])?/u); - if (results === null) { - throw new Error(`Malformed release header: '${truncated(line)}'`); - } - // Trailing newline removed because the release section is expected to - // be prefixed by a newline. - finalizePreviousChange({ - removeTrailingNewline: true, - }); - mostRecentRelease = results[1]; - mostRecentCategory = undefined; - const date = results[2]; - const status = results[3]; - changelog.addRelease({ - addToStart: false, - date, - status, - version: mostRecentRelease, - }); - } - else if (line.startsWith('### ')) { - const results = line.match(/^### (\w+)$\b/u); - if (results === null) { - throw new Error(`Malformed category header: '${truncated(line)}'`); - } - const isFirstCategory = mostRecentCategory === null; - finalizePreviousChange({ - removeTrailingNewline: !isFirstCategory, - }); - if (!isValidChangeCategory(results[1])) { - throw new Error(`Invalid change category: '${results[1]}'`); - } - mostRecentCategory = results[1]; - } - else if (line.startsWith('- ')) { - if (!mostRecentCategory) { - throw new Error(`Category missing for change: '${truncated(line)}'`); - } - const description = line.slice(2); - finalizePreviousChange(); - currentChangeEntry = description; - } - else if (currentChangeEntry) { - currentChangeEntry += `\n${line}`; - } - else if (line === '') { - continue; - } - else { - throw new Error(`Unrecognized line: '${truncated(line)}'`); - } + const firstTab = prefix ? `${prefix}${TWO_SPACES}` : TWO_SPACES; + if (numTabs === 1) { + return firstTab; } - // Trailing newline removed because the reference link definition section is - // expected to be separated by a newline. - finalizePreviousChange({ removeTrailingNewline: true }); - return changelog; + return firstTab + new Array(numTabs).join(TWO_SPACES); } -exports.parseChangelog = parseChangelog; -//# sourceMappingURL=parse-changelog.js.map +exports.tabs = tabs; +//# sourceMappingURL=misc-utils.js.map /***/ }), -/***/ 9437: +/***/ 8609: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1316,10097 +1891,11815 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.updateChangelog = void 0; -const assert_1 = __nccwpck_require__(2357); -const execa_1 = __importDefault(__nccwpck_require__(6747)); -const parse_changelog_1 = __nccwpck_require__(7607); -const constants_1 = __nccwpck_require__(1373); -async function getMostRecentTag() { - const revListArgs = ['rev-list', '--tags', '--max-count=1']; - const results = await runCommand('git', revListArgs); - if (results.length === 0) { - return null; - } - const [mostRecentTagCommitHash] = results; - const [mostRecentTag] = await runCommand('git', [ - 'describe', - '--tags', - mostRecentTagCommitHash, - ]); - assert_1.strict.equal(mostRecentTag === null || mostRecentTag === void 0 ? void 0 : mostRecentTag[0], 'v', 'Most recent tag should start with v'); - return mostRecentTag; -} -async function getCommits(commitHashes) { - var _a; - const commits = []; - for (const commitHash of commitHashes) { - const [subject] = await runCommand('git', [ - 'show', - '-s', - '--format=%s', - commitHash, - ]); - assert_1.strict.ok(Boolean(subject), `"git show" returned empty subject for commit "${commitHash}".`); - let matchResults = subject.match(/\(#(\d+)\)/u); - let prNumber; - let description = subject; - if (matchResults) { - // Squash & Merge: the commit subject is parsed as ` (#)` - prNumber = matchResults[1]; - description = ((_a = subject.match(/^(.+)\s\(#\d+\)/u)) === null || _a === void 0 ? void 0 : _a[1]) || ''; - } - else { - // Merge: the PR ID is parsed from the git subject (which is of the form `Merge pull request - // # from `, and the description is assumed to be the first line of the body. - // If no body is found, the description is set to the commit subject - matchResults = subject.match(/#(\d+)\sfrom/u); - if (matchResults) { - prNumber = matchResults[1]; - const [firstLineOfBody] = await runCommand('git', [ - 'show', - '-s', - '--format=%b', - commitHash, - ]); - description = firstLineOfBody || subject; - } - } - // Otherwise: - // Normal commits: The commit subject is the description, and the PR ID is omitted. - commits.push({ prNumber, description }); - } - return commits; -} -function getAllChangeDescriptions(changelog) { - const releases = changelog.getReleases(); - const changeDescriptions = Object.values(changelog.getUnreleasedChanges()).flat(); - for (const release of releases) { - changeDescriptions.push(...Object.values(changelog.getReleaseChanges(release.version)).flat()); - } - return changeDescriptions; -} -function getAllLoggedPrNumbers(changelog) { - const changeDescriptions = getAllChangeDescriptions(changelog); - const prNumbersWithChangelogEntries = []; - for (const description of changeDescriptions) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const matchResults = description.matchAll(/\[#(\d+)\]/gu); - const prNumbers = Array.from(matchResults, (result) => result[1]); - prNumbersWithChangelogEntries.push(...prNumbers); - } - return prNumbersWithChangelogEntries; -} -async function getCommitHashesInRange(commitRange, rootDirectory) { - const revListArgs = ['rev-list', commitRange]; - if (rootDirectory) { - revListArgs.push(rootDirectory); - } - return await runCommand('git', revListArgs); -} +exports.getWorkspaceLocations = exports.validateMonorepoPackageManifest = exports.validatePolyrepoPackageManifest = exports.validatePackageManifestName = exports.validatePackageManifestVersion = exports.getPackageManifest = exports.ManifestFieldNames = exports.ManifestDependencyFieldNames = void 0; +const path_1 = __importDefault(__nccwpck_require__(5622)); +const util_1 = __nccwpck_require__(1669); +const glob_1 = __importDefault(__nccwpck_require__(1957)); +const misc_utils_1 = __nccwpck_require__(279); +const file_utils_1 = __nccwpck_require__(4208); +const semver_utils_1 = __nccwpck_require__(2064); +const glob = util_1.promisify(glob_1.default); +const PACKAGE_JSON = 'package.json'; +var ManifestDependencyFieldNames; +(function (ManifestDependencyFieldNames) { + ManifestDependencyFieldNames["Production"] = "dependencies"; + ManifestDependencyFieldNames["Development"] = "devDependencies"; + ManifestDependencyFieldNames["Peer"] = "peerDependencies"; + ManifestDependencyFieldNames["Bundled"] = "bundledDependencies"; + ManifestDependencyFieldNames["Optional"] = "optionalDependencies"; +})(ManifestDependencyFieldNames = exports.ManifestDependencyFieldNames || (exports.ManifestDependencyFieldNames = {})); +var ManifestFieldNames; +(function (ManifestFieldNames) { + ManifestFieldNames["Name"] = "name"; + ManifestFieldNames["Private"] = "private"; + ManifestFieldNames["Version"] = "version"; + ManifestFieldNames["Workspaces"] = "workspaces"; +})(ManifestFieldNames = exports.ManifestFieldNames || (exports.ManifestFieldNames = {})); /** - * Update a changelog with any commits made since the last release. Commits for - * PRs that are already included in the changelog are omitted. - * @param options - * @param options.changelogContent - The current changelog - * @param options.currentVersion - The current version. Required if - * `isReleaseCandidate` is set, but optional otherwise. - * @param options.repoUrl - The GitHub repository URL for the current project. - * @param options.isReleaseCandidate - Denotes whether the current project. - * is in the midst of release preparation or not. If this is set, any new - * changes are listed under the current release header. Otherwise, they are - * listed under the 'Unreleased' section. - * @param options.projectRootDirectory - The root project directory, used to - * filter results from various git commands. This path is assumed to be either - * absolute, or relative to the current directory. Defaults to the root of the - * current git repository. - * @returns The updated changelog text + * Read, parse, validate, and return the object corresponding to the + * package.json file in the given directory. + * + * An error is thrown if validation fails. + * + * @param containingDirPath - The complete path to the directory containing + * the package.json file. + * @returns The object corresponding to the parsed package.json file. */ -async function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, }) { - if (isReleaseCandidate && !currentVersion) { - throw new Error(`A version must be specified if 'isReleaseCandidate' is set.`); - } - const changelog = parse_changelog_1.parseChangelog({ changelogContent, repoUrl }); - // Ensure we have all tags on remote - await runCommand('git', ['fetch', '--tags']); - const mostRecentTag = await getMostRecentTag(); - if (isReleaseCandidate && mostRecentTag === `v${currentVersion}`) { - throw new Error(`Current version already has tag, which is unexpected for a release candidate.`); - } - const commitRange = mostRecentTag === null ? 'HEAD' : `${mostRecentTag}..HEAD`; - const commitsHashesSinceLastRelease = await getCommitHashesInRange(commitRange, projectRootDirectory); - const commits = await getCommits(commitsHashesSinceLastRelease); - const loggedPrNumbers = getAllLoggedPrNumbers(changelog); - const newCommits = commits.filter(({ prNumber }) => prNumber === undefined || !loggedPrNumbers.includes(prNumber)); - const hasUnreleasedChanges = Object.keys(changelog.getUnreleasedChanges()).length !== 0; - if (newCommits.length === 0 && - (!isReleaseCandidate || hasUnreleasedChanges)) { - return undefined; - } - // Ensure release header exists, if necessary - if (isReleaseCandidate && - !changelog - .getReleases() - .find((release) => release.version === currentVersion)) { - // Typecast: currentVersion will be defined here due to type guard at the - // top of this function. - changelog.addRelease({ version: currentVersion }); - } - if (isReleaseCandidate && hasUnreleasedChanges) { - // Typecast: currentVersion will be defined here due to type guard at the - // top of this function. - changelog.migrateUnreleasedChangesToRelease(currentVersion); - } - const newChangeEntries = newCommits.map(({ prNumber, description }) => { - if (prNumber) { - const suffix = `([#${prNumber}](${repoUrl}/pull/${prNumber}))`; - return `${description} ${suffix}`; - } - return description; - }); - for (const description of newChangeEntries.reverse()) { - changelog.addChange({ - version: isReleaseCandidate ? currentVersion : undefined, - category: constants_1.ChangeCategory.Uncategorized, - description, - }); - } - return changelog.toString(); +async function getPackageManifest(containingDirPath) { + return await file_utils_1.readJsonObjectFile(path_1.default.join(containingDirPath, PACKAGE_JSON)); } -exports.updateChangelog = updateChangelog; +exports.getPackageManifest = getPackageManifest; /** - * Executes a shell command in a child process and returns what it wrote to - * stdout, or rejects if the process exited with an error. + * Type guard to ensure that the given manifest has a valid "name" field. * - * @param command - The command to run, e.g. "git". - * @param args - The arguments to the command. - * @returns An array of the non-empty lines returned by the command. + * @param manifest - The manifest object to validate. + * @returns Whether the manifest has a valid "name" field. */ -async function runCommand(command, args) { - return (await execa_1.default(command, [...args])).stdout - .trim() - .split('\n') - .filter((line) => line !== ''); +function hasValidNameField(manifest) { + return misc_utils_1.isTruthyString(manifest[ManifestFieldNames.Name]); } -//# sourceMappingURL=update-changelog.js.map - -/***/ }), - -/***/ 4933: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.validateChangelog = exports.ChangelogFormattingError = exports.MissingCurrentVersionError = exports.UncategorizedChangesError = exports.UnreleasedChangesError = exports.InvalidChangelogError = void 0; -const constants_1 = __nccwpck_require__(1373); -const parse_changelog_1 = __nccwpck_require__(7607); /** - * Indicates that the changelog is invalid. + * Type guard to ensure that the given manifest has a valid "private" field. + * + * @param manifest - The manifest object to validate. + * @returns Whether the manifest has a valid "private" field. */ -class InvalidChangelogError extends Error { +function hasValidPrivateField(manifest) { + return manifest[ManifestFieldNames.Private] === true; } -exports.InvalidChangelogError = InvalidChangelogError; /** - * Indicates that unreleased changes are still present in the changelog. + * Type guard to ensure that the given manifest has a valid "version" field. + * + * @param manifest - The manifest object to validate. + * @returns Whether the manifest has a valid "version" field. */ -class UnreleasedChangesError extends InvalidChangelogError { - constructor() { - super('Unreleased changes present in the changelog'); - } -} -exports.UnreleasedChangesError = UnreleasedChangesError; -class UncategorizedChangesError extends InvalidChangelogError { - constructor() { - super('Uncategorized changes present in the changelog'); - } +function hasValidVersionField(manifest) { + return semver_utils_1.isValidSemver(manifest[ManifestFieldNames.Version]); } -exports.UncategorizedChangesError = UncategorizedChangesError; /** - * Indicates that the release header for the current version is missing. + * Type guard to ensure that the given manifest has a valid "worksapces" field. + * + * @param manifest - The manifest object to validate. + * @returns Whether the manifest has a valid "worksapces" field. */ -class MissingCurrentVersionError extends InvalidChangelogError { - /** - * @param currentVersion - The current version - */ - constructor(currentVersion) { - super(`Current version missing from changelog: '${currentVersion}'`); - } +function hasValidWorkspacesField(manifest) { + return (Array.isArray(manifest[ManifestFieldNames.Workspaces]) && + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + manifest[ManifestFieldNames.Workspaces].length > 0); } -exports.MissingCurrentVersionError = MissingCurrentVersionError; /** - * Represents a formatting error in a changelog. - */ -class ChangelogFormattingError extends InvalidChangelogError { - /** - * @param options - * @param options.validChangelog - The string contents of the well-formatted - * changelog. - * @param options.invalidChangelog - The string contents of the malformed - * changelog. - */ - constructor({ validChangelog, invalidChangelog, }) { - super('Changelog is not well-formatted'); - this.data = { - validChangelog, - invalidChangelog, - }; + * Validates the "version" field of a package manifest object, i.e. a parsed + * "package.json" file. + * + * @param manifest - The manifest to validate. + * @param manifestDirPath - The path to the directory containing the + * manifest file relative to the root directory. + * @returns The unmodified manifest, with the "version" field typed correctly. + */ +function validatePackageManifestVersion(manifest, manifestDirPath) { + if (!hasValidVersionField(manifest)) { + throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Version, manifest, manifestDirPath)} is not a valid SemVer version: ${manifest[ManifestFieldNames.Version]}`); } + return manifest; } -exports.ChangelogFormattingError = ChangelogFormattingError; +exports.validatePackageManifestVersion = validatePackageManifestVersion; /** - * Validates that a changelog is well-formatted. + * Validates the "name" field of a package manifest object, i.e. a parsed + * "package.json" file. * - * @param options - * @param options.changelogContent - The current changelog - * @param options.currentVersion - The current version. Required if - * `isReleaseCandidate` is set, but optional otherwise. - * @param options.repoUrl - The GitHub repository URL for the current - * project. - * @param options.isReleaseCandidate - Denotes whether the current project is in - * the midst of release preparation or not. If this is set, this command will - * also ensure the current version is represented in the changelog with a - * header, and that there are no unreleased changes present. - * @throws `InvalidChangelogError` - Will throw if the changelog is invalid - * @throws `MissingCurrentVersionError` - Will throw if `isReleaseCandidate` is - * `true` and the changelog is missing the release header for the current - * version. - * @throws `UnreleasedChangesError` - Will throw if `isReleaseCandidate` is - * `true` and the changelog contains unreleased changes. - * @throws `UnreleasedChangesError` - Will throw if `isReleaseCandidate` is - * `true` and the changelog contains uncategorized changes. - * @throws `ChangelogFormattingError` - Will throw if there is a formatting error. + * @param manifest - The manifest to validate. + * @param manifestDirPath - The path to the directory containing the + * manifest file relative to the root directory. + * @returns The unmodified manifest, with the "name" field typed correctly. */ -function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, }) { - var _a, _b; - const changelog = parse_changelog_1.parseChangelog({ changelogContent, repoUrl }); - const hasUnreleasedChanges = Object.keys(changelog.getUnreleasedChanges()).length !== 0; - const releaseChanges = currentVersion - ? changelog.getReleaseChanges(currentVersion) - : undefined; - if (isReleaseCandidate) { - if (!currentVersion) { - throw new Error(`A version must be specified if 'isReleaseCandidate' is set.`); - } - else if (!changelog - .getReleases() - .find((release) => release.version === currentVersion)) { - throw new MissingCurrentVersionError(currentVersion); - } - else if (hasUnreleasedChanges) { - throw new UnreleasedChangesError(); - } - else if (((_a = releaseChanges === null || releaseChanges === void 0 ? void 0 : releaseChanges[constants_1.ChangeCategory.Uncategorized]) === null || _a === void 0 ? void 0 : _a.length) && - ((_b = releaseChanges === null || releaseChanges === void 0 ? void 0 : releaseChanges[constants_1.ChangeCategory.Uncategorized]) === null || _b === void 0 ? void 0 : _b.length) !== 0) { - throw new UncategorizedChangesError(); - } +function validatePackageManifestName(manifest, manifestDirPath) { + if (!hasValidNameField(manifest)) { + throw new Error(`Manifest in "${manifestDirPath}" does not have a valid "${ManifestFieldNames.Name}" field.`); } - const validChangelog = changelog.toString(); - if (validChangelog !== changelogContent) { - throw new ChangelogFormattingError({ - validChangelog, - invalidChangelog: changelogContent, - }); + return manifest; +} +exports.validatePackageManifestName = validatePackageManifestName; +/** + * Validates the "version" and "name" fields of a package manifest object, + * i.e. a parsed "package.json" file. + * + * @param manifest - The manifest to validate. + * @param manifestDirPath - The path to the directory containing the + * manifest file relative to the root directory. + * @returns The unmodified manifest, with the "version" and "name" fields typed + * correctly. + */ +function validatePolyrepoPackageManifest(manifest, manifestDirPath) { + return validatePackageManifestName(validatePackageManifestVersion(manifest, manifestDirPath), manifestDirPath); +} +exports.validatePolyrepoPackageManifest = validatePolyrepoPackageManifest; +/** + * Validates the "workspaces" and "private" fields of a package manifest object, + * i.e. a parsed "package.json" file. + * + * Assumes that the manifest's "version" field is already validated. + * + * @param manifest - The manifest to validate. + * @param manifestDirPath - The path to the directory containing the + * manifest file relative to the root directory. + * @returns The unmodified manifest, with the "workspaces" and "private" fields + * typed correctly. + */ +function validateMonorepoPackageManifest(manifest, manifestDirPath) { + if (!hasValidWorkspacesField(manifest)) { + throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Workspaces, manifest, manifestDirPath)} must be a non-empty array if present. Received: ${manifest[ManifestFieldNames.Workspaces]}`); } + if (!hasValidPrivateField(manifest)) { + throw new Error(`${getManifestErrorMessagePrefix(ManifestFieldNames.Private, manifest, manifestDirPath)} must be "true" if "${ManifestFieldNames.Workspaces}" is present. Received: ${manifest[ManifestFieldNames.Private]}`); + } + return manifest; } -exports.validateChangelog = validateChangelog; -//# sourceMappingURL=validate-changelog.js.map +exports.validateMonorepoPackageManifest = validateMonorepoPackageManifest; +/** + * Gets the prefix of an error message for a manifest file validation error. + * + * @param invalidField - The name of the invalid field. + * @param manifest - The manifest object that's invalid. + * @param manifestDirPath - The path to the directory of the manifest file + * relative to the root directory. + * @returns The prefix of a manifest validation error message. + */ +function getManifestErrorMessagePrefix(invalidField, manifest, manifestDirPath) { + return `${manifest[ManifestFieldNames.Name] + ? `"${manifest[ManifestFieldNames.Name]}" manifest "${invalidField}"` + : `"${invalidField}" of manifest in "${manifestDirPath}"`}`; +} +/** + * Get workspace directory locations, given the set of workspace patterns + * specified in the `workspaces` field of the root `package.json` file. + * + * @param workspaces - The list of workspace patterns given in the root manifest. + * @param rootDir - The monorepo root directory. + * @returns The location of each workspace directory relative to the root directory + */ +async function getWorkspaceLocations(workspaces, rootDir) { + const resolvedWorkspaces = await Promise.all(workspaces.map((pattern) => glob(pattern, { cwd: rootDir }))); + return resolvedWorkspaces.flat(); +} +exports.getWorkspaceLocations = getWorkspaceLocations; +//# sourceMappingURL=package-utils.js.map + +/***/ }), + +/***/ 2064: +/***/ (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.isMajorSemverDiff = exports.isValidSemver = exports.SemverReleaseTypes = void 0; +const parse_1 = __importDefault(__nccwpck_require__(5925)); +var SemverReleaseTypes; +(function (SemverReleaseTypes) { + SemverReleaseTypes["Major"] = "major"; + SemverReleaseTypes["Premajor"] = "premajor"; + SemverReleaseTypes["Minor"] = "minor"; + SemverReleaseTypes["Preminor"] = "preminor"; + SemverReleaseTypes["Patch"] = "patch"; + SemverReleaseTypes["Prepatch"] = "prepatch"; + SemverReleaseTypes["Prerelease"] = "prerelease"; +})(SemverReleaseTypes = exports.SemverReleaseTypes || (exports.SemverReleaseTypes = {})); +/** + * Checks whether the given value is a valid, unprefixed SemVer version string. + * The string must begin with the numerical major version. + * + * (The semver package has a similar function, but it permits v-prefixes.) + * + * @param value - The value to check. + * @returns Whether the given value is a valid, unprefixed SemVer version + * string. + */ +function isValidSemver(value) { + var _a; + if (typeof value !== 'string') { + return false; + } + return ((_a = parse_1.default(value, { loose: false })) === null || _a === void 0 ? void 0 : _a.version) === value; +} +exports.isValidSemver = isValidSemver; +/** + * Checks whether the given SemVer diff is a major diff, i.e. "major" or + * "premajor". + * + * @param diff - The SemVer diff to check. + * @returns Whether the given SemVer diff is a major diff. + */ +function isMajorSemverDiff(diff) { + return diff.includes(SemverReleaseTypes.Major); +} +exports.isMajorSemverDiff = isMajorSemverDiff; +//# sourceMappingURL=semver-utils.js.map + +/***/ }), + +/***/ 1610: +/***/ (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 })); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const constants_1 = __nccwpck_require__(1373); +const changelogTitle = '# Changelog'; +const changelogDescription = `All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).`; +// Stringification helpers +function stringifyCategory(category, changes) { + const categoryHeader = `### ${category}`; + if (changes.length === 0) { + return categoryHeader; + } + const changeDescriptions = changes + .map((description) => `- ${description}`) + .join('\n'); + return `${categoryHeader}\n${changeDescriptions}`; +} +function stringifyRelease(version, categories, { date, status } = {}) { + const releaseHeader = `## [${version}]${date ? ` - ${date}` : ''}${status ? ` [${status}]` : ''}`; + const categorizedChanges = constants_1.orderedChangeCategories + .filter((category) => categories[category]) + .map((category) => { + const changes = categories[category]; + return stringifyCategory(category, changes); + }) + .join('\n\n'); + if (categorizedChanges === '') { + return releaseHeader; + } + return `${releaseHeader}\n${categorizedChanges}`; +} +function stringifyReleases(releases, changes) { + const stringifiedUnreleased = stringifyRelease(constants_1.unreleased, changes[constants_1.unreleased]); + const stringifiedReleases = releases.map(({ version, date, status }) => { + const categories = changes[version]; + return stringifyRelease(version, categories, { date, status }); + }); + return [stringifiedUnreleased, ...stringifiedReleases].join('\n\n'); +} +function withTrailingSlash(url) { + return url.endsWith('/') ? url : `${url}/`; +} +function getCompareUrl(repoUrl, firstRef, secondRef) { + return `${withTrailingSlash(repoUrl)}compare/${firstRef}...${secondRef}`; +} +function getTagUrl(repoUrl, tag) { + return `${withTrailingSlash(repoUrl)}releases/tag/${tag}`; +} +function stringifyLinkReferenceDefinitions(repoUrl, releases) { + // A list of release versions in descending SemVer order + const descendingSemverVersions = releases + .map(({ version }) => version) + .sort((a, b) => { + return semver_1.default.gt(a, b) ? -1 : 1; + }); + const latestSemverVersion = descendingSemverVersions[0]; + // A list of release versions in chronological order + const chronologicalVersions = releases.map(({ version }) => version); + const hasReleases = chronologicalVersions.length > 0; + // The "Unreleased" section represents all changes made since the *highest* + // release, not the most recent release. This is to accomodate patch releases + // of older versions that don't represent the latest set of changes. + // + // For example, if a library has a v2.0.0 but the v1.0.0 release needed a + // security update, the v1.0.1 release would then be the most recent, but the + // range of unreleased changes would remain `v2.0.0...HEAD`. + // + // If there have not been any releases yet, the repo URL is used directly as + // the link definition. + const unreleasedLinkReferenceDefinition = `[${constants_1.unreleased}]: ${hasReleases + ? getCompareUrl(repoUrl, `v${latestSemverVersion}`, 'HEAD') + : withTrailingSlash(repoUrl)}`; + // The "previous" release that should be used for comparison is not always + // the most recent release chronologically. The _highest_ version that is + // lower than the current release is used as the previous release, so that + // patch releases on older releases can be accomodated. + const releaseLinkReferenceDefinitions = releases + .map(({ version }) => { + let diffUrl; + if (version === chronologicalVersions[chronologicalVersions.length - 1]) { + diffUrl = getTagUrl(repoUrl, `v${version}`); + } + else { + const versionIndex = chronologicalVersions.indexOf(version); + const previousVersion = chronologicalVersions + .slice(versionIndex) + .find((releaseVersion) => { + return semver_1.default.gt(version, releaseVersion); + }); + diffUrl = previousVersion + ? getCompareUrl(repoUrl, `v${previousVersion}`, `v${version}`) + : getTagUrl(repoUrl, `v${version}`); + } + return `[${version}]: ${diffUrl}`; + }) + .join('\n'); + return `${unreleasedLinkReferenceDefinition}\n${releaseLinkReferenceDefinitions}${releases.length > 0 ? '\n' : ''}`; +} +/** + * A changelog that complies with the + * ["Keep a Changelog" v1.1.0 guidelines](https://keepachangelog.com/en/1.0.0/). + * + * This changelog starts out completely empty, and allows new releases and + * changes to be added such that the changelog remains compliant at all times. + * This can be used to help validate the contents of a changelog, normalize + * formatting, update a changelog, or build one from scratch. + */ +class Changelog { + /** + * Construct an empty changelog + * + * @param options + * @param options.repoUrl - The GitHub repository URL for the current project + */ + constructor({ repoUrl }) { + this._releases = []; + this._changes = { [constants_1.unreleased]: {} }; + this._repoUrl = repoUrl; + } + /** + * Add a release to the changelog. + * + * @param options + * @param options.addToStart - Determines whether the change is added to the + * top or bottom of the list of changes in this category. This defaults to + * `true` because changes should be in reverse-chronological order. This + * should be set to `false` when parsing a changelog top-to-bottom. + * @param options.date - An ISO-8601 formatted date, representing the release + * date. + * @param options.status - The status of the release (e.g. 'WITHDRAWN', + * 'DEPRECATED') + * @param options.version - The version of the current release, which should + * be a [SemVer](https://semver.org/spec/v2.0.0.html)-compatible version. + */ + addRelease({ addToStart = true, date, status, version }) { + if (!version) { + throw new Error('Version required'); + } + else if (semver_1.default.valid(version) === null) { + throw new Error(`Not a valid semver version: '${version}'`); + } + else if (this._changes[version]) { + throw new Error(`Release already exists: '${version}'`); + } + this._changes[version] = {}; + const newRelease = { version, date, status }; + if (addToStart) { + this._releases.unshift(newRelease); + } + else { + this._releases.push(newRelease); + } + } + /** + * Add a change to the changelog. + * + * @param options + * @param options.addToStart - Determines whether the change is added to the + * top or bottom of the list of changes in this category. This defaults to + * `true` because changes should be in reverse-chronological order. This + * should be set to `false` when parsing a changelog top-to-bottom. + * @param options.category - The category of the change. + * @param options.description - The description of the change. + * @param options.version - The version this change was released in. If this + * is not given, the change is assumed to be unreleased. + */ + addChange({ addToStart = true, category, description, version, }) { + if (!category) { + throw new Error('Category required'); + } + else if (!constants_1.orderedChangeCategories.includes(category)) { + throw new Error(`Unrecognized category: '${category}'`); + } + else if (!description) { + throw new Error('Description required'); + } + else if (version !== undefined && !this._changes[version]) { + throw new Error(`Specified release version does not exist: '${version}'`); + } + const release = version + ? this._changes[version] + : this._changes[constants_1.unreleased]; + if (!release[category]) { + release[category] = []; + } + if (addToStart) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + release[category].unshift(description); + } + else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + release[category].push(description); + } + } + /** + * Migrate all unreleased changes to a release section. + * + * Changes are migrated in their existing categories, and placed above any + * pre-existing changes in that category. + * + * @param version - The release version to migrate unreleased changes to. + */ + migrateUnreleasedChangesToRelease(version) { + const releaseChanges = this._changes[version]; + if (!releaseChanges) { + throw new Error(`Specified release version does not exist: '${version}'`); + } + const unreleasedChanges = this._changes[constants_1.unreleased]; + for (const category of Object.keys(unreleasedChanges)) { + if (releaseChanges[category]) { + releaseChanges[category] = [ + ...unreleasedChanges[category], + ...releaseChanges[category], + ]; + } + else { + releaseChanges[category] = unreleasedChanges[category]; + } + } + this._changes[constants_1.unreleased] = {}; + } + /** + * Gets the metadata for all releases. + * + * @returns The metadata for each release. + */ + getReleases() { + return this._releases; + } + /** + * Gets the release of the given version. + * + * @param version - The version of the release to retrieve. + * @returns The specified release, or undefined if no such release exists. + */ + getRelease(version) { + return this.getReleases().find(({ version: _version }) => _version === version); + } + /** + * Gets the stringified release of the given version. + * Throws an error if no such release exists. + * + * @param version - The version of the release to stringify. + * @returns The stringified release, as it appears in the changelog. + */ + getStringifiedRelease(version) { + const release = this.getRelease(version); + if (!release) { + throw new Error(`Specified release version does not exist: '${version}'`); + } + const releaseChanges = this.getReleaseChanges(version); + return stringifyRelease(version, releaseChanges, release); + } + /** + * Gets the changes in the given release, organized by category. + * + * @param version - The version of the release being retrieved. + * @returns The changes included in the given released. + */ + getReleaseChanges(version) { + return this._changes[version]; + } + /** + * Gets all changes that have not yet been released + * + * @returns The changes that have not yet been released. + */ + getUnreleasedChanges() { + return this._changes[constants_1.unreleased]; + } + /** + * The stringified changelog, formatted according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + * + * @returns The stringified changelog. + */ + toString() { + return `${changelogTitle} +${changelogDescription} + +${stringifyReleases(this._releases, this._changes)} + +${stringifyLinkReferenceDefinitions(this._repoUrl, this._releases)}`; + } +} +exports.default = Changelog; +//# sourceMappingURL=changelog.js.map + +/***/ }), + +/***/ 1373: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.unreleased = exports.orderedChangeCategories = exports.ChangeCategory = void 0; +/** + * Change categories. + * + * Most of these categories are from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + * The "Uncategorized" category was added because we have many changes from + * older releases that would be difficult to categorize. + */ +var ChangeCategory; +(function (ChangeCategory) { + /** + * For new features. + */ + ChangeCategory["Added"] = "Added"; + /** + * For changes in existing functionality. + */ + ChangeCategory["Changed"] = "Changed"; + /** + * For soon-to-be-removed features. + */ + ChangeCategory["Deprecated"] = "Deprecated"; + /** + * For bug fixes. + */ + ChangeCategory["Fixed"] = "Fixed"; + /** + * For now removed features. + */ + ChangeCategory["Removed"] = "Removed"; + /** + * In case of vulnerabilities. + */ + ChangeCategory["Security"] = "Security"; + /** + * For any changes that have yet to be categorized. + */ + ChangeCategory["Uncategorized"] = "Uncategorized"; +})(ChangeCategory = exports.ChangeCategory || (exports.ChangeCategory = {})); +/** + * Change categories in the order in which they should be listed in the + * changelog. + */ +exports.orderedChangeCategories = [ + ChangeCategory.Uncategorized, + ChangeCategory.Added, + ChangeCategory.Changed, + ChangeCategory.Deprecated, + ChangeCategory.Removed, + ChangeCategory.Fixed, + ChangeCategory.Security, +]; +/** + * The header for the section of the changelog listing unreleased changes. + */ +exports.unreleased = 'Unreleased'; +//# sourceMappingURL=constants.js.map + +/***/ }), + +/***/ 9272: +/***/ (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.validateChangelog = exports.ChangelogFormattingError = exports.updateChangelog = exports.parseChangelog = exports.createEmptyChangelog = exports.Changelog = void 0; +var changelog_1 = __nccwpck_require__(1610); +Object.defineProperty(exports, "Changelog", ({ enumerable: true, get: function () { return __importDefault(changelog_1).default; } })); +var init_1 = __nccwpck_require__(3725); +Object.defineProperty(exports, "createEmptyChangelog", ({ enumerable: true, get: function () { return init_1.createEmptyChangelog; } })); +var parse_changelog_1 = __nccwpck_require__(7607); +Object.defineProperty(exports, "parseChangelog", ({ enumerable: true, get: function () { return parse_changelog_1.parseChangelog; } })); +var update_changelog_1 = __nccwpck_require__(9437); +Object.defineProperty(exports, "updateChangelog", ({ enumerable: true, get: function () { return update_changelog_1.updateChangelog; } })); +var validate_changelog_1 = __nccwpck_require__(4933); +Object.defineProperty(exports, "ChangelogFormattingError", ({ enumerable: true, get: function () { return validate_changelog_1.ChangelogFormattingError; } })); +Object.defineProperty(exports, "validateChangelog", ({ enumerable: true, get: function () { return validate_changelog_1.validateChangelog; } })); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 3725: +/***/ (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.createEmptyChangelog = void 0; +const changelog_1 = __importDefault(__nccwpck_require__(1610)); +/** + * Creates a new empty changelog. + * + * @param options + * @param options.repoUrl - The GitHub repository URL for the current project. + * @returns The initial changelog text. + */ +function createEmptyChangelog({ repoUrl }) { + const changelog = new changelog_1.default({ repoUrl }); + return changelog.toString(); +} +exports.createEmptyChangelog = createEmptyChangelog; +//# sourceMappingURL=init.js.map + +/***/ }), + +/***/ 7607: +/***/ (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.parseChangelog = void 0; +const changelog_1 = __importDefault(__nccwpck_require__(1610)); +const constants_1 = __nccwpck_require__(1373); +function truncated(line) { + return line.length > 80 ? `${line.slice(0, 80)}...` : line; +} +function isValidChangeCategory(category) { + return constants_1.ChangeCategory[category] !== undefined; +} +/** + * Constructs a Changelog instance that represents the given changelog, which + * is parsed for release and change information. + * @param options + * @param options.changelogContent - The changelog to parse + * @param options.repoUrl - The GitHub repository URL for the current project. + * @returns A changelog instance that reflects the changelog text provided. + */ +function parseChangelog({ changelogContent, repoUrl, }) { + const changelogLines = changelogContent.split('\n'); + const changelog = new changelog_1.default({ repoUrl }); + const unreleasedHeaderIndex = changelogLines.indexOf(`## [${constants_1.unreleased}]`); + if (unreleasedHeaderIndex === -1) { + throw new Error(`Failed to find ${constants_1.unreleased} header`); + } + const unreleasedLinkReferenceDefinition = changelogLines.findIndex((line) => { + return line.startsWith(`[${constants_1.unreleased}]:`); + }); + if (unreleasedLinkReferenceDefinition === -1) { + throw new Error(`Failed to find ${constants_1.unreleased} link reference definition`); + } + const contentfulChangelogLines = changelogLines.slice(unreleasedHeaderIndex + 1, unreleasedLinkReferenceDefinition); + let mostRecentRelease; + let mostRecentCategory; + let currentChangeEntry; + /** + * Finalize a change entry, adding it to the changelog. + * + * This is required because change entries can span multiple lines. + * + * @param options + * @param options.removeTrailingNewline - Indicates that the trailing newline + * is not a part of the change description, and should therefore be removed. + */ + function finalizePreviousChange({ removeTrailingNewline = false, } = {}) { + if (!currentChangeEntry) { + return; + } + // This should never happen in practice, because `mostRecentCategory` is + // guaranteed to be set if `currentChangeEntry` is set. + /* istanbul ignore next */ + if (!mostRecentCategory) { + throw new Error('Cannot finalize change without most recent category.'); + } + if (removeTrailingNewline && currentChangeEntry.endsWith('\n')) { + currentChangeEntry = currentChangeEntry.slice(0, currentChangeEntry.length - 1); + } + changelog.addChange({ + addToStart: false, + category: mostRecentCategory, + description: currentChangeEntry, + version: mostRecentRelease, + }); + currentChangeEntry = undefined; + } + for (const line of contentfulChangelogLines) { + if (line.startsWith('## [')) { + const results = line.match(/^## \[(\d+\.\d+\.\d+)\](?: - (\d\d\d\d-\d\d-\d\d))?(?: \[(\w+)\])?/u); + if (results === null) { + throw new Error(`Malformed release header: '${truncated(line)}'`); + } + // Trailing newline removed because the release section is expected to + // be prefixed by a newline. + finalizePreviousChange({ + removeTrailingNewline: true, + }); + mostRecentRelease = results[1]; + mostRecentCategory = undefined; + const date = results[2]; + const status = results[3]; + changelog.addRelease({ + addToStart: false, + date, + status, + version: mostRecentRelease, + }); + } + else if (line.startsWith('### ')) { + const results = line.match(/^### (\w+)$\b/u); + if (results === null) { + throw new Error(`Malformed category header: '${truncated(line)}'`); + } + const isFirstCategory = mostRecentCategory === null; + finalizePreviousChange({ + removeTrailingNewline: !isFirstCategory, + }); + if (!isValidChangeCategory(results[1])) { + throw new Error(`Invalid change category: '${results[1]}'`); + } + mostRecentCategory = results[1]; + } + else if (line.startsWith('- ')) { + if (!mostRecentCategory) { + throw new Error(`Category missing for change: '${truncated(line)}'`); + } + const description = line.slice(2); + finalizePreviousChange(); + currentChangeEntry = description; + } + else if (currentChangeEntry) { + currentChangeEntry += `\n${line}`; + } + else if (line === '') { + continue; + } + else { + throw new Error(`Unrecognized line: '${truncated(line)}'`); + } + } + // Trailing newline removed because the reference link definition section is + // expected to be separated by a newline. + finalizePreviousChange({ removeTrailingNewline: true }); + return changelog; +} +exports.parseChangelog = parseChangelog; +//# sourceMappingURL=parse-changelog.js.map + +/***/ }), + +/***/ 9437: +/***/ (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.updateChangelog = void 0; +const assert_1 = __nccwpck_require__(2357); +const execa_1 = __importDefault(__nccwpck_require__(6747)); +const parse_changelog_1 = __nccwpck_require__(7607); +const constants_1 = __nccwpck_require__(1373); +async function getMostRecentTag() { + const revListArgs = ['rev-list', '--tags', '--max-count=1']; + const results = await runCommand('git', revListArgs); + if (results.length === 0) { + return null; + } + const [mostRecentTagCommitHash] = results; + const [mostRecentTag] = await runCommand('git', [ + 'describe', + '--tags', + mostRecentTagCommitHash, + ]); + assert_1.strict.equal(mostRecentTag === null || mostRecentTag === void 0 ? void 0 : mostRecentTag[0], 'v', 'Most recent tag should start with v'); + return mostRecentTag; +} +async function getCommits(commitHashes) { + var _a; + const commits = []; + for (const commitHash of commitHashes) { + const [subject] = await runCommand('git', [ + 'show', + '-s', + '--format=%s', + commitHash, + ]); + assert_1.strict.ok(Boolean(subject), `"git show" returned empty subject for commit "${commitHash}".`); + let matchResults = subject.match(/\(#(\d+)\)/u); + let prNumber; + let description = subject; + if (matchResults) { + // Squash & Merge: the commit subject is parsed as ` (#)` + prNumber = matchResults[1]; + description = ((_a = subject.match(/^(.+)\s\(#\d+\)/u)) === null || _a === void 0 ? void 0 : _a[1]) || ''; + } + else { + // Merge: the PR ID is parsed from the git subject (which is of the form `Merge pull request + // # from `, and the description is assumed to be the first line of the body. + // If no body is found, the description is set to the commit subject + matchResults = subject.match(/#(\d+)\sfrom/u); + if (matchResults) { + prNumber = matchResults[1]; + const [firstLineOfBody] = await runCommand('git', [ + 'show', + '-s', + '--format=%b', + commitHash, + ]); + description = firstLineOfBody || subject; + } + } + // Otherwise: + // Normal commits: The commit subject is the description, and the PR ID is omitted. + commits.push({ prNumber, description }); + } + return commits; +} +function getAllChangeDescriptions(changelog) { + const releases = changelog.getReleases(); + const changeDescriptions = Object.values(changelog.getUnreleasedChanges()).flat(); + for (const release of releases) { + changeDescriptions.push(...Object.values(changelog.getReleaseChanges(release.version)).flat()); + } + return changeDescriptions; +} +function getAllLoggedPrNumbers(changelog) { + const changeDescriptions = getAllChangeDescriptions(changelog); + const prNumbersWithChangelogEntries = []; + for (const description of changeDescriptions) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const matchResults = description.matchAll(/\[#(\d+)\]/gu); + const prNumbers = Array.from(matchResults, (result) => result[1]); + prNumbersWithChangelogEntries.push(...prNumbers); + } + return prNumbersWithChangelogEntries; +} +async function getCommitHashesInRange(commitRange, rootDirectory) { + const revListArgs = ['rev-list', commitRange]; + if (rootDirectory) { + revListArgs.push(rootDirectory); + } + return await runCommand('git', revListArgs); +} +/** + * Update a changelog with any commits made since the last release. Commits for + * PRs that are already included in the changelog are omitted. + * @param options + * @param options.changelogContent - The current changelog + * @param options.currentVersion - The current version. Required if + * `isReleaseCandidate` is set, but optional otherwise. + * @param options.repoUrl - The GitHub repository URL for the current project. + * @param options.isReleaseCandidate - Denotes whether the current project. + * is in the midst of release preparation or not. If this is set, any new + * changes are listed under the current release header. Otherwise, they are + * listed under the 'Unreleased' section. + * @param options.projectRootDirectory - The root project directory, used to + * filter results from various git commands. This path is assumed to be either + * absolute, or relative to the current directory. Defaults to the root of the + * current git repository. + * @returns The updated changelog text + */ +async function updateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, projectRootDirectory, }) { + if (isReleaseCandidate && !currentVersion) { + throw new Error(`A version must be specified if 'isReleaseCandidate' is set.`); + } + const changelog = parse_changelog_1.parseChangelog({ changelogContent, repoUrl }); + // Ensure we have all tags on remote + await runCommand('git', ['fetch', '--tags']); + const mostRecentTag = await getMostRecentTag(); + if (isReleaseCandidate && mostRecentTag === `v${currentVersion}`) { + throw new Error(`Current version already has tag, which is unexpected for a release candidate.`); + } + const commitRange = mostRecentTag === null ? 'HEAD' : `${mostRecentTag}..HEAD`; + const commitsHashesSinceLastRelease = await getCommitHashesInRange(commitRange, projectRootDirectory); + const commits = await getCommits(commitsHashesSinceLastRelease); + const loggedPrNumbers = getAllLoggedPrNumbers(changelog); + const newCommits = commits.filter(({ prNumber }) => prNumber === undefined || !loggedPrNumbers.includes(prNumber)); + const hasUnreleasedChanges = Object.keys(changelog.getUnreleasedChanges()).length !== 0; + if (newCommits.length === 0 && + (!isReleaseCandidate || hasUnreleasedChanges)) { + return undefined; + } + // Ensure release header exists, if necessary + if (isReleaseCandidate && + !changelog + .getReleases() + .find((release) => release.version === currentVersion)) { + // Typecast: currentVersion will be defined here due to type guard at the + // top of this function. + changelog.addRelease({ version: currentVersion }); + } + if (isReleaseCandidate && hasUnreleasedChanges) { + // Typecast: currentVersion will be defined here due to type guard at the + // top of this function. + changelog.migrateUnreleasedChangesToRelease(currentVersion); + } + const newChangeEntries = newCommits.map(({ prNumber, description }) => { + if (prNumber) { + const suffix = `([#${prNumber}](${repoUrl}/pull/${prNumber}))`; + return `${description} ${suffix}`; + } + return description; + }); + for (const description of newChangeEntries.reverse()) { + changelog.addChange({ + version: isReleaseCandidate ? currentVersion : undefined, + category: constants_1.ChangeCategory.Uncategorized, + description, + }); + } + return changelog.toString(); +} +exports.updateChangelog = updateChangelog; +/** + * Executes a shell command in a child process and returns what it wrote to + * stdout, or rejects if the process exited with an error. + * + * @param command - The command to run, e.g. "git". + * @param args - The arguments to the command. + * @returns An array of the non-empty lines returned by the command. + */ +async function runCommand(command, args) { + return (await execa_1.default(command, [...args])).stdout + .trim() + .split('\n') + .filter((line) => line !== ''); +} +//# sourceMappingURL=update-changelog.js.map + +/***/ }), + +/***/ 4933: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.validateChangelog = exports.ChangelogFormattingError = exports.MissingCurrentVersionError = exports.UncategorizedChangesError = exports.UnreleasedChangesError = exports.InvalidChangelogError = void 0; +const constants_1 = __nccwpck_require__(1373); +const parse_changelog_1 = __nccwpck_require__(7607); +/** + * Indicates that the changelog is invalid. + */ +class InvalidChangelogError extends Error { +} +exports.InvalidChangelogError = InvalidChangelogError; +/** + * Indicates that unreleased changes are still present in the changelog. + */ +class UnreleasedChangesError extends InvalidChangelogError { + constructor() { + super('Unreleased changes present in the changelog'); + } +} +exports.UnreleasedChangesError = UnreleasedChangesError; +class UncategorizedChangesError extends InvalidChangelogError { + constructor() { + super('Uncategorized changes present in the changelog'); + } +} +exports.UncategorizedChangesError = UncategorizedChangesError; +/** + * Indicates that the release header for the current version is missing. + */ +class MissingCurrentVersionError extends InvalidChangelogError { + /** + * @param currentVersion - The current version + */ + constructor(currentVersion) { + super(`Current version missing from changelog: '${currentVersion}'`); + } +} +exports.MissingCurrentVersionError = MissingCurrentVersionError; +/** + * Represents a formatting error in a changelog. + */ +class ChangelogFormattingError extends InvalidChangelogError { + /** + * @param options + * @param options.validChangelog - The string contents of the well-formatted + * changelog. + * @param options.invalidChangelog - The string contents of the malformed + * changelog. + */ + constructor({ validChangelog, invalidChangelog, }) { + super('Changelog is not well-formatted'); + this.data = { + validChangelog, + invalidChangelog, + }; + } +} +exports.ChangelogFormattingError = ChangelogFormattingError; +/** + * Validates that a changelog is well-formatted. + * + * @param options + * @param options.changelogContent - The current changelog + * @param options.currentVersion - The current version. Required if + * `isReleaseCandidate` is set, but optional otherwise. + * @param options.repoUrl - The GitHub repository URL for the current + * project. + * @param options.isReleaseCandidate - Denotes whether the current project is in + * the midst of release preparation or not. If this is set, this command will + * also ensure the current version is represented in the changelog with a + * header, and that there are no unreleased changes present. + * @throws `InvalidChangelogError` - Will throw if the changelog is invalid + * @throws `MissingCurrentVersionError` - Will throw if `isReleaseCandidate` is + * `true` and the changelog is missing the release header for the current + * version. + * @throws `UnreleasedChangesError` - Will throw if `isReleaseCandidate` is + * `true` and the changelog contains unreleased changes. + * @throws `UnreleasedChangesError` - Will throw if `isReleaseCandidate` is + * `true` and the changelog contains uncategorized changes. + * @throws `ChangelogFormattingError` - Will throw if there is a formatting error. + */ +function validateChangelog({ changelogContent, currentVersion, repoUrl, isReleaseCandidate, }) { + var _a, _b; + const changelog = parse_changelog_1.parseChangelog({ changelogContent, repoUrl }); + const hasUnreleasedChanges = Object.keys(changelog.getUnreleasedChanges()).length !== 0; + const releaseChanges = currentVersion + ? changelog.getReleaseChanges(currentVersion) + : undefined; + if (isReleaseCandidate) { + if (!currentVersion) { + throw new Error(`A version must be specified if 'isReleaseCandidate' is set.`); + } + else if (!changelog + .getReleases() + .find((release) => release.version === currentVersion)) { + throw new MissingCurrentVersionError(currentVersion); + } + else if (hasUnreleasedChanges) { + throw new UnreleasedChangesError(); + } + else if (((_a = releaseChanges === null || releaseChanges === void 0 ? void 0 : releaseChanges[constants_1.ChangeCategory.Uncategorized]) === null || _a === void 0 ? void 0 : _a.length) && + ((_b = releaseChanges === null || releaseChanges === void 0 ? void 0 : releaseChanges[constants_1.ChangeCategory.Uncategorized]) === null || _b === void 0 ? void 0 : _b.length) !== 0) { + throw new UncategorizedChangesError(); + } + } + const validChangelog = changelog.toString(); + if (validChangelog !== changelogContent) { + throw new ChangelogFormattingError({ + validChangelog, + invalidChangelog: changelogContent, + }); + } +} +exports.validateChangelog = validateChangelog; +//# sourceMappingURL=validate-changelog.js.map + +/***/ }), + +/***/ 6747: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const path = __nccwpck_require__(5622); +const childProcess = __nccwpck_require__(3129); +const crossSpawn = __nccwpck_require__(7881); +const stripFinalNewline = __nccwpck_require__(8174); +const npmRunPath = __nccwpck_require__(502); +const onetime = __nccwpck_require__(9082); +const makeError = __nccwpck_require__(1771); +const normalizeStdio = __nccwpck_require__(3390); +const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = __nccwpck_require__(1509); +const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __nccwpck_require__(7788); +const {mergePromise, getSpawnedPromise} = __nccwpck_require__(4856); +const {joinCommand, parseCommand, getEscapedCommand} = __nccwpck_require__(3516); + +const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; + +const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => { + const env = extendEnv ? {...process.env, ...envOption} : envOption; + + if (preferLocal) { + return npmRunPath.env({env, cwd: localDir, execPath}); + } + + return env; +}; + +const handleArguments = (file, args, options = {}) => { + const parsed = crossSpawn._parse(file, args, options); + file = parsed.command; + args = parsed.args; + options = parsed.options; + + options = { + maxBuffer: DEFAULT_MAX_BUFFER, + buffer: true, + stripFinalNewline: true, + extendEnv: true, + preferLocal: false, + localDir: options.cwd || process.cwd(), + execPath: process.execPath, + encoding: 'utf8', + reject: true, + cleanup: true, + all: false, + windowsHide: true, + ...options + }; + + options.env = getEnv(options); + + options.stdio = normalizeStdio(options); + + if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') { + // #116 + args.unshift('/q'); + } + + return {file, args, options, parsed}; +}; + +const handleOutput = (options, value, error) => { + if (typeof value !== 'string' && !Buffer.isBuffer(value)) { + // When `execa.sync()` errors, we normalize it to '' to mimic `execa()` + return error === undefined ? undefined : ''; + } + + if (options.stripFinalNewline) { + return stripFinalNewline(value); + } + + return value; +}; + +const execa = (file, args, options) => { + const parsed = handleArguments(file, args, options); + const command = joinCommand(file, args); + const escapedCommand = getEscapedCommand(file, args); + + validateTimeout(parsed.options); + + let spawned; + try { + spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options); + } catch (error) { + // Ensure the returned error is always both a promise and a child process + const dummySpawned = new childProcess.ChildProcess(); + const errorPromise = Promise.reject(makeError({ + error, + stdout: '', + stderr: '', + all: '', + command, + escapedCommand, + parsed, + timedOut: false, + isCanceled: false, + killed: false + })); + return mergePromise(dummySpawned, errorPromise); + } + + const spawnedPromise = getSpawnedPromise(spawned); + const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise); + const processDone = setExitHandler(spawned, parsed.options, timedPromise); + + const context = {isCanceled: false}; + + spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned)); + spawned.cancel = spawnedCancel.bind(null, spawned, context); + + const handlePromise = async () => { + const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone); + const stdout = handleOutput(parsed.options, stdoutResult); + const stderr = handleOutput(parsed.options, stderrResult); + const all = handleOutput(parsed.options, allResult); + + if (error || exitCode !== 0 || signal !== null) { + const returnedError = makeError({ + error, + exitCode, + signal, + stdout, + stderr, + all, + command, + escapedCommand, + parsed, + timedOut, + isCanceled: context.isCanceled, + killed: spawned.killed + }); + + if (!parsed.options.reject) { + return returnedError; + } + + throw returnedError; + } + + return { + command, + escapedCommand, + exitCode: 0, + stdout, + stderr, + all, + failed: false, + timedOut: false, + isCanceled: false, + killed: false + }; + }; + + const handlePromiseOnce = onetime(handlePromise); + + handleInput(spawned, parsed.options.input); + + spawned.all = makeAllStream(spawned, parsed.options); + + return mergePromise(spawned, handlePromiseOnce); +}; + +module.exports = execa; + +module.exports.sync = (file, args, options) => { + const parsed = handleArguments(file, args, options); + const command = joinCommand(file, args); + const escapedCommand = getEscapedCommand(file, args); + + validateInputSync(parsed.options); + + let result; + try { + result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options); + } catch (error) { + throw makeError({ + error, + stdout: '', + stderr: '', + all: '', + command, + escapedCommand, + parsed, + timedOut: false, + isCanceled: false, + killed: false + }); + } + + const stdout = handleOutput(parsed.options, result.stdout, result.error); + const stderr = handleOutput(parsed.options, result.stderr, result.error); + + if (result.error || result.status !== 0 || result.signal !== null) { + const error = makeError({ + stdout, + stderr, + error: result.error, + signal: result.signal, + exitCode: result.status, + command, + escapedCommand, + parsed, + timedOut: result.error && result.error.code === 'ETIMEDOUT', + isCanceled: false, + killed: result.signal !== null + }); + + if (!parsed.options.reject) { + return error; + } + + throw error; + } + + return { + command, + escapedCommand, + exitCode: 0, + stdout, + stderr, + failed: false, + timedOut: false, + isCanceled: false, + killed: false + }; +}; + +module.exports.command = (command, options) => { + const [file, ...args] = parseCommand(command); + return execa(file, args, options); +}; + +module.exports.commandSync = (command, options) => { + const [file, ...args] = parseCommand(command); + return execa.sync(file, args, options); +}; + +module.exports.node = (scriptPath, args, options = {}) => { + if (args && !Array.isArray(args) && typeof args === 'object') { + options = args; + args = []; + } + + const stdio = normalizeStdio.node(options); + const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect')); + + const { + nodePath = process.execPath, + nodeOptions = defaultExecArgv + } = options; + + return execa( + nodePath, + [ + ...nodeOptions, + scriptPath, + ...(Array.isArray(args) ? args : []) + ], + { + ...options, + stdin: undefined, + stdout: undefined, + stderr: undefined, + stdio, + shell: false + } + ); +}; + + +/***/ }), + +/***/ 3516: +/***/ ((module) => { + +"use strict"; + +const normalizeArgs = (file, args = []) => { + if (!Array.isArray(args)) { + return [file]; + } + + return [file, ...args]; +}; + +const NO_ESCAPE_REGEXP = /^[\w.-]+$/; +const DOUBLE_QUOTES_REGEXP = /"/g; + +const escapeArg = arg => { + if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) { + return arg; + } + + return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`; +}; + +const joinCommand = (file, args) => { + return normalizeArgs(file, args).join(' '); +}; + +const getEscapedCommand = (file, args) => { + return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' '); +}; + +const SPACES_REGEXP = / +/g; + +// Handle `execa.command()` +const parseCommand = command => { + const tokens = []; + for (const token of command.trim().split(SPACES_REGEXP)) { + // Allow spaces to be escaped by a backslash if not meant as a delimiter + const previousToken = tokens[tokens.length - 1]; + if (previousToken && previousToken.endsWith('\\')) { + // Merge previous token with current one + tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`; + } else { + tokens.push(token); + } + } + + return tokens; +}; + +module.exports = { + joinCommand, + getEscapedCommand, + parseCommand +}; + + +/***/ }), + +/***/ 1771: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const {signalsByName} = __nccwpck_require__(2323); + +const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { + if (timedOut) { + return `timed out after ${timeout} milliseconds`; + } + + if (isCanceled) { + return 'was canceled'; + } + + if (errorCode !== undefined) { + return `failed with ${errorCode}`; + } + + if (signal !== undefined) { + return `was killed with ${signal} (${signalDescription})`; + } + + if (exitCode !== undefined) { + return `failed with exit code ${exitCode}`; + } + + return 'failed'; +}; + +const makeError = ({ + stdout, + stderr, + all, + error, + signal, + exitCode, + command, + escapedCommand, + timedOut, + isCanceled, + killed, + parsed: {options: {timeout}} +}) => { + // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`. + // We normalize them to `undefined` + exitCode = exitCode === null ? undefined : exitCode; + signal = signal === null ? undefined : signal; + const signalDescription = signal === undefined ? undefined : signalsByName[signal].description; + + const errorCode = error && error.code; + + const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}); + const execaMessage = `Command ${prefix}: ${command}`; + const isError = Object.prototype.toString.call(error) === '[object Error]'; + const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; + const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n'); + + if (isError) { + error.originalMessage = error.message; + error.message = message; + } else { + error = new Error(message); + } + + error.shortMessage = shortMessage; + error.command = command; + error.escapedCommand = escapedCommand; + error.exitCode = exitCode; + error.signal = signal; + error.signalDescription = signalDescription; + error.stdout = stdout; + error.stderr = stderr; + + if (all !== undefined) { + error.all = all; + } + + if ('bufferedData' in error) { + delete error.bufferedData; + } + + error.failed = true; + error.timedOut = Boolean(timedOut); + error.isCanceled = isCanceled; + error.killed = killed && !timedOut; + + return error; +}; + +module.exports = makeError; + + +/***/ }), + +/***/ 1509: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const os = __nccwpck_require__(2087); +const onExit = __nccwpck_require__(4931); + +const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; + +// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior +const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => { + const killResult = kill(signal); + setKillTimeout(kill, signal, options, killResult); + return killResult; +}; + +const setKillTimeout = (kill, signal, options, killResult) => { + if (!shouldForceKill(signal, options, killResult)) { + return; + } + + const timeout = getForceKillAfterTimeout(options); + const t = setTimeout(() => { + kill('SIGKILL'); + }, timeout); + + // Guarded because there's no `.unref()` when `execa` is used in the renderer + // process in Electron. This cannot be tested since we don't run tests in + // Electron. + // istanbul ignore else + if (t.unref) { + t.unref(); + } +}; + +const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => { + return isSigterm(signal) && forceKillAfterTimeout !== false && killResult; +}; + +const isSigterm = signal => { + return signal === os.constants.signals.SIGTERM || + (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM'); +}; + +const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { + if (forceKillAfterTimeout === true) { + return DEFAULT_FORCE_KILL_TIMEOUT; + } + + if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { + throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`); + } + + return forceKillAfterTimeout; +}; + +// `childProcess.cancel()` +const spawnedCancel = (spawned, context) => { + const killResult = spawned.kill(); + + if (killResult) { + context.isCanceled = true; + } +}; + +const timeoutKill = (spawned, signal, reject) => { + spawned.kill(signal); + reject(Object.assign(new Error('Timed out'), {timedOut: true, signal})); +}; + +// `timeout` option handling +const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => { + if (timeout === 0 || timeout === undefined) { + return spawnedPromise; + } + + let timeoutId; + const timeoutPromise = new Promise((resolve, reject) => { + timeoutId = setTimeout(() => { + timeoutKill(spawned, killSignal, reject); + }, timeout); + }); + + const safeSpawnedPromise = spawnedPromise.finally(() => { + clearTimeout(timeoutId); + }); + + return Promise.race([timeoutPromise, safeSpawnedPromise]); +}; + +const validateTimeout = ({timeout}) => { + if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) { + throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); + } +}; + +// `cleanup` option handling +const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { + if (!cleanup || detached) { + return timedPromise; + } + + const removeExitHandler = onExit(() => { + spawned.kill(); + }); + + return timedPromise.finally(() => { + removeExitHandler(); + }); +}; + +module.exports = { + spawnedKill, + spawnedCancel, + setupTimeout, + validateTimeout, + setExitHandler +}; + + +/***/ }), + +/***/ 4856: +/***/ ((module) => { + +"use strict"; + + +const nativePromisePrototype = (async () => {})().constructor.prototype; +const descriptors = ['then', 'catch', 'finally'].map(property => [ + property, + Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property) +]); + +// The return value is a mixin of `childProcess` and `Promise` +const mergePromise = (spawned, promise) => { + for (const [property, descriptor] of descriptors) { + // Starting the main `promise` is deferred to avoid consuming streams + const value = typeof promise === 'function' ? + (...args) => Reflect.apply(descriptor.value, promise(), args) : + descriptor.value.bind(promise); + + Reflect.defineProperty(spawned, property, {...descriptor, value}); + } + + return spawned; +}; + +// Use promises instead of `child_process` events +const getSpawnedPromise = spawned => { + return new Promise((resolve, reject) => { + spawned.on('exit', (exitCode, signal) => { + resolve({exitCode, signal}); + }); + + spawned.on('error', error => { + reject(error); + }); + + if (spawned.stdin) { + spawned.stdin.on('error', error => { + reject(error); + }); + } + }); +}; + +module.exports = { + mergePromise, + getSpawnedPromise +}; + + /***/ }), -/***/ 6747: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 3390: +/***/ ((module) => { "use strict"; -const path = __nccwpck_require__(5622); -const childProcess = __nccwpck_require__(3129); -const crossSpawn = __nccwpck_require__(2746); -const stripFinalNewline = __nccwpck_require__(8174); -const npmRunPath = __nccwpck_require__(502); -const onetime = __nccwpck_require__(9082); -const makeError = __nccwpck_require__(1771); -const normalizeStdio = __nccwpck_require__(3390); -const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = __nccwpck_require__(1509); -const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __nccwpck_require__(7788); -const {mergePromise, getSpawnedPromise} = __nccwpck_require__(4856); -const {joinCommand, parseCommand, getEscapedCommand} = __nccwpck_require__(3516); +const aliases = ['stdin', 'stdout', 'stderr']; -const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; +const hasAlias = options => aliases.some(alias => options[alias] !== undefined); -const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => { - const env = extendEnv ? {...process.env, ...envOption} : envOption; +const normalizeStdio = options => { + if (!options) { + return; + } - if (preferLocal) { - return npmRunPath.env({env, cwd: localDir, execPath}); + const {stdio} = options; + + if (stdio === undefined) { + return aliases.map(alias => options[alias]); } - return env; + if (hasAlias(options)) { + throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`); + } + + if (typeof stdio === 'string') { + return stdio; + } + + if (!Array.isArray(stdio)) { + throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``); + } + + const length = Math.max(stdio.length, aliases.length); + return Array.from({length}, (value, index) => stdio[index]); }; -const handleArguments = (file, args, options = {}) => { - const parsed = crossSpawn._parse(file, args, options); - file = parsed.command; - args = parsed.args; - options = parsed.options; +module.exports = normalizeStdio; - options = { - maxBuffer: DEFAULT_MAX_BUFFER, - buffer: true, - stripFinalNewline: true, - extendEnv: true, - preferLocal: false, - localDir: options.cwd || process.cwd(), - execPath: process.execPath, - encoding: 'utf8', - reject: true, - cleanup: true, - all: false, - windowsHide: true, - ...options - }; +// `ipc` is pushed unless it is already present +module.exports.node = options => { + const stdio = normalizeStdio(options); - options.env = getEnv(options); + if (stdio === 'ipc') { + return 'ipc'; + } - options.stdio = normalizeStdio(options); + if (stdio === undefined || typeof stdio === 'string') { + return [stdio, stdio, stdio, 'ipc']; + } - if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') { - // #116 - args.unshift('/q'); + if (stdio.includes('ipc')) { + return stdio; } - return {file, args, options, parsed}; + return [...stdio, 'ipc']; }; -const handleOutput = (options, value, error) => { - if (typeof value !== 'string' && !Buffer.isBuffer(value)) { - // When `execa.sync()` errors, we normalize it to '' to mimic `execa()` - return error === undefined ? undefined : ''; + +/***/ }), + +/***/ 7788: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const isStream = __nccwpck_require__(1554); +const getStream = __nccwpck_require__(7816); +const mergeStream = __nccwpck_require__(2621); + +// `input` option +const handleInput = (spawned, input) => { + // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 + // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 + if (input === undefined || spawned.stdin === undefined) { + return; } - if (options.stripFinalNewline) { - return stripFinalNewline(value); + if (isStream(input)) { + input.pipe(spawned.stdin); + } else { + spawned.stdin.end(input); } +}; - return value; +// `all` interleaves `stdout` and `stderr` +const makeAllStream = (spawned, {all}) => { + if (!all || (!spawned.stdout && !spawned.stderr)) { + return; + } + + const mixed = mergeStream(); + + if (spawned.stdout) { + mixed.add(spawned.stdout); + } + + if (spawned.stderr) { + mixed.add(spawned.stderr); + } + + return mixed; }; -const execa = (file, args, options) => { - const parsed = handleArguments(file, args, options); - const command = joinCommand(file, args); - const escapedCommand = getEscapedCommand(file, args); +// On failure, `result.stdout|stderr|all` should contain the currently buffered stream +const getBufferedData = async (stream, streamPromise) => { + if (!stream) { + return; + } - validateTimeout(parsed.options); + stream.destroy(); - let spawned; try { - spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options); + return await streamPromise; } catch (error) { - // Ensure the returned error is always both a promise and a child process - const dummySpawned = new childProcess.ChildProcess(); - const errorPromise = Promise.reject(makeError({ - error, - stdout: '', - stderr: '', - all: '', - command, - escapedCommand, - parsed, - timedOut: false, - isCanceled: false, - killed: false - })); - return mergePromise(dummySpawned, errorPromise); + return error.bufferedData; } +}; - const spawnedPromise = getSpawnedPromise(spawned); - const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise); - const processDone = setExitHandler(spawned, parsed.options, timedPromise); +const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => { + if (!stream || !buffer) { + return; + } - const context = {isCanceled: false}; + if (encoding) { + return getStream(stream, {encoding, maxBuffer}); + } - spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned)); - spawned.cancel = spawnedCancel.bind(null, spawned, context); + return getStream.buffer(stream, {maxBuffer}); +}; - const handlePromise = async () => { - const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone); - const stdout = handleOutput(parsed.options, stdoutResult); - const stderr = handleOutput(parsed.options, stderrResult); - const all = handleOutput(parsed.options, allResult); +// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all) +const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => { + const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer}); + const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer}); + const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2}); + + try { + return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]); + } catch (error) { + return Promise.all([ + {error, signal: error.signal, timedOut: error.timedOut}, + getBufferedData(stdout, stdoutPromise), + getBufferedData(stderr, stderrPromise), + getBufferedData(all, allPromise) + ]); + } +}; + +const validateInputSync = ({input}) => { + if (isStream(input)) { + throw new TypeError('The `input` option cannot be a stream in sync mode'); + } +}; + +module.exports = { + handleInput, + makeAllStream, + getSpawnedResult, + validateInputSync +}; + + + +/***/ }), + +/***/ 6579: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const {PassThrough: PassThroughStream} = __nccwpck_require__(2413); + +module.exports = options => { + options = {...options}; + + const {array} = options; + let {encoding} = options; + const isBuffer = encoding === 'buffer'; + let objectMode = false; + + if (array) { + objectMode = !(encoding || isBuffer); + } else { + encoding = encoding || 'utf8'; + } + + if (isBuffer) { + encoding = null; + } + + const stream = new PassThroughStream({objectMode}); + + if (encoding) { + stream.setEncoding(encoding); + } + + let length = 0; + const chunks = []; - if (error || exitCode !== 0 || signal !== null) { - const returnedError = makeError({ - error, - exitCode, - signal, - stdout, - stderr, - all, - command, - escapedCommand, - parsed, - timedOut, - isCanceled: context.isCanceled, - killed: spawned.killed - }); + stream.on('data', chunk => { + chunks.push(chunk); - if (!parsed.options.reject) { - return returnedError; - } + if (objectMode) { + length = chunks.length; + } else { + length += chunk.length; + } + }); - throw returnedError; + stream.getBufferedValue = () => { + if (array) { + return chunks; } - return { - command, - escapedCommand, - exitCode: 0, - stdout, - stderr, - all, - failed: false, - timedOut: false, - isCanceled: false, - killed: false - }; + return isBuffer ? Buffer.concat(chunks, length) : chunks.join(''); }; - const handlePromiseOnce = onetime(handlePromise); - - handleInput(spawned, parsed.options.input); - - spawned.all = makeAllStream(spawned, parsed.options); + stream.getBufferedLength = () => length; - return mergePromise(spawned, handlePromiseOnce); + return stream; }; -module.exports = execa; -module.exports.sync = (file, args, options) => { - const parsed = handleArguments(file, args, options); - const command = joinCommand(file, args); - const escapedCommand = getEscapedCommand(file, args); +/***/ }), - validateInputSync(parsed.options); +/***/ 7816: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - let result; - try { - result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options); - } catch (error) { - throw makeError({ - error, - stdout: '', - stderr: '', - all: '', - command, - escapedCommand, - parsed, - timedOut: false, - isCanceled: false, - killed: false - }); - } +"use strict"; - const stdout = handleOutput(parsed.options, result.stdout, result.error); - const stderr = handleOutput(parsed.options, result.stderr, result.error); +const {constants: BufferConstants} = __nccwpck_require__(4293); +const stream = __nccwpck_require__(2413); +const {promisify} = __nccwpck_require__(1669); +const bufferStream = __nccwpck_require__(6579); - if (result.error || result.status !== 0 || result.signal !== null) { - const error = makeError({ - stdout, - stderr, - error: result.error, - signal: result.signal, - exitCode: result.status, - command, - escapedCommand, - parsed, - timedOut: result.error && result.error.code === 'ETIMEDOUT', - isCanceled: false, - killed: result.signal !== null - }); +const streamPipelinePromisified = promisify(stream.pipeline); - if (!parsed.options.reject) { - return error; - } +class MaxBufferError extends Error { + constructor() { + super('maxBuffer exceeded'); + this.name = 'MaxBufferError'; + } +} - throw error; +async function getStream(inputStream, options) { + if (!inputStream) { + throw new Error('Expected a stream'); } - return { - command, - escapedCommand, - exitCode: 0, - stdout, - stderr, - failed: false, - timedOut: false, - isCanceled: false, - killed: false + options = { + maxBuffer: Infinity, + ...options }; -}; -module.exports.command = (command, options) => { - const [file, ...args] = parseCommand(command); - return execa(file, args, options); -}; + const {maxBuffer} = options; + const stream = bufferStream(options); -module.exports.commandSync = (command, options) => { - const [file, ...args] = parseCommand(command); - return execa.sync(file, args, options); -}; + await new Promise((resolve, reject) => { + const rejectPromise = error => { + // Don't retrieve an oversized buffer. + if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) { + error.bufferedData = stream.getBufferedValue(); + } -module.exports.node = (scriptPath, args, options = {}) => { - if (args && !Array.isArray(args) && typeof args === 'object') { - options = args; - args = []; - } + reject(error); + }; - const stdio = normalizeStdio.node(options); - const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect')); + (async () => { + try { + await streamPipelinePromisified(inputStream, stream); + resolve(); + } catch (error) { + rejectPromise(error); + } + })(); - const { - nodePath = process.execPath, - nodeOptions = defaultExecArgv - } = options; + stream.on('data', () => { + if (stream.getBufferedLength() > maxBuffer) { + rejectPromise(new MaxBufferError()); + } + }); + }); - return execa( - nodePath, - [ - ...nodeOptions, - scriptPath, - ...(Array.isArray(args) ? args : []) - ], - { - ...options, - stdin: undefined, - stdout: undefined, - stderr: undefined, - stdio, - shell: false - } - ); -}; + return stream.getBufferedValue(); +} + +module.exports = getStream; +module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'}); +module.exports.array = (stream, options) => getStream(stream, {...options, array: true}); +module.exports.MaxBufferError = MaxBufferError; /***/ }), -/***/ 3516: -/***/ ((module) => { +/***/ 9127: +/***/ ((__unused_webpack_module, exports) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGNALS=void 0; -const normalizeArgs = (file, args = []) => { - if (!Array.isArray(args)) { - return [file]; - } +const SIGNALS=[ +{ +name:"SIGHUP", +number:1, +action:"terminate", +description:"Terminal closed", +standard:"posix"}, - return [file, ...args]; -}; +{ +name:"SIGINT", +number:2, +action:"terminate", +description:"User interruption with CTRL-C", +standard:"ansi"}, -const NO_ESCAPE_REGEXP = /^[\w.-]+$/; -const DOUBLE_QUOTES_REGEXP = /"/g; +{ +name:"SIGQUIT", +number:3, +action:"core", +description:"User interruption with CTRL-\\", +standard:"posix"}, + +{ +name:"SIGILL", +number:4, +action:"core", +description:"Invalid machine instruction", +standard:"ansi"}, + +{ +name:"SIGTRAP", +number:5, +action:"core", +description:"Debugger breakpoint", +standard:"posix"}, + +{ +name:"SIGABRT", +number:6, +action:"core", +description:"Aborted", +standard:"ansi"}, + +{ +name:"SIGIOT", +number:6, +action:"core", +description:"Aborted", +standard:"bsd"}, + +{ +name:"SIGBUS", +number:7, +action:"core", +description: +"Bus error due to misaligned, non-existing address or paging error", +standard:"bsd"}, -const escapeArg = arg => { - if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) { - return arg; - } +{ +name:"SIGEMT", +number:7, +action:"terminate", +description:"Command should be emulated but is not implemented", +standard:"other"}, - return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`; -}; +{ +name:"SIGFPE", +number:8, +action:"core", +description:"Floating point arithmetic error", +standard:"ansi"}, -const joinCommand = (file, args) => { - return normalizeArgs(file, args).join(' '); -}; +{ +name:"SIGKILL", +number:9, +action:"terminate", +description:"Forced termination", +standard:"posix", +forced:true}, -const getEscapedCommand = (file, args) => { - return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' '); -}; +{ +name:"SIGUSR1", +number:10, +action:"terminate", +description:"Application-specific signal", +standard:"posix"}, -const SPACES_REGEXP = / +/g; +{ +name:"SIGSEGV", +number:11, +action:"core", +description:"Segmentation fault", +standard:"ansi"}, -// Handle `execa.command()` -const parseCommand = command => { - const tokens = []; - for (const token of command.trim().split(SPACES_REGEXP)) { - // Allow spaces to be escaped by a backslash if not meant as a delimiter - const previousToken = tokens[tokens.length - 1]; - if (previousToken && previousToken.endsWith('\\')) { - // Merge previous token with current one - tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`; - } else { - tokens.push(token); - } - } +{ +name:"SIGUSR2", +number:12, +action:"terminate", +description:"Application-specific signal", +standard:"posix"}, - return tokens; -}; +{ +name:"SIGPIPE", +number:13, +action:"terminate", +description:"Broken pipe or socket", +standard:"posix"}, -module.exports = { - joinCommand, - getEscapedCommand, - parseCommand -}; +{ +name:"SIGALRM", +number:14, +action:"terminate", +description:"Timeout or timer", +standard:"posix"}, +{ +name:"SIGTERM", +number:15, +action:"terminate", +description:"Termination", +standard:"ansi"}, -/***/ }), +{ +name:"SIGSTKFLT", +number:16, +action:"terminate", +description:"Stack is empty or overflowed", +standard:"other"}, -/***/ 1771: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +{ +name:"SIGCHLD", +number:17, +action:"ignore", +description:"Child process terminated, paused or unpaused", +standard:"posix"}, -"use strict"; +{ +name:"SIGCLD", +number:17, +action:"ignore", +description:"Child process terminated, paused or unpaused", +standard:"other"}, -const {signalsByName} = __nccwpck_require__(2323); +{ +name:"SIGCONT", +number:18, +action:"unpause", +description:"Unpaused", +standard:"posix", +forced:true}, -const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { - if (timedOut) { - return `timed out after ${timeout} milliseconds`; - } +{ +name:"SIGSTOP", +number:19, +action:"pause", +description:"Paused", +standard:"posix", +forced:true}, - if (isCanceled) { - return 'was canceled'; - } +{ +name:"SIGTSTP", +number:20, +action:"pause", +description:"Paused using CTRL-Z or \"suspend\"", +standard:"posix"}, - if (errorCode !== undefined) { - return `failed with ${errorCode}`; - } +{ +name:"SIGTTIN", +number:21, +action:"pause", +description:"Background process cannot read terminal input", +standard:"posix"}, - if (signal !== undefined) { - return `was killed with ${signal} (${signalDescription})`; - } +{ +name:"SIGBREAK", +number:21, +action:"terminate", +description:"User interruption with CTRL-BREAK", +standard:"other"}, - if (exitCode !== undefined) { - return `failed with exit code ${exitCode}`; - } +{ +name:"SIGTTOU", +number:22, +action:"pause", +description:"Background process cannot write to terminal output", +standard:"posix"}, - return 'failed'; -}; +{ +name:"SIGURG", +number:23, +action:"ignore", +description:"Socket received out-of-band data", +standard:"bsd"}, -const makeError = ({ - stdout, - stderr, - all, - error, - signal, - exitCode, - command, - escapedCommand, - timedOut, - isCanceled, - killed, - parsed: {options: {timeout}} -}) => { - // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`. - // We normalize them to `undefined` - exitCode = exitCode === null ? undefined : exitCode; - signal = signal === null ? undefined : signal; - const signalDescription = signal === undefined ? undefined : signalsByName[signal].description; +{ +name:"SIGXCPU", +number:24, +action:"core", +description:"Process timed out", +standard:"bsd"}, - const errorCode = error && error.code; +{ +name:"SIGXFSZ", +number:25, +action:"core", +description:"File too big", +standard:"bsd"}, - const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}); - const execaMessage = `Command ${prefix}: ${command}`; - const isError = Object.prototype.toString.call(error) === '[object Error]'; - const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; - const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n'); +{ +name:"SIGVTALRM", +number:26, +action:"terminate", +description:"Timeout or timer", +standard:"bsd"}, - if (isError) { - error.originalMessage = error.message; - error.message = message; - } else { - error = new Error(message); - } +{ +name:"SIGPROF", +number:27, +action:"terminate", +description:"Timeout or timer", +standard:"bsd"}, - error.shortMessage = shortMessage; - error.command = command; - error.escapedCommand = escapedCommand; - error.exitCode = exitCode; - error.signal = signal; - error.signalDescription = signalDescription; - error.stdout = stdout; - error.stderr = stderr; +{ +name:"SIGWINCH", +number:28, +action:"ignore", +description:"Terminal window size changed", +standard:"bsd"}, - if (all !== undefined) { - error.all = all; - } +{ +name:"SIGIO", +number:29, +action:"terminate", +description:"I/O is available", +standard:"other"}, - if ('bufferedData' in error) { - delete error.bufferedData; - } +{ +name:"SIGPOLL", +number:29, +action:"terminate", +description:"Watched event", +standard:"other"}, - error.failed = true; - error.timedOut = Boolean(timedOut); - error.isCanceled = isCanceled; - error.killed = killed && !timedOut; +{ +name:"SIGINFO", +number:29, +action:"ignore", +description:"Request for process information", +standard:"other"}, - return error; -}; +{ +name:"SIGPWR", +number:30, +action:"terminate", +description:"Device running out of power", +standard:"systemv"}, -module.exports = makeError; +{ +name:"SIGSYS", +number:31, +action:"core", +description:"Invalid system call", +standard:"other"}, +{ +name:"SIGUNUSED", +number:31, +action:"terminate", +description:"Invalid system call", +standard:"other"}];exports.SIGNALS=SIGNALS; +//# sourceMappingURL=core.js.map /***/ }), -/***/ 1509: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 2323: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.signalsByNumber=exports.signalsByName=void 0;var _os=__nccwpck_require__(2087); -const os = __nccwpck_require__(2087); -const onExit = __nccwpck_require__(4931); +var _signals=__nccwpck_require__(5537); +var _realtime=__nccwpck_require__(7250); -const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; -// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior -const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => { - const killResult = kill(signal); - setKillTimeout(kill, signal, options, killResult); - return killResult; -}; -const setKillTimeout = (kill, signal, options, killResult) => { - if (!shouldForceKill(signal, options, killResult)) { - return; - } +const getSignalsByName=function(){ +const signals=(0,_signals.getSignals)(); +return signals.reduce(getSignalByName,{}); +}; - const timeout = getForceKillAfterTimeout(options); - const t = setTimeout(() => { - kill('SIGKILL'); - }, timeout); +const getSignalByName=function( +signalByNameMemo, +{name,number,description,supported,action,forced,standard}) +{ +return{ +...signalByNameMemo, +[name]:{name,number,description,supported,action,forced,standard}}; - // Guarded because there's no `.unref()` when `execa` is used in the renderer - // process in Electron. This cannot be tested since we don't run tests in - // Electron. - // istanbul ignore else - if (t.unref) { - t.unref(); - } }; -const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => { - return isSigterm(signal) && forceKillAfterTimeout !== false && killResult; -}; +const signalsByName=getSignalsByName();exports.signalsByName=signalsByName; -const isSigterm = signal => { - return signal === os.constants.signals.SIGTERM || - (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM'); -}; -const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { - if (forceKillAfterTimeout === true) { - return DEFAULT_FORCE_KILL_TIMEOUT; - } - if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { - throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`); - } - return forceKillAfterTimeout; +const getSignalsByNumber=function(){ +const signals=(0,_signals.getSignals)(); +const length=_realtime.SIGRTMAX+1; +const signalsA=Array.from({length},(value,number)=> +getSignalByNumber(number,signals)); + +return Object.assign({},...signalsA); }; -// `childProcess.cancel()` -const spawnedCancel = (spawned, context) => { - const killResult = spawned.kill(); +const getSignalByNumber=function(number,signals){ +const signal=findSignalByNumber(number,signals); + +if(signal===undefined){ +return{}; +} + +const{name,description,supported,action,forced,standard}=signal; +return{ +[number]:{ +name, +number, +description, +supported, +action, +forced, +standard}}; - if (killResult) { - context.isCanceled = true; - } -}; -const timeoutKill = (spawned, signal, reject) => { - spawned.kill(signal); - reject(Object.assign(new Error('Timed out'), {timedOut: true, signal})); }; -// `timeout` option handling -const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => { - if (timeout === 0 || timeout === undefined) { - return spawnedPromise; - } - let timeoutId; - const timeoutPromise = new Promise((resolve, reject) => { - timeoutId = setTimeout(() => { - timeoutKill(spawned, killSignal, reject); - }, timeout); - }); - const safeSpawnedPromise = spawnedPromise.finally(() => { - clearTimeout(timeoutId); - }); +const findSignalByNumber=function(number,signals){ +const signal=signals.find(({name})=>_os.constants.signals[name]===number); - return Promise.race([timeoutPromise, safeSpawnedPromise]); -}; +if(signal!==undefined){ +return signal; +} -const validateTimeout = ({timeout}) => { - if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) { - throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); - } +return signals.find(signalA=>signalA.number===number); }; -// `cleanup` option handling -const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { - if (!cleanup || detached) { - return timedPromise; - } +const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber; +//# sourceMappingURL=main.js.map - const removeExitHandler = onExit(() => { - spawned.kill(); - }); +/***/ }), - return timedPromise.finally(() => { - removeExitHandler(); - }); -}; +/***/ 7250: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGRTMAX=exports.getRealtimeSignals=void 0; +const getRealtimeSignals=function(){ +const length=SIGRTMAX-SIGRTMIN+1; +return Array.from({length},getRealtimeSignal); +};exports.getRealtimeSignals=getRealtimeSignals; + +const getRealtimeSignal=function(value,index){ +return{ +name:`SIGRT${index+1}`, +number:SIGRTMIN+index, +action:"terminate", +description:"Application-specific signal (realtime)", +standard:"posix"}; -module.exports = { - spawnedKill, - spawnedCancel, - setupTimeout, - validateTimeout, - setExitHandler }; +const SIGRTMIN=34; +const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; +//# sourceMappingURL=realtime.js.map /***/ }), -/***/ 4856: -/***/ ((module) => { +/***/ 5537: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.getSignals=void 0;var _os=__nccwpck_require__(2087); +var _core=__nccwpck_require__(9127); +var _realtime=__nccwpck_require__(7250); -const nativePromisePrototype = (async () => {})().constructor.prototype; -const descriptors = ['then', 'catch', 'finally'].map(property => [ - property, - Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property) -]); -// The return value is a mixin of `childProcess` and `Promise` -const mergePromise = (spawned, promise) => { - for (const [property, descriptor] of descriptors) { - // Starting the main `promise` is deferred to avoid consuming streams - const value = typeof promise === 'function' ? - (...args) => Reflect.apply(descriptor.value, promise(), args) : - descriptor.value.bind(promise); - Reflect.defineProperty(spawned, property, {...descriptor, value}); - } +const getSignals=function(){ +const realtimeSignals=(0,_realtime.getRealtimeSignals)(); +const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal); +return signals; +};exports.getSignals=getSignals; - return spawned; -}; -// Use promises instead of `child_process` events -const getSpawnedPromise = spawned => { - return new Promise((resolve, reject) => { - spawned.on('exit', (exitCode, signal) => { - resolve({exitCode, signal}); - }); - spawned.on('error', error => { - reject(error); - }); - if (spawned.stdin) { - spawned.stdin.on('error', error => { - reject(error); - }); - } - }); -}; -module.exports = { - mergePromise, - getSpawnedPromise + + +const normalizeSignal=function({ +name, +number:defaultNumber, +description, +action, +forced=false, +standard}) +{ +const{ +signals:{[name]:constantSignal}}= +_os.constants; +const supported=constantSignal!==undefined; +const number=supported?constantSignal:defaultNumber; +return{name,number,description,supported,action,forced,standard}; }; - - +//# sourceMappingURL=signals.js.map /***/ }), -/***/ 3390: +/***/ 9417: /***/ ((module) => { "use strict"; -const aliases = ['stdin', 'stdout', 'stderr']; - -const hasAlias = options => aliases.some(alias => options[alias] !== undefined); - -const normalizeStdio = options => { - if (!options) { - return; - } - - const {stdio} = options; - - if (stdio === undefined) { - return aliases.map(alias => options[alias]); - } +module.exports = balanced; +function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); - if (hasAlias(options)) { - throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`); - } + var r = range(a, b, str); - if (typeof stdio === 'string') { - return stdio; - } + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; +} - if (!Array.isArray(stdio)) { - throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``); - } +function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; +} - const length = Math.max(stdio.length, aliases.length); - return Array.from({length}, (value, index) => stdio[index]); -}; +balanced.range = range; +function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; -module.exports = normalizeStdio; + if (ai >= 0 && bi > 0) { + if(a===b) { + return [ai, bi]; + } + begs = []; + left = str.length; -// `ipc` is pushed unless it is already present -module.exports.node = options => { - const stdio = normalizeStdio(options); + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [ begs.pop(), bi ]; + } else { + beg = begs.pop(); + if (beg < left) { + left = beg; + right = bi; + } - if (stdio === 'ipc') { - return 'ipc'; - } + bi = str.indexOf(b, i + 1); + } - if (stdio === undefined || typeof stdio === 'string') { - return [stdio, stdio, stdio, 'ipc']; - } + i = ai < bi && ai >= 0 ? ai : bi; + } - if (stdio.includes('ipc')) { - return stdio; - } + if (begs.length) { + result = [ left, right ]; + } + } - return [...stdio, 'ipc']; -}; + return result; +} /***/ }), -/***/ 7788: +/***/ 3717: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +var concatMap = __nccwpck_require__(6891); +var balanced = __nccwpck_require__(9417); -const isStream = __nccwpck_require__(1554); -const getStream = __nccwpck_require__(7816); -const mergeStream = __nccwpck_require__(2621); +module.exports = expandTop; -// `input` option -const handleInput = (spawned, input) => { - // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 - // @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 - if (input === undefined || spawned.stdin === undefined) { - return; - } +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; - if (isStream(input)) { - input.pipe(spawned.stdin); - } else { - spawned.stdin.end(input); - } -}; +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); +} -// `all` interleaves `stdout` and `stderr` -const makeAllStream = (spawned, {all}) => { - if (!all || (!spawned.stdout && !spawned.stderr)) { - return; - } +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} - const mixed = mergeStream(); +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} - if (spawned.stdout) { - mixed.add(spawned.stdout); - } - if (spawned.stderr) { - mixed.add(spawned.stderr); - } +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; - return mixed; -}; + var parts = []; + var m = balanced('{', '}', str); -// On failure, `result.stdout|stderr|all` should contain the currently buffered stream -const getBufferedData = async (stream, streamPromise) => { - if (!stream) { - return; - } + if (!m) + return str.split(','); - stream.destroy(); + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); - try { - return await streamPromise; - } catch (error) { - return error.bufferedData; - } -}; + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } -const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => { - if (!stream || !buffer) { - return; - } + parts.push.apply(parts, p); - if (encoding) { - return getStream(stream, {encoding, maxBuffer}); - } + return parts; +} - return getStream.buffer(stream, {maxBuffer}); -}; +function expandTop(str) { + if (!str) + return []; -// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all) -const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => { - const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer}); - const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer}); - const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2}); + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); + } - try { - return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]); - } catch (error) { - return Promise.all([ - {error, signal: error.signal, timedOut: error.timedOut}, - getBufferedData(stdout, stdoutPromise), - getBufferedData(stderr, stderrPromise), - getBufferedData(all, allPromise) - ]); - } -}; + return expand(escapeBraces(str), true).map(unescapeBraces); +} -const validateInputSync = ({input}) => { - if (isStream(input)) { - throw new TypeError('The `input` option cannot be a stream in sync mode'); - } -}; +function identity(e) { + return e; +} -module.exports = { - handleInput, - makeAllStream, - getSpawnedResult, - validateInputSync -}; +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} +function expand(str, isTop) { + var expansions = []; -/***/ }), + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; -/***/ 6579: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } -"use strict"; + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } -const {PassThrough: PassThroughStream} = __nccwpck_require__(2413); + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. -module.exports = options => { - options = {...options}; + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; - const {array} = options; - let {encoding} = options; - const isBuffer = encoding === 'buffer'; - let objectMode = false; + var N; - if (array) { - objectMode = !(encoding || isBuffer); - } else { - encoding = encoding || 'utf8'; - } + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); - if (isBuffer) { - encoding = null; - } + N = []; - const stream = new PassThroughStream({objectMode}); + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el, false) }); + } - if (encoding) { - stream.setEncoding(encoding); - } + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } - let length = 0; - const chunks = []; + return expansions; +} - stream.on('data', chunk => { - chunks.push(chunk); - if (objectMode) { - length = chunks.length; - } else { - length += chunk.length; - } - }); - stream.getBufferedValue = () => { - if (array) { - return chunks; - } +/***/ }), - return isBuffer ? Buffer.concat(chunks, length) : chunks.join(''); - }; +/***/ 6891: +/***/ ((module) => { - stream.getBufferedLength = () => length; +module.exports = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; +}; - return stream; +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; }; /***/ }), -/***/ 7816: +/***/ 7881: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -const {constants: BufferConstants} = __nccwpck_require__(4293); -const stream = __nccwpck_require__(2413); -const {promisify} = __nccwpck_require__(1669); -const bufferStream = __nccwpck_require__(6579); - -const streamPipelinePromisified = promisify(stream.pipeline); - -class MaxBufferError extends Error { - constructor() { - super('maxBuffer exceeded'); - this.name = 'MaxBufferError'; - } -} - -async function getStream(inputStream, options) { - if (!inputStream) { - throw new Error('Expected a stream'); - } - - options = { - maxBuffer: Infinity, - ...options - }; - - const {maxBuffer} = options; - const stream = bufferStream(options); - await new Promise((resolve, reject) => { - const rejectPromise = error => { - // Don't retrieve an oversized buffer. - if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) { - error.bufferedData = stream.getBufferedValue(); - } +const cp = __nccwpck_require__(3129); +const parse = __nccwpck_require__(6855); +const enoent = __nccwpck_require__(4101); - reject(error); - }; +function spawn(command, args, options) { + // Parse the arguments + const parsed = parse(command, args, options); - (async () => { - try { - await streamPipelinePromisified(inputStream, stream); - resolve(); - } catch (error) { - rejectPromise(error); - } - })(); + // Spawn the child process + const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); - stream.on('data', () => { - if (stream.getBufferedLength() > maxBuffer) { - rejectPromise(new MaxBufferError()); - } - }); - }); + // Hook into child process "exit" event to emit an error if the command + // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 + enoent.hookChildProcess(spawned, parsed); - return stream.getBufferedValue(); + return spawned; } -module.exports = getStream; -module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'}); -module.exports.array = (stream, options) => getStream(stream, {...options, array: true}); -module.exports.MaxBufferError = MaxBufferError; - - -/***/ }), - -/***/ 9127: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGNALS=void 0; +function spawnSync(command, args, options) { + // Parse the arguments + const parsed = parse(command, args, options); -const SIGNALS=[ -{ -name:"SIGHUP", -number:1, -action:"terminate", -description:"Terminal closed", -standard:"posix"}, + // Spawn the child process + const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); -{ -name:"SIGINT", -number:2, -action:"terminate", -description:"User interruption with CTRL-C", -standard:"ansi"}, + // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 + result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); -{ -name:"SIGQUIT", -number:3, -action:"core", -description:"User interruption with CTRL-\\", -standard:"posix"}, + return result; +} -{ -name:"SIGILL", -number:4, -action:"core", -description:"Invalid machine instruction", -standard:"ansi"}, +module.exports = spawn; +module.exports.spawn = spawn; +module.exports.sync = spawnSync; -{ -name:"SIGTRAP", -number:5, -action:"core", -description:"Debugger breakpoint", -standard:"posix"}, +module.exports._parse = parse; +module.exports._enoent = enoent; -{ -name:"SIGABRT", -number:6, -action:"core", -description:"Aborted", -standard:"ansi"}, -{ -name:"SIGIOT", -number:6, -action:"core", -description:"Aborted", -standard:"bsd"}, +/***/ }), -{ -name:"SIGBUS", -number:7, -action:"core", -description: -"Bus error due to misaligned, non-existing address or paging error", -standard:"bsd"}, +/***/ 4101: +/***/ ((module) => { -{ -name:"SIGEMT", -number:7, -action:"terminate", -description:"Command should be emulated but is not implemented", -standard:"other"}, +"use strict"; -{ -name:"SIGFPE", -number:8, -action:"core", -description:"Floating point arithmetic error", -standard:"ansi"}, -{ -name:"SIGKILL", -number:9, -action:"terminate", -description:"Forced termination", -standard:"posix", -forced:true}, +const isWin = process.platform === 'win32'; -{ -name:"SIGUSR1", -number:10, -action:"terminate", -description:"Application-specific signal", -standard:"posix"}, +function notFoundError(original, syscall) { + return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { + code: 'ENOENT', + errno: 'ENOENT', + syscall: `${syscall} ${original.command}`, + path: original.command, + spawnargs: original.args, + }); +} -{ -name:"SIGSEGV", -number:11, -action:"core", -description:"Segmentation fault", -standard:"ansi"}, +function hookChildProcess(cp, parsed) { + if (!isWin) { + return; + } -{ -name:"SIGUSR2", -number:12, -action:"terminate", -description:"Application-specific signal", -standard:"posix"}, + const originalEmit = cp.emit; -{ -name:"SIGPIPE", -number:13, -action:"terminate", -description:"Broken pipe or socket", -standard:"posix"}, + cp.emit = function (name, arg1) { + // If emitting "exit" event and exit code is 1, we need to check if + // the command exists and emit an "error" instead + // See https://github.com/IndigoUnited/node-cross-spawn/issues/16 + if (name === 'exit') { + const err = verifyENOENT(arg1, parsed, 'spawn'); -{ -name:"SIGALRM", -number:14, -action:"terminate", -description:"Timeout or timer", -standard:"posix"}, + if (err) { + return originalEmit.call(cp, 'error', err); + } + } -{ -name:"SIGTERM", -number:15, -action:"terminate", -description:"Termination", -standard:"ansi"}, + return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params + }; +} -{ -name:"SIGSTKFLT", -number:16, -action:"terminate", -description:"Stack is empty or overflowed", -standard:"other"}, +function verifyENOENT(status, parsed) { + if (isWin && status === 1 && !parsed.file) { + return notFoundError(parsed.original, 'spawn'); + } -{ -name:"SIGCHLD", -number:17, -action:"ignore", -description:"Child process terminated, paused or unpaused", -standard:"posix"}, + return null; +} -{ -name:"SIGCLD", -number:17, -action:"ignore", -description:"Child process terminated, paused or unpaused", -standard:"other"}, +function verifyENOENTSync(status, parsed) { + if (isWin && status === 1 && !parsed.file) { + return notFoundError(parsed.original, 'spawnSync'); + } -{ -name:"SIGCONT", -number:18, -action:"unpause", -description:"Unpaused", -standard:"posix", -forced:true}, + return null; +} -{ -name:"SIGSTOP", -number:19, -action:"pause", -description:"Paused", -standard:"posix", -forced:true}, +module.exports = { + hookChildProcess, + verifyENOENT, + verifyENOENTSync, + notFoundError, +}; -{ -name:"SIGTSTP", -number:20, -action:"pause", -description:"Paused using CTRL-Z or \"suspend\"", -standard:"posix"}, -{ -name:"SIGTTIN", -number:21, -action:"pause", -description:"Background process cannot read terminal input", -standard:"posix"}, +/***/ }), -{ -name:"SIGBREAK", -number:21, -action:"terminate", -description:"User interruption with CTRL-BREAK", -standard:"other"}, +/***/ 6855: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -{ -name:"SIGTTOU", -number:22, -action:"pause", -description:"Background process cannot write to terminal output", -standard:"posix"}, +"use strict"; -{ -name:"SIGURG", -number:23, -action:"ignore", -description:"Socket received out-of-band data", -standard:"bsd"}, -{ -name:"SIGXCPU", -number:24, -action:"core", -description:"Process timed out", -standard:"bsd"}, +const path = __nccwpck_require__(5622); +const resolveCommand = __nccwpck_require__(7274); +const escape = __nccwpck_require__(4274); +const readShebang = __nccwpck_require__(1252); -{ -name:"SIGXFSZ", -number:25, -action:"core", -description:"File too big", -standard:"bsd"}, +const isWin = process.platform === 'win32'; +const isExecutableRegExp = /\.(?:com|exe)$/i; +const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; -{ -name:"SIGVTALRM", -number:26, -action:"terminate", -description:"Timeout or timer", -standard:"bsd"}, +function detectShebang(parsed) { + parsed.file = resolveCommand(parsed); -{ -name:"SIGPROF", -number:27, -action:"terminate", -description:"Timeout or timer", -standard:"bsd"}, + const shebang = parsed.file && readShebang(parsed.file); -{ -name:"SIGWINCH", -number:28, -action:"ignore", -description:"Terminal window size changed", -standard:"bsd"}, + if (shebang) { + parsed.args.unshift(parsed.file); + parsed.command = shebang; -{ -name:"SIGIO", -number:29, -action:"terminate", -description:"I/O is available", -standard:"other"}, + return resolveCommand(parsed); + } -{ -name:"SIGPOLL", -number:29, -action:"terminate", -description:"Watched event", -standard:"other"}, + return parsed.file; +} -{ -name:"SIGINFO", -number:29, -action:"ignore", -description:"Request for process information", -standard:"other"}, +function parseNonShell(parsed) { + if (!isWin) { + return parsed; + } -{ -name:"SIGPWR", -number:30, -action:"terminate", -description:"Device running out of power", -standard:"systemv"}, + // Detect & add support for shebangs + const commandFile = detectShebang(parsed); -{ -name:"SIGSYS", -number:31, -action:"core", -description:"Invalid system call", -standard:"other"}, + // We don't need a shell if the command filename is an executable + const needsShell = !isExecutableRegExp.test(commandFile); -{ -name:"SIGUNUSED", -number:31, -action:"terminate", -description:"Invalid system call", -standard:"other"}];exports.SIGNALS=SIGNALS; -//# sourceMappingURL=core.js.map + // If a shell is required, use cmd.exe and take care of escaping everything correctly + // Note that `forceShell` is an hidden option used only in tests + if (parsed.options.forceShell || needsShell) { + // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/` + // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument + // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called, + // we need to double escape them + const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); -/***/ }), + // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar) + // This is necessary otherwise it will always fail with ENOENT in those cases + parsed.command = path.normalize(parsed.command); -/***/ 2323: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + // Escape command & arguments + parsed.command = escape.command(parsed.command); + parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); -"use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.signalsByNumber=exports.signalsByName=void 0;var _os=__nccwpck_require__(2087); + const shellCommand = [parsed.command].concat(parsed.args).join(' '); -var _signals=__nccwpck_require__(5537); -var _realtime=__nccwpck_require__(7250); + parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`]; + parsed.command = process.env.comspec || 'cmd.exe'; + parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped + } + return parsed; +} +function parse(command, args, options) { + // Normalize arguments, similar to nodejs + if (args && !Array.isArray(args)) { + options = args; + args = null; + } -const getSignalsByName=function(){ -const signals=(0,_signals.getSignals)(); -return signals.reduce(getSignalByName,{}); -}; + args = args ? args.slice(0) : []; // Clone array to avoid changing the original + options = Object.assign({}, options); // Clone object to avoid changing the original -const getSignalByName=function( -signalByNameMemo, -{name,number,description,supported,action,forced,standard}) -{ -return{ -...signalByNameMemo, -[name]:{name,number,description,supported,action,forced,standard}}; + // Build our parsed object + const parsed = { + command, + args, + options, + file: undefined, + original: { + command, + args, + }, + }; -}; + // Delegate further parsing to shell or non-shell + return options.shell ? parsed : parseNonShell(parsed); +} -const signalsByName=getSignalsByName();exports.signalsByName=signalsByName; +module.exports = parse; +/***/ }), +/***/ 4274: +/***/ ((module) => { -const getSignalsByNumber=function(){ -const signals=(0,_signals.getSignals)(); -const length=_realtime.SIGRTMAX+1; -const signalsA=Array.from({length},(value,number)=> -getSignalByNumber(number,signals)); +"use strict"; -return Object.assign({},...signalsA); -}; -const getSignalByNumber=function(number,signals){ -const signal=findSignalByNumber(number,signals); +// See http://www.robvanderwoude.com/escapechars.php +const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; -if(signal===undefined){ -return{}; +function escapeCommand(arg) { + // Escape meta chars + arg = arg.replace(metaCharsRegExp, '^$1'); + + return arg; } -const{name,description,supported,action,forced,standard}=signal; -return{ -[number]:{ -name, -number, -description, -supported, -action, -forced, -standard}}; +function escapeArgument(arg, doubleEscapeMetaChars) { + // Convert to string + arg = `${arg}`; + // Algorithm below is based on https://qntm.org/cmd -}; + // Sequence of backslashes followed by a double quote: + // double up all the backslashes and escape the double quote + arg = arg.replace(/(\\*)"/g, '$1$1\\"'); + // Sequence of backslashes followed by the end of the string + // (which will become a double quote later): + // double up all the backslashes + arg = arg.replace(/(\\*)$/, '$1$1'); + // All other backslashes occur literally -const findSignalByNumber=function(number,signals){ -const signal=signals.find(({name})=>_os.constants.signals[name]===number); + // Quote the whole thing: + arg = `"${arg}"`; -if(signal!==undefined){ -return signal; + // Escape meta chars + arg = arg.replace(metaCharsRegExp, '^$1'); + + // Double escape meta chars if necessary + if (doubleEscapeMetaChars) { + arg = arg.replace(metaCharsRegExp, '^$1'); + } + + return arg; } -return signals.find(signalA=>signalA.number===number); -}; +module.exports.command = escapeCommand; +module.exports.argument = escapeArgument; -const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber; -//# sourceMappingURL=main.js.map /***/ }), -/***/ 7250: -/***/ ((__unused_webpack_module, exports) => { +/***/ 1252: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGRTMAX=exports.getRealtimeSignals=void 0; -const getRealtimeSignals=function(){ -const length=SIGRTMAX-SIGRTMIN+1; -return Array.from({length},getRealtimeSignal); -};exports.getRealtimeSignals=getRealtimeSignals; -const getRealtimeSignal=function(value,index){ -return{ -name:`SIGRT${index+1}`, -number:SIGRTMIN+index, -action:"terminate", -description:"Application-specific signal (realtime)", -standard:"posix"}; -}; +const fs = __nccwpck_require__(5747); +const shebangCommand = __nccwpck_require__(7032); + +function readShebang(command) { + // Read the first 150 bytes from the file + const size = 150; + const buffer = Buffer.alloc(size); + + let fd; + + try { + fd = fs.openSync(command, 'r'); + fs.readSync(fd, buffer, 0, size, 0); + fs.closeSync(fd); + } catch (e) { /* Empty */ } + + // Attempt to extract shebang (null is returned if not a shebang) + return shebangCommand(buffer.toString()); +} + +module.exports = readShebang; -const SIGRTMIN=34; -const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; -//# sourceMappingURL=realtime.js.map /***/ }), -/***/ 5537: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 7274: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.getSignals=void 0;var _os=__nccwpck_require__(2087); -var _core=__nccwpck_require__(9127); -var _realtime=__nccwpck_require__(7250); +const path = __nccwpck_require__(5622); +const which = __nccwpck_require__(4207); +const getPathKey = __nccwpck_require__(539); +function resolveCommandAttempt(parsed, withoutPathExt) { + const env = parsed.options.env || process.env; + const cwd = process.cwd(); + const hasCustomCwd = parsed.options.cwd != null; + // Worker threads do not have process.chdir() + const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled; -const getSignals=function(){ -const realtimeSignals=(0,_realtime.getRealtimeSignals)(); -const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal); -return signals; -};exports.getSignals=getSignals; + // If a custom `cwd` was specified, we need to change the process cwd + // because `which` will do stat calls but does not support a custom cwd + if (shouldSwitchCwd) { + try { + process.chdir(parsed.options.cwd); + } catch (err) { + /* Empty */ + } + } + let resolved; + try { + resolved = which.sync(parsed.command, { + path: env[getPathKey({ env })], + pathExt: withoutPathExt ? path.delimiter : undefined, + }); + } catch (e) { + /* Empty */ + } finally { + if (shouldSwitchCwd) { + process.chdir(cwd); + } + } + // If we successfully resolved, ensure that an absolute path is returned + // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it + if (resolved) { + resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved); + } + return resolved; +} +function resolveCommand(parsed) { + return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); +} +module.exports = resolveCommand; -const normalizeSignal=function({ -name, -number:defaultNumber, -description, -action, -forced=false, -standard}) -{ -const{ -signals:{[name]:constantSignal}}= -_os.constants; -const supported=constantSignal!==undefined; -const number=supported?constantSignal:defaultNumber; -return{name,number,description,supported,action,forced,standard}; -}; -//# sourceMappingURL=signals.js.map /***/ }), -/***/ 9417: -/***/ ((module) => { +/***/ 1205: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +var once = __nccwpck_require__(1223); -module.exports = balanced; -function balanced(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); +var noop = function() {}; - var r = range(a, b, str); +var isRequest = function(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +}; - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; -} +var isChildProcess = function(stream) { + return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3 +}; -function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; -} +var eos = function(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; -balanced.range = range; -function range(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; + callback = once(callback || noop); - if (ai >= 0 && bi > 0) { - if(a===b) { - return [ai, bi]; - } - begs = []; - left = str.length; + var ws = stream._writableState; + var rs = stream._readableState; + var readable = opts.readable || (opts.readable !== false && stream.readable); + var writable = opts.writable || (opts.writable !== false && stream.writable); + var cancelled = false; - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [ begs.pop(), bi ]; - } else { - beg = begs.pop(); - if (beg < left) { - left = beg; - right = bi; - } + var onlegacyfinish = function() { + if (!stream.writable) onfinish(); + }; - bi = str.indexOf(b, i + 1); - } + var onfinish = function() { + writable = false; + if (!readable) callback.call(stream); + }; - i = ai < bi && ai >= 0 ? ai : bi; - } + var onend = function() { + readable = false; + if (!writable) callback.call(stream); + }; - if (begs.length) { - result = [ left, right ]; - } - } + var onexit = function(exitCode) { + callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); + }; - return result; -} + var onerror = function(err) { + callback.call(stream, err); + }; + var onclose = function() { + process.nextTick(onclosenexttick); + }; -/***/ }), + var onclosenexttick = function() { + if (cancelled) return; + if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close')); + if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close')); + }; -/***/ 3717: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + var onrequest = function() { + stream.req.on('finish', onfinish); + }; -var concatMap = __nccwpck_require__(6891); -var balanced = __nccwpck_require__(9417); + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest(); + else stream.on('request', onrequest); + } else if (writable && !ws) { // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } -module.exports = expandTop; + if (isChildProcess(stream)) stream.on('exit', onexit); -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} + return function() { + cancelled = true; + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('exit', onexit); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +}; -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} +module.exports = eos; -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} +/***/ }), -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; +/***/ 5447: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - var parts = []; - var m = balanced('{', '}', str); +"use strict"; - if (!m) - return str.split(','); +const path = __nccwpck_require__(5622); +const childProcess = __nccwpck_require__(3129); +const crossSpawn = __nccwpck_require__(7881); +const stripFinalNewline = __nccwpck_require__(8174); +const npmRunPath = __nccwpck_require__(502); +const onetime = __nccwpck_require__(9082); +const makeError = __nccwpck_require__(2187); +const normalizeStdio = __nccwpck_require__(166); +const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = __nccwpck_require__(9819); +const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __nccwpck_require__(2592); +const {mergePromise, getSpawnedPromise} = __nccwpck_require__(7814); +const {joinCommand, parseCommand} = __nccwpck_require__(8286); - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); +const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } +const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => { + const env = extendEnv ? {...process.env, ...envOption} : envOption; - parts.push.apply(parts, p); + if (preferLocal) { + return npmRunPath.env({env, cwd: localDir, execPath}); + } - return parts; -} + return env; +}; -function expandTop(str) { - if (!str) - return []; +const handleArguments = (file, args, options = {}) => { + const parsed = crossSpawn._parse(file, args, options); + file = parsed.command; + args = parsed.args; + options = parsed.options; - // I don't know why Bash 4.3 does this, but it does. - // Anything starting with {} will have the first two bytes preserved - // but *only* at the top level, so {},a}b will not expand to anything, - // but a{},b}c will be expanded to [a}c,abc]. - // One could argue that this is a bug in Bash, but since the goal of - // this module is to match Bash's rules, we escape a leading {} - if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); - } + options = { + maxBuffer: DEFAULT_MAX_BUFFER, + buffer: true, + stripFinalNewline: true, + extendEnv: true, + preferLocal: false, + localDir: options.cwd || process.cwd(), + execPath: process.execPath, + encoding: 'utf8', + reject: true, + cleanup: true, + all: false, + windowsHide: true, + ...options + }; - return expand(escapeBraces(str), true).map(unescapeBraces); -} + options.env = getEnv(options); -function identity(e) { - return e; -} + options.stdio = normalizeStdio(options); -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} + if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') { + // #116 + args.unshift('/q'); + } -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} + return {file, args, options, parsed}; +}; -function expand(str, isTop) { - var expansions = []; +const handleOutput = (options, value, error) => { + if (typeof value !== 'string' && !Buffer.isBuffer(value)) { + // When `execa.sync()` errors, we normalize it to '' to mimic `execa()` + return error === undefined ? undefined : ''; + } - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; + if (options.stripFinalNewline) { + return stripFinalNewline(value); + } - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } + return value; +}; - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } +const execa = (file, args, options) => { + const parsed = handleArguments(file, args, options); + const command = joinCommand(file, args); - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. + let spawned; + try { + spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options); + } catch (error) { + // Ensure the returned error is always both a promise and a child process + const dummySpawned = new childProcess.ChildProcess(); + const errorPromise = Promise.reject(makeError({ + error, + stdout: '', + stderr: '', + all: '', + command, + parsed, + timedOut: false, + isCanceled: false, + killed: false + })); + return mergePromise(dummySpawned, errorPromise); + } - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; + const spawnedPromise = getSpawnedPromise(spawned); + const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise); + const processDone = setExitHandler(spawned, parsed.options, timedPromise); - var N; + const context = {isCanceled: false}; - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); + spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned)); + spawned.cancel = spawnedCancel.bind(null, spawned, context); - N = []; + const handlePromise = async () => { + const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone); + const stdout = handleOutput(parsed.options, stdoutResult); + const stderr = handleOutput(parsed.options, stderrResult); + const all = handleOutput(parsed.options, allResult); - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } + if (error || exitCode !== 0 || signal !== null) { + const returnedError = makeError({ + error, + exitCode, + signal, + stdout, + stderr, + all, + command, + parsed, + timedOut, + isCanceled: context.isCanceled, + killed: spawned.killed + }); - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } + if (!parsed.options.reject) { + return returnedError; + } - return expansions; -} + throw returnedError; + } + return { + command, + exitCode: 0, + stdout, + stderr, + all, + failed: false, + timedOut: false, + isCanceled: false, + killed: false + }; + }; + const handlePromiseOnce = onetime(handlePromise); -/***/ }), + crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed); -/***/ 6891: -/***/ ((module) => { + handleInput(spawned, parsed.options.input); -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; + spawned.all = makeAllStream(spawned, parsed.options); -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; + return mergePromise(spawned, handlePromiseOnce); }; +module.exports = execa; -/***/ }), - -/***/ 2746: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +module.exports.sync = (file, args, options) => { + const parsed = handleArguments(file, args, options); + const command = joinCommand(file, args); -"use strict"; + validateInputSync(parsed.options); + let result; + try { + result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options); + } catch (error) { + throw makeError({ + error, + stdout: '', + stderr: '', + all: '', + command, + parsed, + timedOut: false, + isCanceled: false, + killed: false + }); + } -const cp = __nccwpck_require__(3129); -const parse = __nccwpck_require__(6855); -const enoent = __nccwpck_require__(4101); + const stdout = handleOutput(parsed.options, result.stdout, result.error); + const stderr = handleOutput(parsed.options, result.stderr, result.error); -function spawn(command, args, options) { - // Parse the arguments - const parsed = parse(command, args, options); + if (result.error || result.status !== 0 || result.signal !== null) { + const error = makeError({ + stdout, + stderr, + error: result.error, + signal: result.signal, + exitCode: result.status, + command, + parsed, + timedOut: result.error && result.error.code === 'ETIMEDOUT', + isCanceled: false, + killed: result.signal !== null + }); - // Spawn the child process - const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); + if (!parsed.options.reject) { + return error; + } - // Hook into child process "exit" event to emit an error if the command - // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 - enoent.hookChildProcess(spawned, parsed); + throw error; + } - return spawned; -} + return { + command, + exitCode: 0, + stdout, + stderr, + failed: false, + timedOut: false, + isCanceled: false, + killed: false + }; +}; -function spawnSync(command, args, options) { - // Parse the arguments - const parsed = parse(command, args, options); +module.exports.command = (command, options) => { + const [file, ...args] = parseCommand(command); + return execa(file, args, options); +}; - // Spawn the child process - const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); +module.exports.commandSync = (command, options) => { + const [file, ...args] = parseCommand(command); + return execa.sync(file, args, options); +}; - // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 - result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); +module.exports.node = (scriptPath, args, options = {}) => { + if (args && !Array.isArray(args) && typeof args === 'object') { + options = args; + args = []; + } - return result; -} + const stdio = normalizeStdio.node(options); + const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect')); -module.exports = spawn; -module.exports.spawn = spawn; -module.exports.sync = spawnSync; + const { + nodePath = process.execPath, + nodeOptions = defaultExecArgv + } = options; -module.exports._parse = parse; -module.exports._enoent = enoent; + return execa( + nodePath, + [ + ...nodeOptions, + scriptPath, + ...(Array.isArray(args) ? args : []) + ], + { + ...options, + stdin: undefined, + stdout: undefined, + stderr: undefined, + stdio, + shell: false + } + ); +}; /***/ }), -/***/ 4101: +/***/ 8286: /***/ ((module) => { "use strict"; +const SPACES_REGEXP = / +/g; -const isWin = process.platform === 'win32'; - -function notFoundError(original, syscall) { - return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { - code: 'ENOENT', - errno: 'ENOENT', - syscall: `${syscall} ${original.command}`, - path: original.command, - spawnargs: original.args, - }); -} - -function hookChildProcess(cp, parsed) { - if (!isWin) { - return; - } - - const originalEmit = cp.emit; - - cp.emit = function (name, arg1) { - // If emitting "exit" event and exit code is 1, we need to check if - // the command exists and emit an "error" instead - // See https://github.com/IndigoUnited/node-cross-spawn/issues/16 - if (name === 'exit') { - const err = verifyENOENT(arg1, parsed, 'spawn'); - - if (err) { - return originalEmit.call(cp, 'error', err); - } - } - - return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params - }; -} - -function verifyENOENT(status, parsed) { - if (isWin && status === 1 && !parsed.file) { - return notFoundError(parsed.original, 'spawn'); - } +const joinCommand = (file, args = []) => { + if (!Array.isArray(args)) { + return file; + } - return null; -} + return [file, ...args].join(' '); +}; -function verifyENOENTSync(status, parsed) { - if (isWin && status === 1 && !parsed.file) { - return notFoundError(parsed.original, 'spawnSync'); - } +// Handle `execa.command()` +const parseCommand = command => { + const tokens = []; + for (const token of command.trim().split(SPACES_REGEXP)) { + // Allow spaces to be escaped by a backslash if not meant as a delimiter + const previousToken = tokens[tokens.length - 1]; + if (previousToken && previousToken.endsWith('\\')) { + // Merge previous token with current one + tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`; + } else { + tokens.push(token); + } + } - return null; -} + return tokens; +}; module.exports = { - hookChildProcess, - verifyENOENT, - verifyENOENTSync, - notFoundError, + joinCommand, + parseCommand }; /***/ }), -/***/ 6855: +/***/ 2187: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +const {signalsByName} = __nccwpck_require__(2779); -const path = __nccwpck_require__(5622); -const resolveCommand = __nccwpck_require__(7274); -const escape = __nccwpck_require__(4274); -const readShebang = __nccwpck_require__(1252); - -const isWin = process.platform === 'win32'; -const isExecutableRegExp = /\.(?:com|exe)$/i; -const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; - -function detectShebang(parsed) { - parsed.file = resolveCommand(parsed); - - const shebang = parsed.file && readShebang(parsed.file); - - if (shebang) { - parsed.args.unshift(parsed.file); - parsed.command = shebang; - - return resolveCommand(parsed); - } +const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { + if (timedOut) { + return `timed out after ${timeout} milliseconds`; + } - return parsed.file; -} + if (isCanceled) { + return 'was canceled'; + } -function parseNonShell(parsed) { - if (!isWin) { - return parsed; - } + if (errorCode !== undefined) { + return `failed with ${errorCode}`; + } - // Detect & add support for shebangs - const commandFile = detectShebang(parsed); + if (signal !== undefined) { + return `was killed with ${signal} (${signalDescription})`; + } - // We don't need a shell if the command filename is an executable - const needsShell = !isExecutableRegExp.test(commandFile); + if (exitCode !== undefined) { + return `failed with exit code ${exitCode}`; + } - // If a shell is required, use cmd.exe and take care of escaping everything correctly - // Note that `forceShell` is an hidden option used only in tests - if (parsed.options.forceShell || needsShell) { - // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/` - // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument - // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called, - // we need to double escape them - const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); + return 'failed'; +}; - // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar) - // This is necessary otherwise it will always fail with ENOENT in those cases - parsed.command = path.normalize(parsed.command); +const makeError = ({ + stdout, + stderr, + all, + error, + signal, + exitCode, + command, + timedOut, + isCanceled, + killed, + parsed: {options: {timeout}} +}) => { + // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`. + // We normalize them to `undefined` + exitCode = exitCode === null ? undefined : exitCode; + signal = signal === null ? undefined : signal; + const signalDescription = signal === undefined ? undefined : signalsByName[signal].description; - // Escape command & arguments - parsed.command = escape.command(parsed.command); - parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); + const errorCode = error && error.code; - const shellCommand = [parsed.command].concat(parsed.args).join(' '); + const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}); + const execaMessage = `Command ${prefix}: ${command}`; + const isError = Object.prototype.toString.call(error) === '[object Error]'; + const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; + const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n'); - parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`]; - parsed.command = process.env.comspec || 'cmd.exe'; - parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped - } + if (isError) { + error.originalMessage = error.message; + error.message = message; + } else { + error = new Error(message); + } - return parsed; -} + error.shortMessage = shortMessage; + error.command = command; + error.exitCode = exitCode; + error.signal = signal; + error.signalDescription = signalDescription; + error.stdout = stdout; + error.stderr = stderr; -function parse(command, args, options) { - // Normalize arguments, similar to nodejs - if (args && !Array.isArray(args)) { - options = args; - args = null; - } + if (all !== undefined) { + error.all = all; + } - args = args ? args.slice(0) : []; // Clone array to avoid changing the original - options = Object.assign({}, options); // Clone object to avoid changing the original + if ('bufferedData' in error) { + delete error.bufferedData; + } - // Build our parsed object - const parsed = { - command, - args, - options, - file: undefined, - original: { - command, - args, - }, - }; + error.failed = true; + error.timedOut = Boolean(timedOut); + error.isCanceled = isCanceled; + error.killed = killed && !timedOut; - // Delegate further parsing to shell or non-shell - return options.shell ? parsed : parseNonShell(parsed); -} + return error; +}; -module.exports = parse; +module.exports = makeError; /***/ }), -/***/ 4274: -/***/ ((module) => { +/***/ 9819: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +const os = __nccwpck_require__(2087); +const onExit = __nccwpck_require__(4931); -// See http://www.robvanderwoude.com/escapechars.php -const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; - -function escapeCommand(arg) { - // Escape meta chars - arg = arg.replace(metaCharsRegExp, '^$1'); - - return arg; -} +const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; -function escapeArgument(arg, doubleEscapeMetaChars) { - // Convert to string - arg = `${arg}`; +// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior +const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => { + const killResult = kill(signal); + setKillTimeout(kill, signal, options, killResult); + return killResult; +}; - // Algorithm below is based on https://qntm.org/cmd +const setKillTimeout = (kill, signal, options, killResult) => { + if (!shouldForceKill(signal, options, killResult)) { + return; + } - // Sequence of backslashes followed by a double quote: - // double up all the backslashes and escape the double quote - arg = arg.replace(/(\\*)"/g, '$1$1\\"'); + const timeout = getForceKillAfterTimeout(options); + const t = setTimeout(() => { + kill('SIGKILL'); + }, timeout); - // Sequence of backslashes followed by the end of the string - // (which will become a double quote later): - // double up all the backslashes - arg = arg.replace(/(\\*)$/, '$1$1'); + // Guarded because there's no `.unref()` when `execa` is used in the renderer + // process in Electron. This cannot be tested since we don't run tests in + // Electron. + // istanbul ignore else + if (t.unref) { + t.unref(); + } +}; - // All other backslashes occur literally +const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => { + return isSigterm(signal) && forceKillAfterTimeout !== false && killResult; +}; - // Quote the whole thing: - arg = `"${arg}"`; +const isSigterm = signal => { + return signal === os.constants.signals.SIGTERM || + (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM'); +}; - // Escape meta chars - arg = arg.replace(metaCharsRegExp, '^$1'); +const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { + if (forceKillAfterTimeout === true) { + return DEFAULT_FORCE_KILL_TIMEOUT; + } - // Double escape meta chars if necessary - if (doubleEscapeMetaChars) { - arg = arg.replace(metaCharsRegExp, '^$1'); - } + if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { + throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`); + } - return arg; -} + return forceKillAfterTimeout; +}; -module.exports.command = escapeCommand; -module.exports.argument = escapeArgument; +// `childProcess.cancel()` +const spawnedCancel = (spawned, context) => { + const killResult = spawned.kill(); + if (killResult) { + context.isCanceled = true; + } +}; -/***/ }), +const timeoutKill = (spawned, signal, reject) => { + spawned.kill(signal); + reject(Object.assign(new Error('Timed out'), {timedOut: true, signal})); +}; -/***/ 1252: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// `timeout` option handling +const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => { + if (timeout === 0 || timeout === undefined) { + return spawnedPromise; + } -"use strict"; + if (!Number.isFinite(timeout) || timeout < 0) { + throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); + } + let timeoutId; + const timeoutPromise = new Promise((resolve, reject) => { + timeoutId = setTimeout(() => { + timeoutKill(spawned, killSignal, reject); + }, timeout); + }); -const fs = __nccwpck_require__(5747); -const shebangCommand = __nccwpck_require__(7032); + const safeSpawnedPromise = spawnedPromise.finally(() => { + clearTimeout(timeoutId); + }); -function readShebang(command) { - // Read the first 150 bytes from the file - const size = 150; - const buffer = Buffer.alloc(size); + return Promise.race([timeoutPromise, safeSpawnedPromise]); +}; - let fd; +// `cleanup` option handling +const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { + if (!cleanup || detached) { + return timedPromise; + } - try { - fd = fs.openSync(command, 'r'); - fs.readSync(fd, buffer, 0, size, 0); - fs.closeSync(fd); - } catch (e) { /* Empty */ } + const removeExitHandler = onExit(() => { + spawned.kill(); + }); - // Attempt to extract shebang (null is returned if not a shebang) - return shebangCommand(buffer.toString()); -} + return timedPromise.finally(() => { + removeExitHandler(); + }); +}; -module.exports = readShebang; +module.exports = { + spawnedKill, + spawnedCancel, + setupTimeout, + setExitHandler +}; /***/ }), -/***/ 7274: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 7814: +/***/ ((module) => { "use strict"; -const path = __nccwpck_require__(5622); -const which = __nccwpck_require__(4207); -const getPathKey = __nccwpck_require__(539); - -function resolveCommandAttempt(parsed, withoutPathExt) { - const env = parsed.options.env || process.env; - const cwd = process.cwd(); - const hasCustomCwd = parsed.options.cwd != null; - // Worker threads do not have process.chdir() - const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled; - - // If a custom `cwd` was specified, we need to change the process cwd - // because `which` will do stat calls but does not support a custom cwd - if (shouldSwitchCwd) { - try { - process.chdir(parsed.options.cwd); - } catch (err) { - /* Empty */ - } - } - - let resolved; +const nativePromisePrototype = (async () => {})().constructor.prototype; +const descriptors = ['then', 'catch', 'finally'].map(property => [ + property, + Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property) +]); - try { - resolved = which.sync(parsed.command, { - path: env[getPathKey({ env })], - pathExt: withoutPathExt ? path.delimiter : undefined, - }); - } catch (e) { - /* Empty */ - } finally { - if (shouldSwitchCwd) { - process.chdir(cwd); - } - } +// The return value is a mixin of `childProcess` and `Promise` +const mergePromise = (spawned, promise) => { + for (const [property, descriptor] of descriptors) { + // Starting the main `promise` is deferred to avoid consuming streams + const value = typeof promise === 'function' ? + (...args) => Reflect.apply(descriptor.value, promise(), args) : + descriptor.value.bind(promise); - // If we successfully resolved, ensure that an absolute path is returned - // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it - if (resolved) { - resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved); - } + Reflect.defineProperty(spawned, property, {...descriptor, value}); + } - return resolved; -} + return spawned; +}; -function resolveCommand(parsed) { - return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); -} +// Use promises instead of `child_process` events +const getSpawnedPromise = spawned => { + return new Promise((resolve, reject) => { + spawned.on('exit', (exitCode, signal) => { + resolve({exitCode, signal}); + }); -module.exports = resolveCommand; + spawned.on('error', error => { + reject(error); + }); + if (spawned.stdin) { + spawned.stdin.on('error', error => { + reject(error); + }); + } + }); +}; -/***/ }), +module.exports = { + mergePromise, + getSpawnedPromise +}; -/***/ 1205: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var once = __nccwpck_require__(1223); -var noop = function() {}; +/***/ }), -var isRequest = function(stream) { - return stream.setHeader && typeof stream.abort === 'function'; -}; +/***/ 166: +/***/ ((module) => { -var isChildProcess = function(stream) { - return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3 -}; +"use strict"; -var eos = function(stream, opts, callback) { - if (typeof opts === 'function') return eos(stream, null, opts); - if (!opts) opts = {}; +const aliases = ['stdin', 'stdout', 'stderr']; - callback = once(callback || noop); +const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined); - var ws = stream._writableState; - var rs = stream._readableState; - var readable = opts.readable || (opts.readable !== false && stream.readable); - var writable = opts.writable || (opts.writable !== false && stream.writable); - var cancelled = false; +const normalizeStdio = opts => { + if (!opts) { + return; + } - var onlegacyfinish = function() { - if (!stream.writable) onfinish(); - }; + const {stdio} = opts; - var onfinish = function() { - writable = false; - if (!readable) callback.call(stream); - }; + if (stdio === undefined) { + return aliases.map(alias => opts[alias]); + } - var onend = function() { - readable = false; - if (!writable) callback.call(stream); - }; + if (hasAlias(opts)) { + throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`); + } - var onexit = function(exitCode) { - callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); - }; + if (typeof stdio === 'string') { + return stdio; + } - var onerror = function(err) { - callback.call(stream, err); - }; + if (!Array.isArray(stdio)) { + throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``); + } - var onclose = function() { - process.nextTick(onclosenexttick); - }; + const length = Math.max(stdio.length, aliases.length); + return Array.from({length}, (value, index) => stdio[index]); +}; - var onclosenexttick = function() { - if (cancelled) return; - if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close')); - if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close')); - }; +module.exports = normalizeStdio; - var onrequest = function() { - stream.req.on('finish', onfinish); - }; +// `ipc` is pushed unless it is already present +module.exports.node = opts => { + const stdio = normalizeStdio(opts); - if (isRequest(stream)) { - stream.on('complete', onfinish); - stream.on('abort', onclose); - if (stream.req) onrequest(); - else stream.on('request', onrequest); - } else if (writable && !ws) { // legacy streams - stream.on('end', onlegacyfinish); - stream.on('close', onlegacyfinish); + if (stdio === 'ipc') { + return 'ipc'; } - if (isChildProcess(stream)) stream.on('exit', onexit); + if (stdio === undefined || typeof stdio === 'string') { + return [stdio, stdio, stdio, 'ipc']; + } - stream.on('end', onend); - stream.on('finish', onfinish); - if (opts.error !== false) stream.on('error', onerror); - stream.on('close', onclose); + if (stdio.includes('ipc')) { + return stdio; + } - return function() { - cancelled = true; - stream.removeListener('complete', onfinish); - stream.removeListener('abort', onclose); - stream.removeListener('request', onrequest); - if (stream.req) stream.req.removeListener('finish', onfinish); - stream.removeListener('end', onlegacyfinish); - stream.removeListener('close', onlegacyfinish); - stream.removeListener('finish', onfinish); - stream.removeListener('exit', onexit); - stream.removeListener('end', onend); - stream.removeListener('error', onerror); - stream.removeListener('close', onclose); - }; + return [...stdio, 'ipc']; }; -module.exports = eos; - /***/ }), -/***/ 5447: +/***/ 2592: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -const path = __nccwpck_require__(5622); -const childProcess = __nccwpck_require__(3129); -const crossSpawn = __nccwpck_require__(2746); -const stripFinalNewline = __nccwpck_require__(8174); -const npmRunPath = __nccwpck_require__(502); -const onetime = __nccwpck_require__(9082); -const makeError = __nccwpck_require__(2187); -const normalizeStdio = __nccwpck_require__(166); -const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = __nccwpck_require__(9819); -const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __nccwpck_require__(2592); -const {mergePromise, getSpawnedPromise} = __nccwpck_require__(7814); -const {joinCommand, parseCommand} = __nccwpck_require__(8286); - -const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; - -const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => { - const env = extendEnv ? {...process.env, ...envOption} : envOption; +const isStream = __nccwpck_require__(1554); +const getStream = __nccwpck_require__(1766); +const mergeStream = __nccwpck_require__(2621); - if (preferLocal) { - return npmRunPath.env({env, cwd: localDir, execPath}); +// `input` option +const handleInput = (spawned, input) => { + // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 + // TODO: Remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 + if (input === undefined || spawned.stdin === undefined) { + return; } - return env; + if (isStream(input)) { + input.pipe(spawned.stdin); + } else { + spawned.stdin.end(input); + } }; -const handleArguments = (file, args, options = {}) => { - const parsed = crossSpawn._parse(file, args, options); - file = parsed.command; - args = parsed.args; - options = parsed.options; - - options = { - maxBuffer: DEFAULT_MAX_BUFFER, - buffer: true, - stripFinalNewline: true, - extendEnv: true, - preferLocal: false, - localDir: options.cwd || process.cwd(), - execPath: process.execPath, - encoding: 'utf8', - reject: true, - cleanup: true, - all: false, - windowsHide: true, - ...options - }; - - options.env = getEnv(options); - - options.stdio = normalizeStdio(options); - - if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') { - // #116 - args.unshift('/q'); +// `all` interleaves `stdout` and `stderr` +const makeAllStream = (spawned, {all}) => { + if (!all || (!spawned.stdout && !spawned.stderr)) { + return; } - return {file, args, options, parsed}; -}; + const mixed = mergeStream(); -const handleOutput = (options, value, error) => { - if (typeof value !== 'string' && !Buffer.isBuffer(value)) { - // When `execa.sync()` errors, we normalize it to '' to mimic `execa()` - return error === undefined ? undefined : ''; + if (spawned.stdout) { + mixed.add(spawned.stdout); } - if (options.stripFinalNewline) { - return stripFinalNewline(value); + if (spawned.stderr) { + mixed.add(spawned.stderr); } - return value; + return mixed; }; -const execa = (file, args, options) => { - const parsed = handleArguments(file, args, options); - const command = joinCommand(file, args); +// On failure, `result.stdout|stderr|all` should contain the currently buffered stream +const getBufferedData = async (stream, streamPromise) => { + if (!stream) { + return; + } + + stream.destroy(); - let spawned; try { - spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options); + return await streamPromise; } catch (error) { - // Ensure the returned error is always both a promise and a child process - const dummySpawned = new childProcess.ChildProcess(); - const errorPromise = Promise.reject(makeError({ - error, - stdout: '', - stderr: '', - all: '', - command, - parsed, - timedOut: false, - isCanceled: false, - killed: false - })); - return mergePromise(dummySpawned, errorPromise); + return error.bufferedData; } +}; - const spawnedPromise = getSpawnedPromise(spawned); - const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise); - const processDone = setExitHandler(spawned, parsed.options, timedPromise); +const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => { + if (!stream || !buffer) { + return; + } - const context = {isCanceled: false}; + if (encoding) { + return getStream(stream, {encoding, maxBuffer}); + } - spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned)); - spawned.cancel = spawnedCancel.bind(null, spawned, context); + return getStream.buffer(stream, {maxBuffer}); +}; - const handlePromise = async () => { - const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone); - const stdout = handleOutput(parsed.options, stdoutResult); - const stderr = handleOutput(parsed.options, stderrResult); - const all = handleOutput(parsed.options, allResult); +// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all) +const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => { + const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer}); + const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer}); + const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2}); - if (error || exitCode !== 0 || signal !== null) { - const returnedError = makeError({ - error, - exitCode, - signal, - stdout, - stderr, - all, - command, - parsed, - timedOut, - isCanceled: context.isCanceled, - killed: spawned.killed - }); + try { + return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]); + } catch (error) { + return Promise.all([ + {error, signal: error.signal, timedOut: error.timedOut}, + getBufferedData(stdout, stdoutPromise), + getBufferedData(stderr, stderrPromise), + getBufferedData(all, allPromise) + ]); + } +}; - if (!parsed.options.reject) { - return returnedError; - } +const validateInputSync = ({input}) => { + if (isStream(input)) { + throw new TypeError('The `input` option cannot be a stream in sync mode'); + } +}; - throw returnedError; - } +module.exports = { + handleInput, + makeAllStream, + getSpawnedResult, + validateInputSync +}; - return { - command, - exitCode: 0, - stdout, - stderr, - all, - failed: false, - timedOut: false, - isCanceled: false, - killed: false - }; - }; - const handlePromiseOnce = onetime(handlePromise); - crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed); +/***/ }), - handleInput(spawned, parsed.options.input); +/***/ 6863: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - spawned.all = makeAllStream(spawned, parsed.options); +module.exports = realpath +realpath.realpath = realpath +realpath.sync = realpathSync +realpath.realpathSync = realpathSync +realpath.monkeypatch = monkeypatch +realpath.unmonkeypatch = unmonkeypatch - return mergePromise(spawned, handlePromiseOnce); -}; +var fs = __nccwpck_require__(5747) +var origRealpath = fs.realpath +var origRealpathSync = fs.realpathSync -module.exports = execa; +var version = process.version +var ok = /^v[0-5]\./.test(version) +var old = __nccwpck_require__(1734) -module.exports.sync = (file, args, options) => { - const parsed = handleArguments(file, args, options); - const command = joinCommand(file, args); +function newError (er) { + return er && er.syscall === 'realpath' && ( + er.code === 'ELOOP' || + er.code === 'ENOMEM' || + er.code === 'ENAMETOOLONG' + ) +} - validateInputSync(parsed.options); +function realpath (p, cache, cb) { + if (ok) { + return origRealpath(p, cache, cb) + } - let result; - try { - result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options); - } catch (error) { - throw makeError({ - error, - stdout: '', - stderr: '', - all: '', - command, - parsed, - timedOut: false, - isCanceled: false, - killed: false - }); - } + if (typeof cache === 'function') { + cb = cache + cache = null + } + origRealpath(p, cache, function (er, result) { + if (newError(er)) { + old.realpath(p, cache, cb) + } else { + cb(er, result) + } + }) +} - const stdout = handleOutput(parsed.options, result.stdout, result.error); - const stderr = handleOutput(parsed.options, result.stderr, result.error); +function realpathSync (p, cache) { + if (ok) { + return origRealpathSync(p, cache) + } - if (result.error || result.status !== 0 || result.signal !== null) { - const error = makeError({ - stdout, - stderr, - error: result.error, - signal: result.signal, - exitCode: result.status, - command, - parsed, - timedOut: result.error && result.error.code === 'ETIMEDOUT', - isCanceled: false, - killed: result.signal !== null - }); + try { + return origRealpathSync(p, cache) + } catch (er) { + if (newError(er)) { + return old.realpathSync(p, cache) + } else { + throw er + } + } +} - if (!parsed.options.reject) { - return error; - } +function monkeypatch () { + fs.realpath = realpath + fs.realpathSync = realpathSync +} - throw error; - } +function unmonkeypatch () { + fs.realpath = origRealpath + fs.realpathSync = origRealpathSync +} - return { - command, - exitCode: 0, - stdout, - stderr, - failed: false, - timedOut: false, - isCanceled: false, - killed: false - }; -}; -module.exports.command = (command, options) => { - const [file, ...args] = parseCommand(command); - return execa(file, args, options); -}; +/***/ }), -module.exports.commandSync = (command, options) => { - const [file, ...args] = parseCommand(command); - return execa.sync(file, args, options); -}; +/***/ 1734: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -module.exports.node = (scriptPath, args, options = {}) => { - if (args && !Array.isArray(args) && typeof args === 'object') { - options = args; - args = []; - } +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - const stdio = normalizeStdio.node(options); - const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect')); +var pathModule = __nccwpck_require__(5622); +var isWindows = process.platform === 'win32'; +var fs = __nccwpck_require__(5747); - const { - nodePath = process.execPath, - nodeOptions = defaultExecArgv - } = options; +// JavaScript implementation of realpath, ported from node pre-v6 - return execa( - nodePath, - [ - ...nodeOptions, - scriptPath, - ...(Array.isArray(args) ? args : []) - ], - { - ...options, - stdin: undefined, - stdout: undefined, - stderr: undefined, - stdio, - shell: false - } - ); -}; +var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); +function rethrow() { + // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and + // is fairly slow to generate. + var callback; + if (DEBUG) { + var backtrace = new Error; + callback = debugCallback; + } else + callback = missingCallback; -/***/ }), + return callback; -/***/ 8286: -/***/ ((module) => { + function debugCallback(err) { + if (err) { + backtrace.message = err.message; + err = backtrace; + missingCallback(err); + } + } -"use strict"; + function missingCallback(err) { + if (err) { + if (process.throwDeprecation) + throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs + else if (!process.noDeprecation) { + var msg = 'fs: missing callback ' + (err.stack || err.message); + if (process.traceDeprecation) + console.trace(msg); + else + console.error(msg); + } + } + } +} -const SPACES_REGEXP = / +/g; +function maybeCallback(cb) { + return typeof cb === 'function' ? cb : rethrow(); +} -const joinCommand = (file, args = []) => { - if (!Array.isArray(args)) { - return file; - } +var normalize = pathModule.normalize; - return [file, ...args].join(' '); -}; +// Regexp that finds the next partion of a (partial) path +// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] +if (isWindows) { + var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; +} else { + var nextPartRe = /(.*?)(?:[\/]+|$)/g; +} -// Handle `execa.command()` -const parseCommand = command => { - const tokens = []; - for (const token of command.trim().split(SPACES_REGEXP)) { - // Allow spaces to be escaped by a backslash if not meant as a delimiter - const previousToken = tokens[tokens.length - 1]; - if (previousToken && previousToken.endsWith('\\')) { - // Merge previous token with current one - tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`; - } else { - tokens.push(token); - } - } +// Regex to find the device root, including trailing slash. E.g. 'c:\\'. +if (isWindows) { + var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; +} else { + var splitRootRe = /^[\/]*/; +} - return tokens; -}; +exports.realpathSync = function realpathSync(p, cache) { + // make p is absolute + p = pathModule.resolve(p); -module.exports = { - joinCommand, - parseCommand -}; + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return cache[p]; + } + var original = p, + seenLinks = {}, + knownHard = {}; -/***/ }), + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; -/***/ 2187: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + start(); -"use strict"; + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; -const {signalsByName} = __nccwpck_require__(2779); + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstatSync(base); + knownHard[base] = true; + } + } -const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { - if (timedOut) { - return `timed out after ${timeout} milliseconds`; - } + // walk down the path, swapping out linked pathparts for their real + // values + // NB: p.length changes. + while (pos < p.length) { + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; - if (isCanceled) { - return 'was canceled'; - } + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + continue; + } - if (errorCode !== undefined) { - return `failed with ${errorCode}`; - } + var resolvedLink; + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // some known symbolic link. no need to stat again. + resolvedLink = cache[base]; + } else { + var stat = fs.lstatSync(base); + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + continue; + } - if (signal !== undefined) { - return `was killed with ${signal} (${signalDescription})`; - } + // read the link if it wasn't read before + // dev/ino always return 0 on windows, so skip the check. + var linkTarget = null; + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + linkTarget = seenLinks[id]; + } + } + if (linkTarget === null) { + fs.statSync(base); + linkTarget = fs.readlinkSync(base); + } + resolvedLink = pathModule.resolve(previous, linkTarget); + // track this, if given a cache. + if (cache) cache[base] = resolvedLink; + if (!isWindows) seenLinks[id] = linkTarget; + } - if (exitCode !== undefined) { - return `failed with exit code ${exitCode}`; - } + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } - return 'failed'; + if (cache) cache[original] = p; + + return p; }; -const makeError = ({ - stdout, - stderr, - all, - error, - signal, - exitCode, - command, - timedOut, - isCanceled, - killed, - parsed: {options: {timeout}} -}) => { - // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`. - // We normalize them to `undefined` - exitCode = exitCode === null ? undefined : exitCode; - signal = signal === null ? undefined : signal; - const signalDescription = signal === undefined ? undefined : signalsByName[signal].description; - const errorCode = error && error.code; +exports.realpath = function realpath(p, cache, cb) { + if (typeof cb !== 'function') { + cb = maybeCallback(cache); + cache = null; + } - const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}); - const execaMessage = `Command ${prefix}: ${command}`; - const isError = Object.prototype.toString.call(error) === '[object Error]'; - const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage; - const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n'); + // make p is absolute + p = pathModule.resolve(p); - if (isError) { - error.originalMessage = error.message; - error.message = message; - } else { - error = new Error(message); - } + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return process.nextTick(cb.bind(null, null, cache[p])); + } - error.shortMessage = shortMessage; - error.command = command; - error.exitCode = exitCode; - error.signal = signal; - error.signalDescription = signalDescription; - error.stdout = stdout; - error.stderr = stderr; + var original = p, + seenLinks = {}, + knownHard = {}; + + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; + + start(); + + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstat(base, function(err) { + if (err) return cb(err); + knownHard[base] = true; + LOOP(); + }); + } else { + process.nextTick(LOOP); + } + } - if (all !== undefined) { - error.all = all; - } + // walk down the path, swapping out linked pathparts for their real + // values + function LOOP() { + // stop if scanned past end of path + if (pos >= p.length) { + if (cache) cache[original] = p; + return cb(null, p); + } - if ('bufferedData' in error) { - delete error.bufferedData; - } + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; - error.failed = true; - error.timedOut = Boolean(timedOut); - error.isCanceled = isCanceled; - error.killed = killed && !timedOut; + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + return process.nextTick(LOOP); + } - return error; -}; + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // known symbolic link. no need to stat again. + return gotResolvedLink(cache[base]); + } -module.exports = makeError; + return fs.lstat(base, gotStat); + } + function gotStat(err, stat) { + if (err) return cb(err); -/***/ }), + // if not a symlink, skip to the next path part + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + return process.nextTick(LOOP); + } -/***/ 9819: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + // stat & read the link if not read before + // call gotTarget as soon as the link target is known + // dev/ino always return 0 on windows, so skip the check. + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + return gotTarget(null, seenLinks[id], base); + } + } + fs.stat(base, function(err) { + if (err) return cb(err); -"use strict"; + fs.readlink(base, function(err, target) { + if (!isWindows) seenLinks[id] = target; + gotTarget(err, target); + }); + }); + } -const os = __nccwpck_require__(2087); -const onExit = __nccwpck_require__(4931); + function gotTarget(err, target, base) { + if (err) return cb(err); -const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; + var resolvedLink = pathModule.resolve(previous, target); + if (cache) cache[base] = resolvedLink; + gotResolvedLink(resolvedLink); + } -// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior -const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => { - const killResult = kill(signal); - setKillTimeout(kill, signal, options, killResult); - return killResult; + function gotResolvedLink(resolvedLink) { + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } }; -const setKillTimeout = (kill, signal, options, killResult) => { - if (!shouldForceKill(signal, options, killResult)) { - return; - } - - const timeout = getForceKillAfterTimeout(options); - const t = setTimeout(() => { - kill('SIGKILL'); - }, timeout); - // Guarded because there's no `.unref()` when `execa` is used in the renderer - // process in Electron. This cannot be tested since we don't run tests in - // Electron. - // istanbul ignore else - if (t.unref) { - t.unref(); - } -}; +/***/ }), -const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => { - return isSigterm(signal) && forceKillAfterTimeout !== false && killResult; -}; +/***/ 1585: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const isSigterm = signal => { - return signal === os.constants.signals.SIGTERM || - (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM'); -}; +"use strict"; -const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { - if (forceKillAfterTimeout === true) { - return DEFAULT_FORCE_KILL_TIMEOUT; - } +const {PassThrough: PassThroughStream} = __nccwpck_require__(2413); - if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) { - throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`); - } +module.exports = options => { + options = {...options}; - return forceKillAfterTimeout; -}; + const {array} = options; + let {encoding} = options; + const isBuffer = encoding === 'buffer'; + let objectMode = false; -// `childProcess.cancel()` -const spawnedCancel = (spawned, context) => { - const killResult = spawned.kill(); + if (array) { + objectMode = !(encoding || isBuffer); + } else { + encoding = encoding || 'utf8'; + } - if (killResult) { - context.isCanceled = true; + if (isBuffer) { + encoding = null; } -}; -const timeoutKill = (spawned, signal, reject) => { - spawned.kill(signal); - reject(Object.assign(new Error('Timed out'), {timedOut: true, signal})); -}; + const stream = new PassThroughStream({objectMode}); -// `timeout` option handling -const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => { - if (timeout === 0 || timeout === undefined) { - return spawnedPromise; + if (encoding) { + stream.setEncoding(encoding); } - if (!Number.isFinite(timeout) || timeout < 0) { - throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); - } + let length = 0; + const chunks = []; - let timeoutId; - const timeoutPromise = new Promise((resolve, reject) => { - timeoutId = setTimeout(() => { - timeoutKill(spawned, killSignal, reject); - }, timeout); - }); + stream.on('data', chunk => { + chunks.push(chunk); - const safeSpawnedPromise = spawnedPromise.finally(() => { - clearTimeout(timeoutId); + if (objectMode) { + length = chunks.length; + } else { + length += chunk.length; + } }); - return Promise.race([timeoutPromise, safeSpawnedPromise]); -}; - -// `cleanup` option handling -const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { - if (!cleanup || detached) { - return timedPromise; - } + stream.getBufferedValue = () => { + if (array) { + return chunks; + } - const removeExitHandler = onExit(() => { - spawned.kill(); - }); + return isBuffer ? Buffer.concat(chunks, length) : chunks.join(''); + }; - return timedPromise.finally(() => { - removeExitHandler(); - }); -}; + stream.getBufferedLength = () => length; -module.exports = { - spawnedKill, - spawnedCancel, - setupTimeout, - setExitHandler + return stream; }; /***/ }), -/***/ 7814: -/***/ ((module) => { +/***/ 1766: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +const {constants: BufferConstants} = __nccwpck_require__(4293); +const pump = __nccwpck_require__(8341); +const bufferStream = __nccwpck_require__(1585); -const nativePromisePrototype = (async () => {})().constructor.prototype; -const descriptors = ['then', 'catch', 'finally'].map(property => [ - property, - Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property) -]); - -// The return value is a mixin of `childProcess` and `Promise` -const mergePromise = (spawned, promise) => { - for (const [property, descriptor] of descriptors) { - // Starting the main `promise` is deferred to avoid consuming streams - const value = typeof promise === 'function' ? - (...args) => Reflect.apply(descriptor.value, promise(), args) : - descriptor.value.bind(promise); +class MaxBufferError extends Error { + constructor() { + super('maxBuffer exceeded'); + this.name = 'MaxBufferError'; + } +} - Reflect.defineProperty(spawned, property, {...descriptor, value}); +async function getStream(inputStream, options) { + if (!inputStream) { + return Promise.reject(new Error('Expected a stream')); } - return spawned; -}; + options = { + maxBuffer: Infinity, + ...options + }; -// Use promises instead of `child_process` events -const getSpawnedPromise = spawned => { - return new Promise((resolve, reject) => { - spawned.on('exit', (exitCode, signal) => { - resolve({exitCode, signal}); - }); + const {maxBuffer} = options; + + let stream; + await new Promise((resolve, reject) => { + const rejectPromise = error => { + // Don't retrieve an oversized buffer. + if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) { + error.bufferedData = stream.getBufferedValue(); + } - spawned.on('error', error => { reject(error); + }; + + stream = pump(inputStream, bufferStream(options), error => { + if (error) { + rejectPromise(error); + return; + } + + resolve(); }); - if (spawned.stdin) { - spawned.stdin.on('error', error => { - reject(error); - }); - } + stream.on('data', () => { + if (stream.getBufferedLength() > maxBuffer) { + rejectPromise(new MaxBufferError()); + } + }); }); -}; -module.exports = { - mergePromise, - getSpawnedPromise -}; + return stream.getBufferedValue(); +} +module.exports = getStream; +// TODO: Remove this for the next major release +module.exports.default = getStream; +module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'}); +module.exports.array = (stream, options) => getStream(stream, {...options, array: true}); +module.exports.MaxBufferError = MaxBufferError; /***/ }), -/***/ 166: -/***/ ((module) => { - -"use strict"; - -const aliases = ['stdin', 'stdout', 'stderr']; +/***/ 7625: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined); +exports.setopts = setopts +exports.ownProp = ownProp +exports.makeAbs = makeAbs +exports.finish = finish +exports.mark = mark +exports.isIgnored = isIgnored +exports.childrenIgnored = childrenIgnored -const normalizeStdio = opts => { - if (!opts) { - return; - } +function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} - const {stdio} = opts; +var path = __nccwpck_require__(5622) +var minimatch = __nccwpck_require__(3973) +var isAbsolute = __nccwpck_require__(8714) +var Minimatch = minimatch.Minimatch - if (stdio === undefined) { - return aliases.map(alias => opts[alias]); - } +function alphasort (a, b) { + return a.localeCompare(b, 'en') +} - if (hasAlias(opts)) { - throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`); - } +function setupIgnores (self, options) { + self.ignore = options.ignore || [] - if (typeof stdio === 'string') { - return stdio; - } + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore] - if (!Array.isArray(stdio)) { - throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``); - } + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap) + } +} - const length = Math.max(stdio.length, aliases.length); - return Array.from({length}, (value, index) => stdio[index]); -}; +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, '') + gmatcher = new Minimatch(gpattern, { dot: true }) + } -module.exports = normalizeStdio; + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } +} -// `ipc` is pushed unless it is already present -module.exports.node = opts => { - const stdio = normalizeStdio(opts); +function setopts (self, pattern, options) { + if (!options) + options = {} - if (stdio === 'ipc') { - return 'ipc'; - } + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern + } - if (stdio === undefined || typeof stdio === 'string') { - return [stdio, stdio, stdio, 'ipc']; - } + self.silent = !!options.silent + self.pattern = pattern + self.strict = options.strict !== false + self.realpath = !!options.realpath + self.realpathCache = options.realpathCache || Object.create(null) + self.follow = !!options.follow + self.dot = !!options.dot + self.mark = !!options.mark + self.nodir = !!options.nodir + if (self.nodir) + self.mark = true + self.sync = !!options.sync + self.nounique = !!options.nounique + self.nonull = !!options.nonull + self.nosort = !!options.nosort + self.nocase = !!options.nocase + self.stat = !!options.stat + self.noprocess = !!options.noprocess + self.absolute = !!options.absolute - if (stdio.includes('ipc')) { - return stdio; - } + self.maxLength = options.maxLength || Infinity + self.cache = options.cache || Object.create(null) + self.statCache = options.statCache || Object.create(null) + self.symlinks = options.symlinks || Object.create(null) - return [...stdio, 'ipc']; -}; + setupIgnores(self, options) + self.changedCwd = false + var cwd = process.cwd() + if (!ownProp(options, "cwd")) + self.cwd = cwd + else { + self.cwd = path.resolve(options.cwd) + self.changedCwd = self.cwd !== cwd + } -/***/ }), + self.root = options.root || path.resolve(self.cwd, "/") + self.root = path.resolve(self.root) + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/") -/***/ 2592: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") + self.nomount = !!options.nomount -"use strict"; + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true + options.nocomment = true -const isStream = __nccwpck_require__(1554); -const getStream = __nccwpck_require__(1766); -const mergeStream = __nccwpck_require__(2621); + self.minimatch = new Minimatch(pattern, options) + self.options = self.minimatch.options +} -// `input` option -const handleInput = (spawned, input) => { - // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 - // TODO: Remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 - if (input === undefined || spawned.stdin === undefined) { - return; - } +function finish (self) { + var nou = self.nounique + var all = nou ? [] : Object.create(null) - if (isStream(input)) { - input.pipe(spawned.stdin); - } else { - spawned.stdin.end(input); - } -}; + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i] + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i] + if (nou) + all.push(literal) + else + all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) + all.push.apply(all, m) + else + m.forEach(function (m) { + all[m] = true + }) + } + } -// `all` interleaves `stdout` and `stderr` -const makeAllStream = (spawned, {all}) => { - if (!all || (!spawned.stdout && !spawned.stderr)) { - return; - } + if (!nou) + all = Object.keys(all) - const mixed = mergeStream(); + if (!self.nosort) + all = all.sort(alphasort) - if (spawned.stdout) { - mixed.add(spawned.stdout); - } + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]) + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)) + var c = self.cache[e] || self.cache[makeAbs(self, e)] + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c) + return notDir + }) + } + } - if (spawned.stderr) { - mixed.add(spawned.stderr); - } + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }) - return mixed; -}; + self.found = all +} -// On failure, `result.stdout|stderr|all` should contain the currently buffered stream -const getBufferedData = async (stream, streamPromise) => { - if (!stream) { - return; - } +function mark (self, p) { + var abs = makeAbs(self, p) + var c = self.cache[abs] + var m = p + if (c) { + var isDir = c === 'DIR' || Array.isArray(c) + var slash = p.slice(-1) === '/' - stream.destroy(); + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) - try { - return await streamPromise; - } catch (error) { - return error.bufferedData; - } -}; + if (m !== p) { + var mabs = makeAbs(self, m) + self.statCache[mabs] = self.statCache[abs] + self.cache[mabs] = self.cache[abs] + } + } -const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => { - if (!stream || !buffer) { - return; - } + return m +} - if (encoding) { - return getStream(stream, {encoding, maxBuffer}); - } +// lotta situps... +function makeAbs (self, f) { + var abs = f + if (f.charAt(0) === '/') { + abs = path.join(self.root, f) + } else if (isAbsolute(f) || f === '') { + abs = f + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f) + } else { + abs = path.resolve(f) + } - return getStream.buffer(stream, {maxBuffer}); -}; + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/') -// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all) -const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => { - const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer}); - const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer}); - const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2}); + return abs +} - try { - return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]); - } catch (error) { - return Promise.all([ - {error, signal: error.signal, timedOut: error.timedOut}, - getBufferedData(stdout, stdoutPromise), - getBufferedData(stderr, stderrPromise), - getBufferedData(all, allPromise) - ]); - } -}; -const validateInputSync = ({input}) => { - if (isStream(input)) { - throw new TypeError('The `input` option cannot be a stream in sync mode'); - } -}; +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored (self, path) { + if (!self.ignore.length) + return false -module.exports = { - handleInput, - makeAllStream, - getSpawnedResult, - validateInputSync -}; + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) +} + +function childrenIgnored (self, path) { + if (!self.ignore.length) + return false + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) +} /***/ }), -/***/ 6863: +/***/ 1957: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = realpath -realpath.realpath = realpath -realpath.sync = realpathSync -realpath.realpathSync = realpathSync -realpath.monkeypatch = monkeypatch -realpath.unmonkeypatch = unmonkeypatch +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. + +module.exports = glob var fs = __nccwpck_require__(5747) -var origRealpath = fs.realpath -var origRealpathSync = fs.realpathSync +var rp = __nccwpck_require__(6863) +var minimatch = __nccwpck_require__(3973) +var Minimatch = minimatch.Minimatch +var inherits = __nccwpck_require__(4124) +var EE = __nccwpck_require__(8614).EventEmitter +var path = __nccwpck_require__(5622) +var assert = __nccwpck_require__(2357) +var isAbsolute = __nccwpck_require__(8714) +var globSync = __nccwpck_require__(9010) +var common = __nccwpck_require__(7625) +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = __nccwpck_require__(2492) +var util = __nccwpck_require__(1669) +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored -var version = process.version -var ok = /^v[0-5]\./.test(version) -var old = __nccwpck_require__(1734) +var once = __nccwpck_require__(1223) -function newError (er) { - return er && er.syscall === 'realpath' && ( - er.code === 'ELOOP' || - er.code === 'ENOMEM' || - er.code === 'ENAMETOOLONG' - ) +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} + + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } + + return new Glob(pattern, options, cb) } -function realpath (p, cache, cb) { - if (ok) { - return origRealpath(p, cache, cb) +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync + +// old api surface +glob.glob = glob + +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin } - if (typeof cache === 'function') { - cb = cache - cache = null + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] } - origRealpath(p, cache, function (er, result) { - if (newError(er)) { - old.realpath(p, cache, cb) - } else { - cb(er, result) - } - }) + return origin } -function realpathSync (p, cache) { - if (ok) { - return origRealpathSync(p, cache) +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true + + var g = new Glob(pattern, options) + var set = g.minimatch.set + + if (!pattern) + return false + + if (set.length > 1) + return true + + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true } - try { - return origRealpathSync(p, cache) - } catch (er) { - if (newError(er)) { - return old.realpathSync(p, cache) - } else { - throw er - } + return false +} + +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options + options = null } -} - -function monkeypatch () { - fs.realpath = realpath - fs.realpathSync = realpathSync -} -function unmonkeypatch () { - fs.realpath = origRealpath - fs.realpathSync = origRealpathSync -} + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) -/***/ }), + setopts(this, pattern, options) + this._didRealPath = false -/***/ 1734: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + // process each pattern in the minimatch set + var n = this.minimatch.set.length -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) -var pathModule = __nccwpck_require__(5622); -var isWindows = process.platform === 'win32'; -var fs = __nccwpck_require__(5747); + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) + } -// JavaScript implementation of realpath, ported from node pre-v6 + var self = this + this._processing = 0 -var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); + this._emitQueue = [] + this._processQueue = [] + this.paused = false -function rethrow() { - // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and - // is fairly slow to generate. - var callback; - if (DEBUG) { - var backtrace = new Error; - callback = debugCallback; - } else - callback = missingCallback; + if (this.noprocess) + return this - return callback; + if (n === 0) + return done() - function debugCallback(err) { - if (err) { - backtrace.message = err.message; - err = backtrace; - missingCallback(err); - } + var sync = true + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) } + sync = false - function missingCallback(err) { - if (err) { - if (process.throwDeprecation) - throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs - else if (!process.noDeprecation) { - var msg = 'fs: missing callback ' + (err.stack || err.message); - if (process.traceDeprecation) - console.trace(msg); - else - console.error(msg); + function done () { + --self._processing + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish() + }) + } else { + self._finish() } } } } -function maybeCallback(cb) { - return typeof cb === 'function' ? cb : rethrow(); -} +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return -var normalize = pathModule.normalize; + if (this.realpath && !this._didRealpath) + return this._realpath() -// Regexp that finds the next partion of a (partial) path -// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] -if (isWindows) { - var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; -} else { - var nextPartRe = /(.*?)(?:[\/]+|$)/g; + common.finish(this) + this.emit('end', this.found) } -// Regex to find the device root, including trailing slash. E.g. 'c:\\'. -if (isWindows) { - var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; -} else { - var splitRootRe = /^[\/]*/; -} +Glob.prototype._realpath = function () { + if (this._didRealpath) + return -exports.realpathSync = function realpathSync(p, cache) { - // make p is absolute - p = pathModule.resolve(p); + this._didRealpath = true - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return cache[p]; + var n = this.matches.length + if (n === 0) + return this._finish() + + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) + + function next () { + if (--n === 0) + self._finish() } +} - var original = p, - seenLinks = {}, - knownHard = {}; +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; + var found = Object.keys(matchset) + var self = this + var n = found.length - start(); + if (n === 0) + return cb() - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here - // On windows, check that the root exists. On unix there is no need. - if (isWindows && !knownHard[base]) { - fs.lstatSync(base); - knownHard[base] = true; - } - } + if (--n === 0) { + self.matches[index] = set + cb() + } + }) + }) +} - // walk down the path, swapping out linked pathparts for their real - // values - // NB: p.length changes. - while (pos < p.length) { - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - continue; - } +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} - var resolvedLink; - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // some known symbolic link. no need to stat again. - resolvedLink = cache[base]; - } else { - var stat = fs.lstatSync(base); - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - continue; - } +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') +} - // read the link if it wasn't read before - // dev/ino always return 0 on windows, so skip the check. - var linkTarget = null; - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - linkTarget = seenLinks[id]; - } +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} + +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) } - if (linkTarget === null) { - fs.statSync(base); - linkTarget = fs.readlinkSync(base); + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) } - resolvedLink = pathModule.resolve(previous, linkTarget); - // track this, if given a cache. - if (cache) cache[base] = resolvedLink; - if (!isWindows) seenLinks[id] = linkTarget; } - - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); } +} - if (cache) cache[original] = p; - - return p; -}; +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') + if (this.aborted) + return -exports.realpath = function realpath(p, cache, cb) { - if (typeof cb !== 'function') { - cb = maybeCallback(cache); - cache = null; + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return } - // make p is absolute - p = pathModule.resolve(p); + //console.error('PROCESS %d', this._processing, pattern) - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return process.nextTick(cb.bind(null, null, cache[p])); + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ } + // now n is the index of the first one that is *not* a string. - var original = p, - seenLinks = {}, - knownHard = {}; + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break - start(); + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; + var remain = pattern.slice(n) - // On windows, check that the root exists. On unix there is no need. - if (isWindows && !knownHard[base]) { - fs.lstat(base, function(err) { - if (err) return cb(err); - knownHard[base] = true; - LOOP(); - }); - } else { - process.nextTick(LOOP); - } - } + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix - // walk down the path, swapping out linked pathparts for their real - // values - function LOOP() { - // stop if scanned past end of path - if (pos >= p.length) { - if (cache) cache[original] = p; - return cb(null, p); - } + var abs = this._makeAbs(read) - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - return process.nextTick(LOOP); - } + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) +} - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // known symbolic link. no need to stat again. - return gotResolvedLink(cache[base]); - } +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} - return fs.lstat(base, gotStat); - } +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - function gotStat(err, stat) { - if (err) return cb(err); + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() - // if not a symlink, skip to the next path part - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - return process.nextTick(LOOP); - } + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' - // stat & read the link if not read before - // call gotTarget as soon as the link target is known - // dev/ino always return 0 on windows, so skip the check. - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - return gotTarget(null, seenLinks[id], base); + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) } + if (m) + matchedEntries.push(e) } - fs.stat(base, function(err) { - if (err) return cb(err); - - fs.readlink(base, function(err, target) { - if (!isWindows) seenLinks[id] = target; - gotTarget(err, target); - }); - }); } - function gotTarget(err, target, base) { - if (err) return cb(err); + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) - var resolvedLink = pathModule.resolve(previous, target); - if (cache) cache[base] = resolvedLink; - gotResolvedLink(resolvedLink); + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return cb() } - function gotResolvedLink(resolvedLink) { - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + this._process([e].concat(remain), index, inGlobStar, cb) } -}; + cb() +} +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return -/***/ }), + if (isIgnored(this, e)) + return -/***/ 1585: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (this.paused) { + this._emitQueue.push([index, e]) + return + } -"use strict"; + var abs = isAbsolute(e) ? e : this._makeAbs(e) -const {PassThrough: PassThroughStream} = __nccwpck_require__(2413); + if (this.mark) + e = this._mark(e) -module.exports = options => { - options = {...options}; + if (this.absolute) + e = abs - const {array} = options; - let {encoding} = options; - const isBuffer = encoding === 'buffer'; - let objectMode = false; + if (this.matches[index][e]) + return - if (array) { - objectMode = !(encoding || isBuffer); - } else { - encoding = encoding || 'utf8'; - } + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } - if (isBuffer) { - encoding = null; - } + this.matches[index][e] = true - const stream = new PassThroughStream({objectMode}); + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) - if (encoding) { - stream.setEncoding(encoding); - } + this.emit('match', e) +} - let length = 0; - const chunks = []; +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return - stream.on('data', chunk => { - chunks.push(chunk); + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) - if (objectMode) { - length = chunks.length; - } else { - length += chunk.length; - } - }); + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) - stream.getBufferedValue = () => { - if (array) { - return chunks; - } + if (lstatcb) + fs.lstat(abs, lstatcb) - return isBuffer ? Buffer.concat(chunks, length) : chunks.join(''); - }; + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() - stream.getBufferedLength = () => length; + var isSym = lstat && lstat.isSymbolicLink() + self.symlinks[abs] = isSym - return stream; -}; + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) + } +} +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return -/***/ }), + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return -/***/ 1766: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) -"use strict"; + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() -const {constants: BufferConstants} = __nccwpck_require__(4293); -const pump = __nccwpck_require__(8341); -const bufferStream = __nccwpck_require__(1585); + if (Array.isArray(c)) + return cb(null, c) + } -class MaxBufferError extends Error { - constructor() { - super('maxBuffer exceeded'); - this.name = 'MaxBufferError'; - } + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) } -async function getStream(inputStream, options) { - if (!inputStream) { - return Promise.reject(new Error('Expected a stream')); - } - - options = { - maxBuffer: Infinity, - ...options - }; - - const {maxBuffer} = options; - - let stream; - await new Promise((resolve, reject) => { - const rejectPromise = error => { - // Don't retrieve an oversized buffer. - if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) { - error.bufferedData = stream.getBufferedValue(); - } - - reject(error); - }; - - stream = pump(inputStream, bufferStream(options), error => { - if (error) { - rejectPromise(error); - return; - } +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) + } +} - resolve(); - }); +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return - stream.on('data', () => { - if (stream.getBufferedLength() > maxBuffer) { - rejectPromise(new MaxBufferError()); - } - }); - }); + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } - return stream.getBufferedValue(); + this.cache[abs] = entries + return cb(null, entries) } -module.exports = getStream; -// TODO: Remove this for the next major release -module.exports.default = getStream; -module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'}); -module.exports.array = (stream, options) => getStream(stream, {...options, array: true}); -module.exports.MaxBufferError = MaxBufferError; - +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return -/***/ }), + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + this.emit('error', error) + this.abort() + } + break -/***/ 7625: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break -exports.setopts = setopts -exports.ownProp = ownProp -exports.makeAbs = makeAbs -exports.finish = finish -exports.mark = mark -exports.isIgnored = isIgnored -exports.childrenIgnored = childrenIgnored + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break + } -function ownProp (obj, field) { - return Object.prototype.hasOwnProperty.call(obj, field) + return cb() } -var path = __nccwpck_require__(5622) -var minimatch = __nccwpck_require__(3973) -var isAbsolute = __nccwpck_require__(8714) -var Minimatch = minimatch.Minimatch - -function alphasort (a, b) { - return a.localeCompare(b, 'en') +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) } -function setupIgnores (self, options) { - self.ignore = options.ignore || [] - - if (!Array.isArray(self.ignore)) - self.ignore = [self.ignore] - if (self.ignore.length) { - self.ignore = self.ignore.map(ignoreMap) - } -} +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) -// ignore patterns are always in dot:true mode. -function ignoreMap (pattern) { - var gmatcher = null - if (pattern.slice(-3) === '/**') { - var gpattern = pattern.replace(/(\/\*\*)+$/, '') - gmatcher = new Minimatch(gpattern, { dot: true }) - } + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() - return { - matcher: new Minimatch(pattern, { dot: true }), - gmatcher: gmatcher - } -} + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) -function setopts (self, pattern, options) { - if (!options) - options = {} + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) - // base-matching: just use globstar for that. - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar") - } - pattern = "**/" + pattern - } + var isSym = this.symlinks[abs] + var len = entries.length - self.silent = !!options.silent - self.pattern = pattern - self.strict = options.strict !== false - self.realpath = !!options.realpath - self.realpathCache = options.realpathCache || Object.create(null) - self.follow = !!options.follow - self.dot = !!options.dot - self.mark = !!options.mark - self.nodir = !!options.nodir - if (self.nodir) - self.mark = true - self.sync = !!options.sync - self.nounique = !!options.nounique - self.nonull = !!options.nonull - self.nosort = !!options.nosort - self.nocase = !!options.nocase - self.stat = !!options.stat - self.noprocess = !!options.noprocess - self.absolute = !!options.absolute + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() - self.maxLength = options.maxLength || Infinity - self.cache = options.cache || Object.create(null) - self.statCache = options.statCache || Object.create(null) - self.symlinks = options.symlinks || Object.create(null) + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue - setupIgnores(self, options) + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) - self.changedCwd = false - var cwd = process.cwd() - if (!ownProp(options, "cwd")) - self.cwd = cwd - else { - self.cwd = path.resolve(options.cwd) - self.changedCwd = self.cwd !== cwd + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) } - self.root = options.root || path.resolve(self.cwd, "/") - self.root = path.resolve(self.root) - if (process.platform === "win32") - self.root = self.root.replace(/\\/g, "/") + cb() +} - // TODO: is an absolute `cwd` supposed to be resolved against `root`? - // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') - self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) - if (process.platform === "win32") - self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") - self.nomount = !!options.nomount +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) +} +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - // disable comments and negation in Minimatch. - // Note that they are not supported in Glob itself anyway. - options.nonegate = true - options.nocomment = true + //console.error('ps2', prefix, exists) - self.minimatch = new Minimatch(pattern, options) - self.options = self.minimatch.options -} + if (!this.matches[index]) + this.matches[index] = Object.create(null) -function finish (self) { - var nou = self.nounique - var all = nou ? [] : Object.create(null) + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() - for (var i = 0, l = self.matches.length; i < l; i ++) { - var matches = self.matches[i] - if (!matches || Object.keys(matches).length === 0) { - if (self.nonull) { - // do like the shell, and spit out the literal glob - var literal = self.minimatch.globSet[i] - if (nou) - all.push(literal) - else - all[literal] = true - } + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) } else { - // had matches - var m = Object.keys(matches) - if (nou) - all.push.apply(all, m) - else - m.forEach(function (m) { - all[m] = true - }) + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' } } - if (!nou) - all = Object.keys(all) + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') - if (!self.nosort) - all = all.sort(alphasort) + // Mark this as a match + this._emitMatch(index, prefix) + cb() +} - // at *some* point we statted all of these - if (self.mark) { - for (var i = 0; i < all.length; i++) { - all[i] = self._mark(all[i]) - } - if (self.nodir) { - all = all.filter(function (e) { - var notDir = !(/\/$/.test(e)) - var c = self.cache[e] || self.cache[makeAbs(self, e)] - if (notDir && c) - notDir = c !== 'DIR' && !Array.isArray(c) - return notDir - }) - } - } +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' - if (self.ignore.length) - all = all.filter(function(m) { - return !isIgnored(self, m) - }) + if (f.length > this.maxLength) + return cb() - self.found = all -} + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] -function mark (self, p) { - var abs = makeAbs(self, p) - var c = self.cache[abs] - var m = p - if (c) { - var isDir = c === 'DIR' || Array.isArray(c) - var slash = p.slice(-1) === '/' + if (Array.isArray(c)) + c = 'DIR' - if (isDir && !slash) - m += '/' - else if (!isDir && slash) - m = m.slice(0, -1) + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) - if (m !== p) { - var mabs = makeAbs(self, m) - self.statCache[mabs] = self.statCache[abs] - self.cache[mabs] = self.cache[abs] + if (needDir && c === 'FILE') + return cb() + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) } } - return m -} + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) -// lotta situps... -function makeAbs (self, f) { - var abs = f - if (f.charAt(0) === '/') { - abs = path.join(self.root, f) - } else if (isAbsolute(f) || f === '') { - abs = f - } else if (self.changedCwd) { - abs = path.resolve(self.cwd, f) - } else { - abs = path.resolve(f) + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) + } } - - if (process.platform === 'win32') - abs = abs.replace(/\\/g, '/') - - return abs } +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return cb() + } -// Return true, if pattern ends with globstar '**', for the accompanying parent directory. -// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents -function isIgnored (self, path) { - if (!self.ignore.length) - return false + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat - return self.ignore.some(function(item) { - return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) - }) -} + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) -function childrenIgnored (self, path) { - if (!self.ignore.length) - return false + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c - return self.ignore.some(function(item) { - return !!(item.gmatcher && item.gmatcher.match(path)) - }) + if (needDir && c === 'FILE') + return cb() + + return cb(null, c, stat) } /***/ }), -/***/ 1957: +/***/ 9010: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// Approach: -// -// 1. Get the minimatch set -// 2. For each pattern in the set, PROCESS(pattern, false) -// 3. Store matches per-set, then uniq them -// -// PROCESS(pattern, inGlobStar) -// Get the first [n] items from pattern that are all strings -// Join these together. This is PREFIX. -// If there is no more remaining, then stat(PREFIX) and -// add to matches if it succeeds. END. -// -// If inGlobStar and PREFIX is symlink and points to dir -// set ENTRIES = [] -// else readdir(PREFIX) as ENTRIES -// If fail, END -// -// with ENTRIES -// If pattern[n] is GLOBSTAR -// // handle the case where the globstar match is empty -// // by pruning it out, and testing the resulting pattern -// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) -// // handle other cases. -// for ENTRY in ENTRIES (not dotfiles) -// // attach globstar + tail onto the entry -// // Mark that this entry is a globstar match -// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) -// -// else // not globstar -// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) -// Test ENTRY against pattern[n] -// If fails, continue -// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) -// -// Caveat: -// Cache all stats and readdirs results to minimize syscall. Since all -// we ever care about is existence and directory-ness, we can just keep -// `true` for files, and [children,...] for directories, or `false` for -// things that don't exist. - -module.exports = glob +module.exports = globSync +globSync.GlobSync = GlobSync var fs = __nccwpck_require__(5747) var rp = __nccwpck_require__(6863) var minimatch = __nccwpck_require__(3973) var Minimatch = minimatch.Minimatch -var inherits = __nccwpck_require__(4124) -var EE = __nccwpck_require__(8614).EventEmitter +var Glob = __nccwpck_require__(1957).Glob +var util = __nccwpck_require__(1669) var path = __nccwpck_require__(5622) var assert = __nccwpck_require__(2357) var isAbsolute = __nccwpck_require__(8714) -var globSync = __nccwpck_require__(9010) var common = __nccwpck_require__(7625) var setopts = common.setopts var ownProp = common.ownProp -var inflight = __nccwpck_require__(2492) -var util = __nccwpck_require__(1669) var childrenIgnored = common.childrenIgnored var isIgnored = common.isIgnored -var once = __nccwpck_require__(1223) +function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -function glob (pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {} - if (!options) options = {} + return new GlobSync(pattern, options).found +} - if (options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return globSync(pattern, options) - } +function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') - return new Glob(pattern, options, cb) -} + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') -glob.sync = globSync -var GlobSync = glob.GlobSync = globSync.GlobSync + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) -// old api surface -glob.glob = glob + setopts(this, pattern, options) -function extend (origin, add) { - if (add === null || typeof add !== 'object') { - return origin - } + if (this.noprocess) + return this - var keys = Object.keys(add) - var i = keys.length - while (i--) { - origin[keys[i]] = add[keys[i]] + var n = this.minimatch.set.length + this.matches = new Array(n) + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false) } - return origin + this._finish() } -glob.hasMagic = function (pattern, options_) { - var options = extend({}, options_) - options.noprocess = true - - var g = new Glob(pattern, options) - var set = g.minimatch.set +GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync) + if (this.realpath) { + var self = this + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null) + for (var p in matchset) { + try { + p = self._makeAbs(p) + var real = rp.realpathSync(p, self.realpathCache) + set[real] = true + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true + else + throw er + } + } + }) + } + common.finish(this) +} - if (!pattern) - return false - if (set.length > 1) - return true +GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync) - for (var j = 0; j < set[0].length; j++) { - if (typeof set[0][j] !== 'string') - return true + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ } + // now n is the index of the first one that is *not* a string. - return false -} + // See if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index) + return -glob.Glob = Glob -inherits(Glob, EE) -function Glob (pattern, options, cb) { - if (typeof options === 'function') { - cb = options - options = null - } + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break - if (options && options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return new GlobSync(pattern, options) + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break } - if (!(this instanceof Glob)) - return new Glob(pattern, options, cb) - - setopts(this, pattern, options) - this._didRealPath = false + var remain = pattern.slice(n) - // process each pattern in the minimatch set - var n = this.minimatch.set.length + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix - // The matches are stored as {: true,...} so that - // duplicates are automagically pruned. - // Later, we do an Object.keys() on these. - // Keep them as a list so we can fill in when nonull is set. - this.matches = new Array(n) + var abs = this._makeAbs(read) - if (typeof cb === 'function') { - cb = once(cb) - this.on('error', cb) - this.on('end', function (matches) { - cb(null, matches) - }) - } + //if ignored, skip processing + if (childrenIgnored(this, read)) + return - var self = this - this._processing = 0 + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar) +} - this._emitQueue = [] - this._processQueue = [] - this.paused = false - if (this.noprocess) - return this +GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar) - if (n === 0) - return done() + // if the abs isn't a dir, then nothing can match! + if (!entries) + return - var sync = true - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false, done) - } - sync = false + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' - function done () { - --self._processing - if (self._processing <= 0) { - if (sync) { - process.nextTick(function () { - self._finish() - }) + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) } else { - self._finish() + m = e.match(pn) } + if (m) + matchedEntries.push(e) } } -} -Glob.prototype._finish = function () { - assert(this instanceof Glob) - if (this.aborted) + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) return - if (this.realpath && !this._didRealpath) - return this._realpath() + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. - common.finish(this) - this.emit('end', this.found) + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) + newPattern = [prefix, e] + else + newPattern = [e] + this._process(newPattern.concat(remain), index, inGlobStar) + } } -Glob.prototype._realpath = function () { - if (this._didRealpath) + +GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) return - this._didRealpath = true + var abs = this._makeAbs(e) - var n = this.matches.length - if (n === 0) - return this._finish() + if (this.mark) + e = this._mark(e) - var self = this - for (var i = 0; i < this.matches.length; i++) - this._realpathSet(i, next) + if (this.absolute) { + e = abs + } - function next () { - if (--n === 0) - self._finish() + if (this.matches[index][e]) + return + + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return } + + this.matches[index][e] = true + + if (this.stat) + this._stat(e) } -Glob.prototype._realpathSet = function (index, cb) { - var matchset = this.matches[index] - if (!matchset) - return cb() - var found = Object.keys(matchset) - var self = this - var n = found.length +GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) - if (n === 0) - return cb() + var entries + var lstat + var stat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null + } + } - var set = this.matches[index] = Object.create(null) - found.forEach(function (p, i) { - // If there's a problem with the stat, then it means that - // one or more of the links in the realpath couldn't be - // resolved. just return the abs value in that case. - p = self._makeAbs(p) - rp.realpath(p, self.realpathCache, function (er, real) { - if (!er) - set[real] = true - else if (er.syscall === 'stat') - set[p] = true - else - self.emit('error', er) // srsly wtf right here + var isSym = lstat && lstat.isSymbolicLink() + this.symlinks[abs] = isSym - if (--n === 0) { - self.matches[index] = set - cb() - } - }) - }) -} + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) + this.cache[abs] = 'FILE' + else + entries = this._readdir(abs, false) -Glob.prototype._mark = function (p) { - return common.mark(this, p) + return entries } -Glob.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) -} +GlobSync.prototype._readdir = function (abs, inGlobStar) { + var entries -Glob.prototype.abort = function () { - this.aborted = true - this.emit('abort') -} + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) -Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true - this.emit('pause') + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return null + + if (Array.isArray(c)) + return c + } + + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er) + return null } } -Glob.prototype.resume = function () { - if (this.paused) { - this.emit('resume') - this.paused = false - if (this._emitQueue.length) { - var eq = this._emitQueue.slice(0) - this._emitQueue.length = 0 - for (var i = 0; i < eq.length; i ++) { - var e = eq[i] - this._emitMatch(e[0], e[1]) - } +GlobSync.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true } - if (this._processQueue.length) { - var pq = this._processQueue.slice(0) - this._processQueue.length = 0 - for (var i = 0; i < pq.length; i ++) { - var p = pq[i] - this._processing-- - this._process(p[0], p[1], p[2], p[3]) + } + + this.cache[abs] = entries + + // mark and cache dir-ness + return entries +} + +GlobSync.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + throw error } - } + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er) + break } } -Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob) - assert(typeof cb === 'function') +GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - if (this.aborted) - return + var entries = this._readdir(abs, inGlobStar) - this._processing++ - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]) + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) return - } - //console.error('PROCESS %d', this._processing, pattern) + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false) - // see if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index, cb) - return + var len = entries.length + var isSym = this.symlinks[abs] - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true) } +} - var remain = pattern.slice(n) +GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix) - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix + if (!this.matches[index]) + this.matches[index] = Object.create(null) - var abs = this._makeAbs(read) + // If it doesn't exist, then just mark the lack of results + if (!exists) + return - //if ignored, skip _processing - if (childrenIgnored(this, read)) - return cb() + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) -} + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') -Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) + // Mark this as a match + this._emitMatch(index, prefix) } -Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - - // if the abs isn't a dir, then nothing can match! - if (!entries) - return cb() +// Returns either 'DIR', 'FILE', or false +GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' + if (f.length > this.maxLength) + return false - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) - } else { - m = e.match(pn) - } - if (m) - matchedEntries.push(e) - } - } + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] - //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) + if (Array.isArray(c)) + c = 'DIR' - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return cb() + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. + if (needDir && c === 'FILE') + return false - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e + var exists + var stat = this.statCache[abs] + if (!stat) { + var lstat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return false } + } - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat } - this._emitMatch(index, e) + } else { + stat = lstat } - // This was the last one, and no stats were needed - return cb() } - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - this._process([e].concat(remain), index, inGlobStar, cb) - } - cb() -} + this.statCache[abs] = stat -Glob.prototype._emitMatch = function (index, e) { - if (this.aborted) - return + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' - if (isIgnored(this, e)) - return + this.cache[abs] = this.cache[abs] || c - if (this.paused) { - this._emitQueue.push([index, e]) - return - } + if (needDir && c === 'FILE') + return false - var abs = isAbsolute(e) ? e : this._makeAbs(e) + return c +} + +GlobSync.prototype._mark = function (p) { + return common.mark(this, p) +} - if (this.mark) - e = this._mark(e) +GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} - if (this.absolute) - e = abs - if (this.matches[index][e]) - return +/***/ }), - if (this.nodir) { - var c = this.cache[abs] - if (c === 'DIR' || Array.isArray(c)) - return - } +/***/ 8213: +/***/ ((__unused_webpack_module, exports) => { - this.matches[index][e] = true +"use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGNALS=void 0; - var st = this.statCache[abs] - if (st) - this.emit('stat', e, st) +const SIGNALS=[ +{ +name:"SIGHUP", +number:1, +action:"terminate", +description:"Terminal closed", +standard:"posix"}, - this.emit('match', e) -} +{ +name:"SIGINT", +number:2, +action:"terminate", +description:"User interruption with CTRL-C", +standard:"ansi"}, -Glob.prototype._readdirInGlobStar = function (abs, cb) { - if (this.aborted) - return +{ +name:"SIGQUIT", +number:3, +action:"core", +description:"User interruption with CTRL-\\", +standard:"posix"}, - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false, cb) +{ +name:"SIGILL", +number:4, +action:"core", +description:"Invalid machine instruction", +standard:"ansi"}, - var lstatkey = 'lstat\0' + abs - var self = this - var lstatcb = inflight(lstatkey, lstatcb_) +{ +name:"SIGTRAP", +number:5, +action:"core", +description:"Debugger breakpoint", +standard:"posix"}, - if (lstatcb) - fs.lstat(abs, lstatcb) +{ +name:"SIGABRT", +number:6, +action:"core", +description:"Aborted", +standard:"ansi"}, - function lstatcb_ (er, lstat) { - if (er && er.code === 'ENOENT') - return cb() +{ +name:"SIGIOT", +number:6, +action:"core", +description:"Aborted", +standard:"bsd"}, - var isSym = lstat && lstat.isSymbolicLink() - self.symlinks[abs] = isSym +{ +name:"SIGBUS", +number:7, +action:"core", +description: +"Bus error due to misaligned, non-existing address or paging error", +standard:"bsd"}, - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && lstat && !lstat.isDirectory()) { - self.cache[abs] = 'FILE' - cb() - } else - self._readdir(abs, false, cb) - } -} +{ +name:"SIGEMT", +number:7, +action:"terminate", +description:"Command should be emulated but is not implemented", +standard:"other"}, -Glob.prototype._readdir = function (abs, inGlobStar, cb) { - if (this.aborted) - return +{ +name:"SIGFPE", +number:8, +action:"core", +description:"Floating point arithmetic error", +standard:"ansi"}, - cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) - if (!cb) - return +{ +name:"SIGKILL", +number:9, +action:"terminate", +description:"Forced termination", +standard:"posix", +forced:true}, - //console.error('RD %j %j', +inGlobStar, abs) - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs, cb) +{ +name:"SIGUSR1", +number:10, +action:"terminate", +description:"Application-specific signal", +standard:"posix"}, - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return cb() +{ +name:"SIGSEGV", +number:11, +action:"core", +description:"Segmentation fault", +standard:"ansi"}, - if (Array.isArray(c)) - return cb(null, c) - } +{ +name:"SIGUSR2", +number:12, +action:"terminate", +description:"Application-specific signal", +standard:"posix"}, - var self = this - fs.readdir(abs, readdirCb(this, abs, cb)) -} +{ +name:"SIGPIPE", +number:13, +action:"terminate", +description:"Broken pipe or socket", +standard:"posix"}, -function readdirCb (self, abs, cb) { - return function (er, entries) { - if (er) - self._readdirError(abs, er, cb) - else - self._readdirEntries(abs, entries, cb) - } -} +{ +name:"SIGALRM", +number:14, +action:"terminate", +description:"Timeout or timer", +standard:"posix"}, -Glob.prototype._readdirEntries = function (abs, entries, cb) { - if (this.aborted) - return +{ +name:"SIGTERM", +number:15, +action:"terminate", +description:"Termination", +standard:"ansi"}, - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } +{ +name:"SIGSTKFLT", +number:16, +action:"terminate", +description:"Stack is empty or overflowed", +standard:"other"}, - this.cache[abs] = entries - return cb(null, entries) -} +{ +name:"SIGCHLD", +number:17, +action:"ignore", +description:"Child process terminated, paused or unpaused", +standard:"posix"}, -Glob.prototype._readdirError = function (f, er, cb) { - if (this.aborted) - return +{ +name:"SIGCLD", +number:17, +action:"ignore", +description:"Child process terminated, paused or unpaused", +standard:"other"}, - // handle errors, and cache the information - switch (er.code) { - case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 - case 'ENOTDIR': // totally normal. means it *does* exist. - var abs = this._makeAbs(f) - this.cache[abs] = 'FILE' - if (abs === this.cwdAbs) { - var error = new Error(er.code + ' invalid cwd ' + this.cwd) - error.path = this.cwd - error.code = er.code - this.emit('error', error) - this.abort() - } - break +{ +name:"SIGCONT", +number:18, +action:"unpause", +description:"Unpaused", +standard:"posix", +forced:true}, - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break +{ +name:"SIGSTOP", +number:19, +action:"pause", +description:"Paused", +standard:"posix", +forced:true}, - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) { - this.emit('error', er) - // If the error is handled, then we abort - // if not, we threw out of here - this.abort() - } - if (!this.silent) - console.error('glob error', er) - break - } +{ +name:"SIGTSTP", +number:20, +action:"pause", +description:"Paused using CTRL-Z or \"suspend\"", +standard:"posix"}, - return cb() -} +{ +name:"SIGTTIN", +number:21, +action:"pause", +description:"Background process cannot read terminal input", +standard:"posix"}, -Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) -} +{ +name:"SIGBREAK", +number:21, +action:"terminate", +description:"User interruption with CTRL-BREAK", +standard:"other"}, +{ +name:"SIGTTOU", +number:22, +action:"pause", +description:"Background process cannot write to terminal output", +standard:"posix"}, -Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - //console.error('pgs2', prefix, remain[0], entries) +{ +name:"SIGURG", +number:23, +action:"ignore", +description:"Socket received out-of-band data", +standard:"bsd"}, - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return cb() +{ +name:"SIGXCPU", +number:24, +action:"core", +description:"Process timed out", +standard:"bsd"}, - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) +{ +name:"SIGXFSZ", +number:25, +action:"core", +description:"File too big", +standard:"bsd"}, - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false, cb) +{ +name:"SIGVTALRM", +number:26, +action:"terminate", +description:"Timeout or timer", +standard:"bsd"}, - var isSym = this.symlinks[abs] - var len = entries.length +{ +name:"SIGPROF", +number:27, +action:"terminate", +description:"Timeout or timer", +standard:"bsd"}, - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return cb() +{ +name:"SIGWINCH", +number:28, +action:"ignore", +description:"Terminal window size changed", +standard:"bsd"}, - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue +{ +name:"SIGIO", +number:29, +action:"terminate", +description:"I/O is available", +standard:"other"}, - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true, cb) +{ +name:"SIGPOLL", +number:29, +action:"terminate", +description:"Watched event", +standard:"other"}, - var below = gspref.concat(entries[i], remain) - this._process(below, index, true, cb) - } +{ +name:"SIGINFO", +number:29, +action:"ignore", +description:"Request for process information", +standard:"other"}, - cb() -} +{ +name:"SIGPWR", +number:30, +action:"terminate", +description:"Device running out of power", +standard:"systemv"}, -Glob.prototype._processSimple = function (prefix, index, cb) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var self = this - this._stat(prefix, function (er, exists) { - self._processSimple2(prefix, index, er, exists, cb) - }) -} -Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { +{ +name:"SIGSYS", +number:31, +action:"core", +description:"Invalid system call", +standard:"other"}, - //console.error('ps2', prefix, exists) +{ +name:"SIGUNUSED", +number:31, +action:"terminate", +description:"Invalid system call", +standard:"other"}];exports.SIGNALS=SIGNALS; +//# sourceMappingURL=core.js.map - if (!this.matches[index]) - this.matches[index] = Object.create(null) +/***/ }), - // If it doesn't exist, then just mark the lack of results - if (!exists) - return cb() +/***/ 2779: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' - } - } +"use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.signalsByNumber=exports.signalsByName=void 0;var _os=__nccwpck_require__(2087); - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') +var _signals=__nccwpck_require__(6435); +var _realtime=__nccwpck_require__(5295); - // Mark this as a match - this._emitMatch(index, prefix) - cb() -} -// Returns either 'DIR', 'FILE', or false -Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' - if (f.length > this.maxLength) - return cb() +const getSignalsByName=function(){ +const signals=(0,_signals.getSignals)(); +return signals.reduce(getSignalByName,{}); +}; - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] +const getSignalByName=function( +signalByNameMemo, +{name,number,description,supported,action,forced,standard}) +{ +return{ +...signalByNameMemo, +[name]:{name,number,description,supported,action,forced,standard}}; - if (Array.isArray(c)) - c = 'DIR' +}; - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return cb(null, c) +const signalsByName=getSignalsByName();exports.signalsByName=signalsByName; - if (needDir && c === 'FILE') - return cb() - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - var exists - var stat = this.statCache[abs] - if (stat !== undefined) { - if (stat === false) - return cb(null, stat) - else { - var type = stat.isDirectory() ? 'DIR' : 'FILE' - if (needDir && type === 'FILE') - return cb() - else - return cb(null, type, stat) - } - } - var self = this - var statcb = inflight('stat\0' + abs, lstatcb_) - if (statcb) - fs.lstat(abs, statcb) +const getSignalsByNumber=function(){ +const signals=(0,_signals.getSignals)(); +const length=_realtime.SIGRTMAX+1; +const signalsA=Array.from({length},(value,number)=> +getSignalByNumber(number,signals)); - function lstatcb_ (er, lstat) { - if (lstat && lstat.isSymbolicLink()) { - // If it's a symlink, then treat it as the target, unless - // the target does not exist, then treat it as a file. - return fs.stat(abs, function (er, stat) { - if (er) - self._stat2(f, abs, null, lstat, cb) - else - self._stat2(f, abs, er, stat, cb) - }) - } else { - self._stat2(f, abs, er, lstat, cb) - } - } +return Object.assign({},...signalsA); +}; + +const getSignalByNumber=function(number,signals){ +const signal=findSignalByNumber(number,signals); + +if(signal===undefined){ +return{}; } -Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false - return cb() - } +const{name,description,supported,action,forced,standard}=signal; +return{ +[number]:{ +name, +number, +description, +supported, +action, +forced, +standard}}; - var needDir = f.slice(-1) === '/' - this.statCache[abs] = stat - if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) - return cb(null, false, stat) +}; - var c = true - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE' - this.cache[abs] = this.cache[abs] || c - if (needDir && c === 'FILE') - return cb() - return cb(null, c, stat) -} +const findSignalByNumber=function(number,signals){ +const signal=signals.find(({name})=>_os.constants.signals[name]===number); +if(signal!==undefined){ +return signal; +} -/***/ }), +return signals.find(signalA=>signalA.number===number); +}; -/***/ 9010: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber; +//# sourceMappingURL=main.js.map -module.exports = globSync -globSync.GlobSync = GlobSync +/***/ }), -var fs = __nccwpck_require__(5747) -var rp = __nccwpck_require__(6863) -var minimatch = __nccwpck_require__(3973) -var Minimatch = minimatch.Minimatch -var Glob = __nccwpck_require__(1957).Glob -var util = __nccwpck_require__(1669) -var path = __nccwpck_require__(5622) -var assert = __nccwpck_require__(2357) -var isAbsolute = __nccwpck_require__(8714) -var common = __nccwpck_require__(7625) -var setopts = common.setopts -var ownProp = common.ownProp -var childrenIgnored = common.childrenIgnored -var isIgnored = common.isIgnored +/***/ 5295: +/***/ ((__unused_webpack_module, exports) => { -function globSync (pattern, options) { - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') +"use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGRTMAX=exports.getRealtimeSignals=void 0; +const getRealtimeSignals=function(){ +const length=SIGRTMAX-SIGRTMIN+1; +return Array.from({length},getRealtimeSignal); +};exports.getRealtimeSignals=getRealtimeSignals; - return new GlobSync(pattern, options).found -} +const getRealtimeSignal=function(value,index){ +return{ +name:`SIGRT${index+1}`, +number:SIGRTMIN+index, +action:"terminate", +description:"Application-specific signal (realtime)", +standard:"posix"}; -function GlobSync (pattern, options) { - if (!pattern) - throw new Error('must provide pattern') +}; - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') +const SIGRTMIN=34; +const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; +//# sourceMappingURL=realtime.js.map - if (!(this instanceof GlobSync)) - return new GlobSync(pattern, options) +/***/ }), - setopts(this, pattern, options) +/***/ 6435: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - if (this.noprocess) - return this +"use strict"; +Object.defineProperty(exports, "__esModule", ({value:true}));exports.getSignals=void 0;var _os=__nccwpck_require__(2087); - var n = this.minimatch.set.length - this.matches = new Array(n) - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false) - } - this._finish() -} +var _core=__nccwpck_require__(8213); +var _realtime=__nccwpck_require__(5295); -GlobSync.prototype._finish = function () { - assert(this instanceof GlobSync) - if (this.realpath) { - var self = this - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null) - for (var p in matchset) { - try { - p = self._makeAbs(p) - var real = rp.realpathSync(p, self.realpathCache) - set[real] = true - } catch (er) { - if (er.syscall === 'stat') - set[self._makeAbs(p)] = true - else - throw er - } - } - }) - } - common.finish(this) -} -GlobSync.prototype._process = function (pattern, index, inGlobStar) { - assert(this instanceof GlobSync) +const getSignals=function(){ +const realtimeSignals=(0,_realtime.getRealtimeSignals)(); +const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal); +return signals; +};exports.getSignals=getSignals; - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. - // See if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index) - return - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break - } - var remain = pattern.slice(n) - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix - var abs = this._makeAbs(read) +const normalizeSignal=function({ +name, +number:defaultNumber, +description, +action, +forced=false, +standard}) +{ +const{ +signals:{[name]:constantSignal}}= +_os.constants; +const supported=constantSignal!==undefined; +const number=supported?constantSignal:defaultNumber; +return{name,number,description,supported,action,forced,standard}; +}; +//# sourceMappingURL=signals.js.map - //if ignored, skip processing - if (childrenIgnored(this, read)) - return +/***/ }), - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar) -} +/***/ 2492: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var wrappy = __nccwpck_require__(2940) +var reqs = Object.create(null) +var once = __nccwpck_require__(1223) -GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar) +module.exports = wrappy(inflight) - // if the abs isn't a dir, then nothing can match! - if (!entries) - return +function inflight (key, cb) { + if (reqs[key]) { + reqs[key].push(cb) + return null + } else { + reqs[key] = [cb] + return makeres(key) + } +} - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' +function makeres (key) { + return once(function RES () { + var cbs = reqs[key] + var len = cbs.length + var args = slice(arguments) - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) + // XXX It's somewhat ambiguous whether a new callback added in this + // pass should be queued for later execution if something in the + // list of callbacks throws, or if it should just be discarded. + // However, it's such an edge case that it hardly matters, and either + // choice is likely as surprising as the other. + // As it happens, we do go ahead and schedule it for later execution. + try { + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args) + } + } finally { + if (cbs.length > len) { + // added more in the interim. + // de-zalgo, just in case, but don't call again. + cbs.splice(0, len) + process.nextTick(function () { + RES.apply(null, args) + }) } else { - m = e.match(pn) + delete reqs[key] } - if (m) - matchedEntries.push(e) } - } + }) +} - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return +function slice (args) { + var length = args.length + var array = [] - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. + for (var i = 0; i < length; i++) array[i] = args[i] + return array +} - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix.slice(-1) !== '/') - e = prefix + '/' + e - else - e = prefix + e - } +/***/ }), - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) - } - this._emitMatch(index, e) - } - // This was the last one, and no stats were needed - return - } +/***/ 4124: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) - newPattern = [prefix, e] - else - newPattern = [e] - this._process(newPattern.concat(remain), index, inGlobStar) - } +try { + var util = __nccwpck_require__(1669); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + /* istanbul ignore next */ + module.exports = __nccwpck_require__(8544); } -GlobSync.prototype._emitMatch = function (index, e) { - if (isIgnored(this, e)) - return - - var abs = this._makeAbs(e) +/***/ }), - if (this.mark) - e = this._mark(e) +/***/ 8544: +/***/ ((module) => { - if (this.absolute) { - e = abs +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } +} - if (this.matches[index][e]) - return - if (this.nodir) { - var c = this.cache[abs] - if (c === 'DIR' || Array.isArray(c)) - return - } +/***/ }), - this.matches[index][e] = true +/***/ 1554: +/***/ ((module) => { - if (this.stat) - this._stat(e) -} +"use strict"; -GlobSync.prototype._readdirInGlobStar = function (abs) { - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false) +const isStream = stream => + stream !== null && + typeof stream === 'object' && + typeof stream.pipe === 'function'; - var entries - var lstat - var stat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - if (er.code === 'ENOENT') { - // lstat failed, doesn't exist - return null - } - } +isStream.writable = stream => + isStream(stream) && + stream.writable !== false && + typeof stream._write === 'function' && + typeof stream._writableState === 'object'; - var isSym = lstat && lstat.isSymbolicLink() - this.symlinks[abs] = isSym +isStream.readable = stream => + isStream(stream) && + stream.readable !== false && + typeof stream._read === 'function' && + typeof stream._readableState === 'object'; - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && lstat && !lstat.isDirectory()) - this.cache[abs] = 'FILE' - else - entries = this._readdir(abs, false) +isStream.duplex = stream => + isStream.writable(stream) && + isStream.readable(stream); - return entries -} +isStream.transform = stream => + isStream.duplex(stream) && + typeof stream._transform === 'function' && + typeof stream._transformState === 'object'; -GlobSync.prototype._readdir = function (abs, inGlobStar) { - var entries +module.exports = isStream; - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs) - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return null +/***/ }), - if (Array.isArray(c)) - return c - } +/***/ 7126: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - try { - return this._readdirEntries(abs, fs.readdirSync(abs)) - } catch (er) { - this._readdirError(abs, er) - return null - } +var fs = __nccwpck_require__(5747) +var core +if (process.platform === 'win32' || global.TESTING_WINDOWS) { + core = __nccwpck_require__(2001) +} else { + core = __nccwpck_require__(9728) } -GlobSync.prototype._readdirEntries = function (abs, entries) { - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } - - this.cache[abs] = entries - - // mark and cache dir-ness - return entries -} +module.exports = isexe +isexe.sync = sync -GlobSync.prototype._readdirError = function (f, er) { - // handle errors, and cache the information - switch (er.code) { - case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 - case 'ENOTDIR': // totally normal. means it *does* exist. - var abs = this._makeAbs(f) - this.cache[abs] = 'FILE' - if (abs === this.cwdAbs) { - var error = new Error(er.code + ' invalid cwd ' + this.cwd) - error.path = this.cwd - error.code = er.code - throw error - } - break +function isexe (path, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break + if (!cb) { + if (typeof Promise !== 'function') { + throw new TypeError('callback not provided') + } - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) - throw er - if (!this.silent) - console.error('glob error', er) - break + return new Promise(function (resolve, reject) { + isexe(path, options || {}, function (er, is) { + if (er) { + reject(er) + } else { + resolve(is) + } + }) + }) } -} - -GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar) + core(path, options || {}, function (er, is) { + // ignore EACCES because that just means we aren't allowed to run it + if (er) { + if (er.code === 'EACCES' || options && options.ignoreErrors) { + er = null + is = false + } + } + cb(er, is) + }) +} - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return +function sync (path, options) { + // my kingdom for a filtered catch + try { + return core.sync(path, options || {}) + } catch (er) { + if (options && options.ignoreErrors || er.code === 'EACCES') { + return false + } else { + throw er + } + } +} - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false) +/***/ }), - var len = entries.length - var isSym = this.symlinks[abs] +/***/ 9728: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return +module.exports = isexe +isexe.sync = sync - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue +var fs = __nccwpck_require__(5747) - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true) +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, options)) + }) +} - var below = gspref.concat(entries[i], remain) - this._process(below, index, true) - } +function sync (path, options) { + return checkStat(fs.statSync(path), options) } -GlobSync.prototype._processSimple = function (prefix, index) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var exists = this._stat(prefix) +function checkStat (stat, options) { + return stat.isFile() && checkMode(stat, options) +} - if (!this.matches[index]) - this.matches[index] = Object.create(null) +function checkMode (stat, options) { + var mod = stat.mode + var uid = stat.uid + var gid = stat.gid - // If it doesn't exist, then just mark the lack of results - if (!exists) - return + var myUid = options.uid !== undefined ? + options.uid : process.getuid && process.getuid() + var myGid = options.gid !== undefined ? + options.gid : process.getgid && process.getgid() - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' - } - } + var u = parseInt('100', 8) + var g = parseInt('010', 8) + var o = parseInt('001', 8) + var ug = u | g - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') + var ret = (mod & o) || + (mod & g) && gid === myGid || + (mod & u) && uid === myUid || + (mod & ug) && myUid === 0 - // Mark this as a match - this._emitMatch(index, prefix) + return ret } -// Returns either 'DIR', 'FILE', or false -GlobSync.prototype._stat = function (f) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' - if (f.length > this.maxLength) - return false +/***/ }), - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] +/***/ 2001: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (Array.isArray(c)) - c = 'DIR' +module.exports = isexe +isexe.sync = sync - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return c +var fs = __nccwpck_require__(5747) - if (needDir && c === 'FILE') - return false +function checkPathExt (path, options) { + var pathext = options.pathExt !== undefined ? + options.pathExt : process.env.PATHEXT - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. + if (!pathext) { + return true } - var exists - var stat = this.statCache[abs] - if (!stat) { - var lstat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false - return false - } - } - - if (lstat && lstat.isSymbolicLink()) { - try { - stat = fs.statSync(abs) - } catch (er) { - stat = lstat - } - } else { - stat = lstat + pathext = pathext.split(';') + if (pathext.indexOf('') !== -1) { + return true + } + for (var i = 0; i < pathext.length; i++) { + var p = pathext[i].toLowerCase() + if (p && path.substr(-p.length).toLowerCase() === p) { + return true } } + return false +} - this.statCache[abs] = stat - - var c = true - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE' - - this.cache[abs] = this.cache[abs] || c - - if (needDir && c === 'FILE') +function checkStat (stat, path, options) { + if (!stat.isSymbolicLink() && !stat.isFile()) { return false - - return c + } + return checkPathExt(path, options) } -GlobSync.prototype._mark = function (p) { - return common.mark(this, p) +function isexe (path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, path, options)) + }) } -GlobSync.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) +function sync (path, options) { + return checkStat(fs.statSync(path), path, options) } /***/ }), -/***/ 8213: -/***/ ((__unused_webpack_module, exports) => { +/***/ 7129: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGNALS=void 0; -const SIGNALS=[ -{ -name:"SIGHUP", -number:1, -action:"terminate", -description:"Terminal closed", -standard:"posix"}, -{ -name:"SIGINT", -number:2, -action:"terminate", -description:"User interruption with CTRL-C", -standard:"ansi"}, +// 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') -{ -name:"SIGQUIT", -number:3, -action:"core", -description:"User interruption with CTRL-\\", -standard:"posix"}, + this[MAX] = mL || Infinity + trim(this) + } + get max () { + return this[MAX] + } -{ -name:"SIGILL", -number:4, -action:"core", -description:"Invalid machine instruction", -standard:"ansi"}, + set allowStale (allowStale) { + this[ALLOW_STALE] = !!allowStale + } + get allowStale () { + return this[ALLOW_STALE] + } -{ -name:"SIGTRAP", -number:5, -action:"core", -description:"Debugger breakpoint", -standard:"posix"}, + set maxAge (mA) { + if (typeof mA !== 'number') + throw new TypeError('maxAge must be a non-negative number') -{ -name:"SIGABRT", -number:6, -action:"core", -description:"Aborted", -standard:"ansi"}, + this[MAX_AGE] = mA + trim(this) + } + get maxAge () { + return this[MAX_AGE] + } -{ -name:"SIGIOT", -number:6, -action:"core", -description:"Aborted", -standard:"bsd"}, + // resize the cache when the lengthCalculator changes. + set lengthCalculator (lC) { + if (typeof lC !== 'function') + lC = naiveLength -{ -name:"SIGBUS", -number:7, -action:"core", -description: -"Bus error due to misaligned, non-existing address or paging error", -standard:"bsd"}, + 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] } -{ -name:"SIGEMT", -number:7, -action:"terminate", -description:"Command should be emulated but is not implemented", -standard:"other"}, + get length () { return this[LENGTH] } + get itemCount () { return this[LRU_LIST].length } -{ -name:"SIGFPE", -number:8, -action:"core", -description:"Floating point arithmetic error", -standard:"ansi"}, + 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 + } + } -{ -name:"SIGKILL", -number:9, -action:"terminate", -description:"Forced termination", -standard:"posix", -forced:true}, + 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 + } + } -{ -name:"SIGUSR1", -number:10, -action:"terminate", -description:"Application-specific signal", -standard:"posix"}, + keys () { + return this[LRU_LIST].toArray().map(k => k.key) + } -{ -name:"SIGSEGV", -number:11, -action:"core", -description:"Segmentation fault", -standard:"ansi"}, + values () { + return this[LRU_LIST].toArray().map(k => k.value) + } -{ -name:"SIGUSR2", -number:12, -action:"terminate", -description:"Application-specific signal", -standard:"posix"}, + reset () { + if (this[DISPOSE] && + this[LRU_LIST] && + this[LRU_LIST].length) { + this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) + } -{ -name:"SIGPIPE", -number:13, -action:"terminate", -description:"Broken pipe or socket", -standard:"posix"}, + 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 + } -{ -name:"SIGALRM", -number:14, -action:"terminate", -description:"Timeout or timer", -standard:"posix"}, + 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) + } -{ -name:"SIGTERM", -number:15, -action:"terminate", -description:"Termination", -standard:"ansi"}, + dumpLru () { + return this[LRU_LIST] + } -{ -name:"SIGSTKFLT", -number:16, -action:"terminate", -description:"Stack is empty or overflowed", -standard:"other"}, + set (key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE] -{ -name:"SIGCHLD", -number:17, -action:"ignore", -description:"Child process terminated, paused or unpaused", -standard:"posix"}, + if (maxAge && typeof maxAge !== 'number') + throw new TypeError('maxAge must be a number') -{ -name:"SIGCLD", -number:17, -action:"ignore", -description:"Child process terminated, paused or unpaused", -standard:"other"}, + const now = maxAge ? Date.now() : 0 + const len = this[LENGTH_CALCULATOR](value, key) -{ -name:"SIGCONT", -number:18, -action:"unpause", -description:"Unpaused", -standard:"posix", -forced:true}, + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)) + return false + } -{ -name:"SIGSTOP", -number:19, -action:"pause", -description:"Paused", -standard:"posix", -forced:true}, + const node = this[CACHE].get(key) + const item = node.value -{ -name:"SIGTSTP", -number:20, -action:"pause", -description:"Paused using CTRL-Z or \"suspend\"", -standard:"posix"}, + // 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) + } -{ -name:"SIGTTIN", -number:21, -action:"pause", -description:"Background process cannot read terminal input", -standard:"posix"}, + item.now = now + item.maxAge = maxAge + item.value = value + this[LENGTH] += len - item.length + item.length = len + this.get(key) + trim(this) + return true + } -{ -name:"SIGBREAK", -number:21, -action:"terminate", -description:"User interruption with CTRL-BREAK", -standard:"other"}, + const hit = new Entry(key, value, len, now, maxAge) -{ -name:"SIGTTOU", -number:22, -action:"pause", -description:"Background process cannot write to terminal output", -standard:"posix"}, + // oversized objects fall out of cache automatically. + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value) -{ -name:"SIGURG", -number:23, -action:"ignore", -description:"Socket received out-of-band data", -standard:"bsd"}, + return false + } -{ -name:"SIGXCPU", -number:24, -action:"core", -description:"Process timed out", -standard:"bsd"}, + this[LENGTH] += hit.length + this[LRU_LIST].unshift(hit) + this[CACHE].set(key, this[LRU_LIST].head) + trim(this) + return true + } -{ -name:"SIGXFSZ", -number:25, -action:"core", -description:"File too big", -standard:"bsd"}, + has (key) { + if (!this[CACHE].has(key)) return false + const hit = this[CACHE].get(key).value + return !isStale(this, hit) + } -{ -name:"SIGVTALRM", -number:26, -action:"terminate", -description:"Timeout or timer", -standard:"bsd"}, + get (key) { + return get(this, key, true) + } -{ -name:"SIGPROF", -number:27, -action:"terminate", -description:"Timeout or timer", -standard:"bsd"}, + peek (key) { + return get(this, key, false) + } -{ -name:"SIGWINCH", -number:28, -action:"ignore", -description:"Terminal window size changed", -standard:"bsd"}, + pop () { + const node = this[LRU_LIST].tail + if (!node) + return null -{ -name:"SIGIO", -number:29, -action:"terminate", -description:"I/O is available", -standard:"other"}, + del(this, node) + return node.value + } -{ -name:"SIGPOLL", -number:29, -action:"terminate", -description:"Watched event", -standard:"other"}, + del (key) { + del(this, this[CACHE].get(key)) + } -{ -name:"SIGINFO", -number:29, -action:"ignore", -description:"Request for process information", -standard:"other"}, + load (arr) { + // reset the cache + this.reset() -{ -name:"SIGPWR", -number:30, -action:"terminate", -description:"Device running out of power", -standard:"systemv"}, + 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) + } + } + } + } -{ -name:"SIGSYS", -number:31, -action:"core", -description:"Invalid system call", -standard:"other"}, + prune () { + this[CACHE].forEach((value, key) => get(this, key, false)) + } +} -{ -name:"SIGUNUSED", -number:31, -action:"terminate", -description:"Invalid system call", -standard:"other"}];exports.SIGNALS=SIGNALS; -//# sourceMappingURL=core.js.map +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 -/***/ 2779: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + const diff = Date.now() - hit.now + return hit.maxAge ? diff > hit.maxAge + : self[MAX_AGE] && (diff > self[MAX_AGE]) +} -"use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.signalsByNumber=exports.signalsByName=void 0;var _os=__nccwpck_require__(2087); +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 + } + } +} -var _signals=__nccwpck_require__(6435); -var _realtime=__nccwpck_require__(5295); +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 getSignalsByName=function(){ -const signals=(0,_signals.getSignals)(); -return signals.reduce(getSignalByName,{}); -}; +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) +} -const getSignalByName=function( -signalByNameMemo, -{name,number,description,supported,action,forced,standard}) -{ -return{ -...signalByNameMemo, -[name]:{name,number,description,supported,action,forced,standard}}; +module.exports = LRUCache -}; -const signalsByName=getSignalsByName();exports.signalsByName=signalsByName; +/***/ }), +/***/ 2621: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +"use strict"; -const getSignalsByNumber=function(){ -const signals=(0,_signals.getSignals)(); -const length=_realtime.SIGRTMAX+1; -const signalsA=Array.from({length},(value,number)=> -getSignalByNumber(number,signals)); +const { PassThrough } = __nccwpck_require__(2413); -return Object.assign({},...signalsA); -}; +module.exports = function (/*streams...*/) { + var sources = [] + var output = new PassThrough({objectMode: true}) -const getSignalByNumber=function(number,signals){ -const signal=findSignalByNumber(number,signals); + output.setMaxListeners(0) -if(signal===undefined){ -return{}; -} + output.add = add + output.isEmpty = isEmpty -const{name,description,supported,action,forced,standard}=signal; -return{ -[number]:{ -name, -number, -description, -supported, -action, -forced, -standard}}; + output.on('unpipe', remove) + Array.prototype.slice.call(arguments).forEach(add) -}; + return output + function add (source) { + if (Array.isArray(source)) { + source.forEach(add) + return this + } + sources.push(source); + source.once('end', remove.bind(null, source)) + source.once('error', output.emit.bind(output, 'error')) + source.pipe(output, {end: false}) + return this + } -const findSignalByNumber=function(number,signals){ -const signal=signals.find(({name})=>_os.constants.signals[name]===number); + function isEmpty () { + return sources.length == 0; + } -if(signal!==undefined){ -return signal; + function remove (source) { + sources = sources.filter(function (it) { return it !== source }) + if (!sources.length && output.readable) { output.end() } + } } -return signals.find(signalA=>signalA.number===number); -}; - -const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber; -//# sourceMappingURL=main.js.map /***/ }), -/***/ 5295: -/***/ ((__unused_webpack_module, exports) => { +/***/ 6047: +/***/ ((module) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.SIGRTMAX=exports.getRealtimeSignals=void 0; -const getRealtimeSignals=function(){ -const length=SIGRTMAX-SIGRTMIN+1; -return Array.from({length},getRealtimeSignal); -};exports.getRealtimeSignals=getRealtimeSignals; -const getRealtimeSignal=function(value,index){ -return{ -name:`SIGRT${index+1}`, -number:SIGRTMIN+index, -action:"terminate", -description:"Application-specific signal (realtime)", -standard:"posix"}; +const mimicFn = (to, from) => { + for (const prop of Reflect.ownKeys(from)) { + Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); + } + + return to; }; -const SIGRTMIN=34; -const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; -//# sourceMappingURL=realtime.js.map +module.exports = mimicFn; +// TODO: Remove this for the next major release +module.exports.default = mimicFn; + /***/ }), -/***/ 6435: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 3973: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; -Object.defineProperty(exports, "__esModule", ({value:true}));exports.getSignals=void 0;var _os=__nccwpck_require__(2087); +module.exports = minimatch +minimatch.Minimatch = Minimatch -var _core=__nccwpck_require__(8213); -var _realtime=__nccwpck_require__(5295); +var path = { sep: '/' } +try { + path = __nccwpck_require__(5622) +} catch (er) {} +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = __nccwpck_require__(3717) +var plTypes = { + '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, + '?': { open: '(?:', close: ')?' }, + '+': { open: '(?:', close: ')+' }, + '*': { open: '(?:', close: ')*' }, + '@': { open: '(?:', close: ')' } +} -const getSignals=function(){ -const realtimeSignals=(0,_realtime.getRealtimeSignals)(); -const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal); -return signals; -};exports.getSignals=getSignals; +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' +// * => any number of characters +var star = qmark + '*?' +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true + return set + }, {}) +} +// normalizes slashes. +var slashSplit = /\/+/ -const normalizeSignal=function({ -name, -number:defaultNumber, -description, -action, -forced=false, -standard}) -{ -const{ -signals:{[name]:constantSignal}}= -_os.constants; -const supported=constantSignal!==undefined; -const number=supported?constantSignal:defaultNumber; -return{name,number,description,supported,action,forced,standard}; -}; -//# sourceMappingURL=signals.js.map +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} -/***/ }), +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} -/***/ 2492: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch -var wrappy = __nccwpck_require__(2940) -var reqs = Object.create(null) -var once = __nccwpck_require__(1223) + var orig = minimatch -module.exports = wrappy(inflight) + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } -function inflight (key, cb) { - if (reqs[key]) { - reqs[key].push(cb) - return null - } else { - reqs[key] = [cb] - return makeres(key) + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) } -} -function makeres (key) { - return once(function RES () { - var cbs = reqs[key] - var len = cbs.length - var args = slice(arguments) + return m +} - // XXX It's somewhat ambiguous whether a new callback added in this - // pass should be queued for later execution if something in the - // list of callbacks throws, or if it should just be discarded. - // However, it's such an edge case that it hardly matters, and either - // choice is likely as surprising as the other. - // As it happens, we do go ahead and schedule it for later execution. - try { - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args) - } - } finally { - if (cbs.length > len) { - // added more in the interim. - // de-zalgo, just in case, but don't call again. - cbs.splice(0, len) - process.nextTick(function () { - RES.apply(null, args) - }) - } else { - delete reqs[key] - } - } - }) +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch } -function slice (args) { - var length = args.length - var array = [] +function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } - for (var i = 0; i < length; i++) array[i] = args[i] - return array + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) } +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } -/***/ }), + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } -/***/ 4124: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (!options) options = {} + pattern = pattern.trim() + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') + } + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false -try { - var util = __nccwpck_require__(1669); - /* istanbul ignore next */ - if (typeof util.inherits !== 'function') throw ''; - module.exports = util.inherits; -} catch (e) { - /* istanbul ignore next */ - module.exports = __nccwpck_require__(8544); + // make the set of regexps etc. + this.make() } +Minimatch.prototype.debug = function () {} -/***/ }), +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return -/***/ 8544: -/***/ ((module) => { + var pattern = this.pattern + var options = this.options -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }) - } - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return } -} + // step 1: figure out negation, etc. + this.parseNegate() -/***/ }), + // step 2: expand braces + var set = this.globSet = this.braceExpand() -/***/ 1554: -/***/ ((module) => { + if (options.debug) this.debug = console.error -"use strict"; + this.debug(this.pattern, set) + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) -const isStream = stream => - stream !== null && - typeof stream === 'object' && - typeof stream.pipe === 'function'; + this.debug(this.pattern, set) -isStream.writable = stream => - isStream(stream) && - stream.writable !== false && - typeof stream._write === 'function' && - typeof stream._writableState === 'object'; + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) -isStream.readable = stream => - isStream(stream) && - stream.readable !== false && - typeof stream._read === 'function' && - typeof stream._readableState === 'object'; + this.debug(this.pattern, set) -isStream.duplex = stream => - isStream.writable(stream) && - isStream.readable(stream); + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }) -isStream.transform = stream => - isStream.duplex(stream) && - typeof stream._transform === 'function' && - typeof stream._transformState === 'object'; + this.debug(this.pattern, set) -module.exports = isStream; + this.set = set +} +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var negateOffset = 0 -/***/ }), + if (options.nonegate) return -/***/ 7126: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate + negateOffset++ + } -var fs = __nccwpck_require__(5747) -var core -if (process.platform === 'win32' || global.TESTING_WINDOWS) { - core = __nccwpck_require__(2001) -} else { - core = __nccwpck_require__(9728) + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate } -module.exports = isexe -isexe.sync = sync +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +} -function isexe (path, options, cb) { - if (typeof options === 'function') { - cb = options - options = {} - } +Minimatch.prototype.braceExpand = braceExpand - if (!cb) { - if (typeof Promise !== 'function') { - throw new TypeError('callback not provided') +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} } + } - return new Promise(function (resolve, reject) { - isexe(path, options || {}, function (er, is) { - if (er) { - reject(er) - } else { - resolve(is) - } - }) - }) + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern + + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern') } - core(path, options || {}, function (er, is) { - // ignore EACCES because that just means we aren't allowed to run it - if (er) { - if (er.code === 'EACCES' || options && options.ignoreErrors) { - er = null - is = false - } - } - cb(er, is) - }) + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) } -function sync (path, options) { - // my kingdom for a filtered catch - try { - return core.sync(path, options || {}) - } catch (er) { - if (options && options.ignoreErrors || er.code === 'EACCES') { - return false - } else { - throw er +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long') + } + + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star + hasMagic = true + break + case '?': + re += qmark + hasMagic = true + break + default: + re += '\\' + stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false } } -} + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) -/***/ }), + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c + escaping = false + continue + } -/***/ 9728: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false -module.exports = isexe -isexe.sync = sync + case '\\': + clearStateChar() + escaping = true + continue -var fs = __nccwpck_require__(5747) + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) -function isexe (path, options, cb) { - fs.stat(path, function (er, stat) { - cb(er, er ? false : checkStat(stat, options)) - }) -} + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === '!' && i === classStart + 1) c = '^' + re += c + continue + } -function sync (path, options) { - return checkStat(fs.statSync(path), options) -} + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue -function checkStat (stat, options) { - return stat.isFile() && checkMode(stat, options) -} + case '(': + if (inClass) { + re += '(' + continue + } -function checkMode (stat, options) { - var mod = stat.mode - var uid = stat.uid - var gid = stat.gid + if (!stateChar) { + re += '\\(' + continue + } - var myUid = options.uid !== undefined ? - options.uid : process.getuid && process.getuid() - var myGid = options.gid !== undefined ? - options.gid : process.getgid && process.getgid() + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + }) + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue - var u = parseInt('100', 8) - var g = parseInt('010', 8) - var o = parseInt('001', 8) - var ug = u | g + case ')': + if (inClass || !patternListStack.length) { + re += '\\)' + continue + } - var ret = (mod & o) || - (mod & g) && gid === myGid || - (mod & u) && uid === myUid || - (mod & ug) && myUid === 0 + clearStateChar() + hasMagic = true + var pl = patternListStack.pop() + // negation is (?:(?!js)[^/]*) + // The others are (?:) + re += pl.close + if (pl.type === '!') { + negativeLists.push(pl) + } + pl.reEnd = re.length + continue - return ret -} + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|' + escaping = false + continue + } + clearStateChar() + re += '|' + continue -/***/ }), + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar() -/***/ 2001: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (inClass) { + re += '\\' + c + continue + } -module.exports = isexe -isexe.sync = sync + inClass = true + classStart = i + reClassStart = re.length + re += c + continue -var fs = __nccwpck_require__(5747) + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c + escaping = false + continue + } -function checkPathExt (path, options) { - var pathext = options.pathExt !== undefined ? - options.pathExt : process.env.PATHEXT + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } - if (!pathext) { - return true - } + // finish up the class. + hasMagic = true + inClass = false + re += c + continue - pathext = pathext.split(';') - if (pathext.indexOf('') !== -1) { - return true - } - for (var i = 0; i < pathext.length; i++) { - var p = pathext[i].toLowerCase() - if (p && path.substr(-p.length).toLowerCase() === p) { - return true - } - } - return false -} + default: + // swallow any state char that wasn't consumed + clearStateChar() -function checkStat (stat, path, options) { - if (!stat.isSymbolicLink() && !stat.isFile()) { - return false - } - return checkPathExt(path, options) -} + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\' + } -function isexe (path, options, cb) { - fs.stat(path, function (er, stat) { - cb(er, er ? false : checkStat(stat, path, options)) - }) -} + re += c -function sync (path, options) { - return checkStat(fs.statSync(path), path, options) -} + } // switch + } // for + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + hasMagic = hasMagic || sp[1] + } -/***/ }), + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length) + this.debug('setting tail', re, pl) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\' + } -/***/ 7129: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }) -"use strict"; + this.debug('tail=%j\n %s', tail, tail, pl, re) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type + hasMagic = true + re = re.slice(0, pl.reStart) + t + '\\(' + tail + } -// A linked list to keep track of recently-used-ness -const Yallist = __nccwpck_require__(665) + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += '\\\\' + } -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') + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true + } -const naiveLength = () => 1 + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] -// 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 } + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) - if (!options) - options = {} + nlLast += nlAfter - 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 + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter - 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() + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe } - // 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') + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } - this[MAX] = mL || Infinity - trim(this) + if (addPatternStart) { + re = patternStart + re } - get max () { - return this[MAX] + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] } - set allowStale (allowStale) { - this[ALLOW_STALE] = !!allowStale + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) } - get allowStale () { - return this[ALLOW_STALE] + + var flags = options.nocase ? 'i' : '' + try { + var regExp = new RegExp('^' + re + '$', flags) + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.') } - set maxAge (mA) { - if (typeof mA !== 'number') - throw new TypeError('maxAge must be a non-negative number') + regExp._glob = pattern + regExp._src = re - this[MAX_AGE] = mA - trim(this) - } - get maxAge () { - return this[MAX_AGE] - } + return regExp +} - // resize the cache when the lengthCalculator changes. - set lengthCalculator (lC) { - if (typeof lC !== 'function') - lC = naiveLength +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} - 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] } +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp - get length () { return this[LENGTH] } - get itemCount () { return this[LRU_LIST].length } + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set - 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 - } + if (!set.length) { + this.regexp = false + return this.regexp } + var options = this.options - 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 - } - } + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' - keys () { - return this[LRU_LIST].toArray().map(k => k.key) - } + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') - values () { - return this[LRU_LIST].toArray().map(k => k.value) - } + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$' - reset () { - if (this[DISPOSE] && - this[LRU_LIST] && - this[LRU_LIST].length) { - this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) - } + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$' - 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 + try { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) } + return 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) - } +Minimatch.prototype.match = match +function match (f, partial) { + this.debug('match', f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' - dumpLru () { - return this[LRU_LIST] - } + if (f === '/' && partial) return true - set (key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE] + var options = this.options - if (maxAge && typeof maxAge !== 'number') - throw new TypeError('maxAge must be a number') + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/') + } - const now = maxAge ? Date.now() : 0 - const len = this[LENGTH_CALCULATOR](value, key) + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, 'split', f) - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)) - return false - } + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. - const node = this[CACHE].get(key) - const item = node.value + var set = this.set + this.debug(this.pattern, 'set', set) - // 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) - } + // Find the basename of the path by looking for the last non-empty segment + var filename + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } - item.now = now - item.maxAge = maxAge - item.value = value - this[LENGTH] += len - item.length - item.length = len - this.get(key) - trim(this) - return true + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate } + } - const hit = new Entry(key, value, len, now, maxAge) + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} - // oversized objects fall out of cache automatically. - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value) +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options - return false - } + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) - this[LENGTH] += hit.length - this[LRU_LIST].unshift(hit) - this[CACHE].set(key, this[LRU_LIST].head) - trim(this) - return true - } + this.debug('matchOne', file.length, pattern.length) - has (key) { - if (!this[CACHE].has(key)) return false - const hit = this[CACHE].get(key).value - return !isStale(this, hit) - } + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop') + var p = pattern[pi] + var f = file[fi] - get (key) { - return get(this, key, true) - } + this.debug(pattern, p, f) - peek (key) { - return get(this, key, false) - } + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false - pop () { - const node = this[LRU_LIST].tail - if (!node) - return null + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) - del(this, node) - return node.value - } + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + var pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } - del (key) { - del(this, this[CACHE].get(key)) - } + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr] - load (arr) { - // reset the cache - this.reset() + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) - 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) + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr++ } } - } - } - prune () { - this[CACHE].forEach((value, key) => get(this, key, false)) - } -} + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + if (fr === fl) return true + } + return 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) + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p } + this.debug('string match', p, f, hit) + } else { + hit = f.match(p) + this.debug('pattern match', p, f, hit) } - 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 - } + if (!hit) return false } -} -const del = (self, node) => { - if (node) { - const hit = node.value - if (self[DISPOSE]) - self[DISPOSE](hit.key, hit.value) + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* - self[LENGTH] -= hit.length - self[CACHE].delete(hit.key) - self[LRU_LIST].removeNode(node) + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + return emptyFileEnd } -} -class Entry { - constructor (key, value, length, now, maxAge) { - this.key = key - this.value = value - this.length = length - this.now = now - this.maxAge = maxAge || 0 - } + // should be unreachable. + throw new Error('wtf?') } -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) +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') } -module.exports = LRUCache +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} /***/ }), -/***/ 2621: +/***/ 502: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +const path = __nccwpck_require__(5622); +const pathKey = __nccwpck_require__(539); -const { PassThrough } = __nccwpck_require__(2413); - -module.exports = function (/*streams...*/) { - var sources = [] - var output = new PassThrough({objectMode: true}) - - output.setMaxListeners(0) - - output.add = add - output.isEmpty = isEmpty - - output.on('unpipe', remove) - - Array.prototype.slice.call(arguments).forEach(add) - - return output - - function add (source) { - if (Array.isArray(source)) { - source.forEach(add) - return this - } - - sources.push(source); - source.once('end', remove.bind(null, source)) - source.once('error', output.emit.bind(output, 'error')) - source.pipe(output, {end: false}) - return this - } +const npmRunPath = options => { + options = { + cwd: process.cwd(), + path: process.env[pathKey()], + execPath: process.execPath, + ...options + }; - function isEmpty () { - return sources.length == 0; - } + let previous; + let cwdPath = path.resolve(options.cwd); + const result = []; - function remove (source) { - sources = sources.filter(function (it) { return it !== source }) - if (!sources.length && output.readable) { output.end() } - } -} + while (previous !== cwdPath) { + result.push(path.join(cwdPath, 'node_modules/.bin')); + previous = cwdPath; + cwdPath = path.resolve(cwdPath, '..'); + } + // Ensure the running `node` binary is used + const execPathDir = path.resolve(options.cwd, options.execPath, '..'); + result.push(execPathDir); -/***/ }), + return result.concat(options.path).join(path.delimiter); +}; -/***/ 6047: -/***/ ((module) => { +module.exports = npmRunPath; +// TODO: Remove this for the next major release +module.exports.default = npmRunPath; -"use strict"; +module.exports.env = options => { + options = { + env: process.env, + ...options + }; + const env = {...options.env}; + const path = pathKey({env}); -const mimicFn = (to, from) => { - for (const prop of Reflect.ownKeys(from)) { - Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); - } + options.path = env[path]; + env[path] = module.exports(options); - return to; + return env; }; -module.exports = mimicFn; -// TODO: Remove this for the next major release -module.exports.default = mimicFn; - /***/ }), -/***/ 3973: +/***/ 1223: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = minimatch -minimatch.Minimatch = Minimatch - -var path = { sep: '/' } -try { - path = __nccwpck_require__(5622) -} catch (er) {} - -var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} -var expand = __nccwpck_require__(3717) - -var plTypes = { - '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, - '?': { open: '(?:', close: ')?' }, - '+': { open: '(?:', close: ')+' }, - '*': { open: '(?:', close: ')*' }, - '@': { open: '(?:', close: ')' } -} - -// any single thing other than / -// don't need to escape / when using new RegExp() -var qmark = '[^/]' - -// * => any number of characters -var star = qmark + '*?' - -// ** when dots are allowed. Anything goes, except .. and . -// not (^ or / followed by one or two dots followed by $ or /), -// followed by anything, any number of times. -var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' - -// not a ^ or / followed by a dot, -// followed by anything, any number of times. -var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' - -// characters that need to be escaped in RegExp. -var reSpecials = charSet('().*{}+?[]^$\\!') +var wrappy = __nccwpck_require__(2940) +module.exports = wrappy(once) +module.exports.strict = wrappy(onceStrict) -// "abc" -> { a:true, b:true, c:true } -function charSet (s) { - return s.split('').reduce(function (set, c) { - set[c] = true - return set - }, {}) -} +once.proto = once(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once(this) + }, + configurable: true + }) -// normalizes slashes. -var slashSplit = /\/+/ + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function () { + return onceStrict(this) + }, + configurable: true + }) +}) -minimatch.filter = filter -function filter (pattern, options) { - options = options || {} - return function (p, i, list) { - return minimatch(p, pattern, options) +function once (fn) { + var f = function () { + if (f.called) return f.value + f.called = true + return f.value = fn.apply(this, arguments) } + f.called = false + return f } -function ext (a, b) { - a = a || {} - b = b || {} - var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) - Object.keys(a).forEach(function (k) { - t[k] = a[k] - }) - return t +function onceStrict (fn) { + var f = function () { + if (f.called) + throw new Error(f.onceError) + f.called = true + return f.value = fn.apply(this, arguments) + } + var name = fn.name || 'Function wrapped with `once`' + f.onceError = name + " shouldn't be called more than once" + f.called = false + return f } -minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch - var orig = minimatch +/***/ }), - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - } +/***/ 9082: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - } +"use strict"; - return m -} +const mimicFn = __nccwpck_require__(6047); -Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch - return minimatch.defaults(def).Minimatch -} +const calledFunctions = new WeakMap(); -function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } +const onetime = (function_, options = {}) => { + if (typeof function_ !== 'function') { + throw new TypeError('Expected a function'); + } - if (!options) options = {} + let returnValue; + let callCount = 0; + const functionName = function_.displayName || function_.name || ''; - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - return false - } + const onetime = function (...arguments_) { + calledFunctions.set(onetime, ++callCount); - // "" only matches "" - if (pattern.trim() === '') return p === '' + if (callCount === 1) { + returnValue = function_.apply(this, arguments_); + function_ = null; + } else if (options.throw === true) { + throw new Error(`Function \`${functionName}\` can only be called once`); + } - return new Minimatch(pattern, options).match(p) -} + return returnValue; + }; -function Minimatch (pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) - } + mimicFn(onetime, function_); + calledFunctions.set(onetime, callCount); - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + return onetime; +}; - if (!options) options = {} - pattern = pattern.trim() +module.exports = onetime; +// TODO: Remove this for the next major release +module.exports.default = onetime; - // windows support: need to use /, not \ - if (path.sep !== '/') { - pattern = pattern.split(path.sep).join('/') - } +module.exports.callCount = function_ => { + if (!calledFunctions.has(function_)) { + throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); + } - this.options = options - this.set = [] - this.pattern = pattern - this.regexp = null - this.negate = false - this.comment = false - this.empty = false + return calledFunctions.get(function_); +}; - // make the set of regexps etc. - this.make() -} -Minimatch.prototype.debug = function () {} +/***/ }), -Minimatch.prototype.make = make -function make () { - // don't do it more than once. - if (this._made) return +/***/ 8714: +/***/ ((module) => { - var pattern = this.pattern - var options = this.options +"use strict"; - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - this.comment = true - return - } - if (!pattern) { - this.empty = true - return - } - // step 1: figure out negation, etc. - this.parseNegate() +function posix(path) { + return path.charAt(0) === '/'; +} - // step 2: expand braces - var set = this.globSet = this.braceExpand() +function win32(path) { + // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = Boolean(device && device.charAt(1) !== ':'); - if (options.debug) this.debug = console.error + // UNC paths are always absolute + return Boolean(result[2] || isUnc); +} - this.debug(this.pattern, set) +module.exports = process.platform === 'win32' ? win32 : posix; +module.exports.posix = posix; +module.exports.win32 = win32; - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }) - this.debug(this.pattern, set) +/***/ }), - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) +/***/ 539: +/***/ ((module) => { - this.debug(this.pattern, set) +"use strict"; - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }) - this.debug(this.pattern, set) +const pathKey = (options = {}) => { + const environment = options.env || process.env; + const platform = options.platform || process.platform; - this.set = set -} + if (platform !== 'win32') { + return 'PATH'; + } -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - var negate = false - var options = this.options - var negateOffset = 0 + return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path'; +}; - if (options.nonegate) return +module.exports = pathKey; +// TODO: Remove this for the next major release +module.exports.default = pathKey; - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate - negateOffset++ - } - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} +/***/ }), -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} +/***/ 8341: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -Minimatch.prototype.braceExpand = braceExpand +var once = __nccwpck_require__(1223) +var eos = __nccwpck_require__(1205) +var fs = __nccwpck_require__(5747) // we only need fs to get the ReadStream and WriteStream prototypes -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options - } else { - options = {} - } - } +var noop = function () {} +var ancient = /^v?\.0/.test(process.version) - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern +var isFn = function (fn) { + return typeof fn === 'function' +} - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } +var isFS = function (stream) { + if (!ancient) return false // newer node version do not need to care about fs is a special way + if (!fs) return false // browser + return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) +} - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } +var isRequest = function (stream) { + return stream.setHeader && isFn(stream.abort) +} + +var destroyer = function (stream, reading, writing, callback) { + callback = once(callback) - return expand(pattern) -} + var closed = false + stream.on('close', function () { + closed = true + }) -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') - } + eos(stream, {readable: reading, writable: writing}, function (err) { + if (err) return callback(err) + closed = true + callback() + }) - var options = this.options + var destroyed = false + return function (err) { + if (closed) return + if (destroyed) return + destroyed = true - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' + if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks + if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want - var re = '' - var hasMagic = !!options.nocase - var escaping = false - // ? => one single character - var patternListStack = [] - var negativeLists = [] - var stateChar - var inClass = false - var reClassStart = -1 - var classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)' - var self = this + if (isFn(stream.destroy)) return stream.destroy() - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star - hasMagic = true - break - case '?': - re += qmark - hasMagic = true - break - default: - re += '\\' + stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } + callback(err || new Error('stream was destroyed')) } +} - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c - escaping = false - continue - } +var call = function (fn) { + fn() +} - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false +var pipe = function (from, to) { + return from.pipe(to) +} - case '\\': - clearStateChar() - escaping = true - continue +var pump = function () { + var streams = Array.prototype.slice.call(arguments) + var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + if (Array.isArray(streams[0])) streams = streams[0] + if (streams.length < 2) throw new Error('pump requires two streams per minimum') - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === '!' && i === classStart + 1) c = '^' - re += c - continue - } + var error + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1 + var writing = i > 0 + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err + if (err) destroys.forEach(call) + if (reading) return + destroys.forEach(call) + callback(error) + }) + }) - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue + return streams.reduce(pipe) +} - case '(': - if (inClass) { - re += '(' - continue - } +module.exports = pump - if (!stateChar) { - re += '\\(' - continue - } - patternListStack.push({ - type: stateChar, - start: i - 1, - reStart: re.length, - open: plTypes[stateChar].open, - close: plTypes[stateChar].close - }) - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:' - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue +/***/ }), - case ')': - if (inClass || !patternListStack.length) { - re += '\\)' - continue - } +/***/ 1532: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - clearStateChar() - hasMagic = true - var pl = patternListStack.pop() - // negation is (?:(?!js)[^/]*) - // The others are (?:) - re += pl.close - if (pl.type === '!') { - negativeLists.push(pl) - } - pl.reEnd = re.length - continue +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY + } + constructor (comp, options) { + options = parseOptions(options) - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|' - escaping = false - continue - } + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } - clearStateChar() - re += '|' - continue + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar() + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } - if (inClass) { - re += '\\' + c - continue - } + debug('comp', this) + } - inClass = true - classStart = i - reClassStart = re.length - re += c - continue + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c - escaping = false - continue - } + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } - // finish up the class. - hasMagic = true - inClass = false - re += c - continue + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } - default: - // swallow any state char that wasn't consumed - clearStateChar() + toString () { + return this.value + } - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\' - } + test (version) { + debug('Comparator.test', version, this.options.loose) - re += c + if (this.semver === ANY || version === ANY) { + return true + } - } // switch - } // for + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1) - sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] - hasMagic = hasMagic || sp[1] + return cmp(version, this.operator, this.semver, this.options) } - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + pl.open.length) - this.debug('setting tail', re, pl) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\' + intersects (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } + } - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }) + if (this.operator === '') { + if (this.value === '') { + return true + } + return new Range(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + return new Range(this.value, options).test(comp.semver) + } - this.debug('tail=%j\n %s', tail, tail, pl, re) - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type + const sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + const sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + const sameSemVer = this.semver.version === comp.semver.version + const differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + const oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<') + const oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>') - hasMagic = true - re = re.slice(0, pl.reStart) + t + '\\(' + tail + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) } +} - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += '\\\\' - } +module.exports = Comparator - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true - } +const parseOptions = __nccwpck_require__(785) +const {re, t} = __nccwpck_require__(9523) +const cmp = __nccwpck_require__(5098) +const debug = __nccwpck_require__(427) +const SemVer = __nccwpck_require__(8088) +const Range = __nccwpck_require__(9828) - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n] - var nlBefore = re.slice(0, nl.reStart) - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) - var nlAfter = re.slice(nl.reEnd) +/***/ }), - nlLast += nlAfter +/***/ 9828: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1 - var cleanAfter = nlAfter - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + options = parseOptions(options) + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } } - nlAfter = cleanAfter - var dollar = '' - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$' + if (range instanceof Comparator) { + // just put it in the set and return + this.raw = range.value + this.set = [[range]] + this.format() + return this + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range + .split(/\s*\|\|\s*/) + // map the range to a 2d array of comparators + .map(range => this.parseRange(range.trim())) + // throw out any comparator lists that are empty + // this generally means that it was not a valid range, which is allowed + // in loose mode, but will still throw if the WHOLE range is invalid. + .filter(c => c.length) + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${range}`) + } + + // if we have any that are not the null set, throw out null sets. + if (this.set.length > 1) { + // keep the first one, in case they're all null sets + const first = this.set[0] + this.set = this.set.filter(c => !isNullSet(c[0])) + if (this.set.length === 0) + this.set = [first] + else if (this.set.length > 1) { + // if we have any that are *, then the range is just * + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c] + break + } + } + } } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast - re = newRe - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re - } - - if (addPatternStart) { - re = patternStart + re - } - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] + this.format() } - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range } - var flags = options.nocase ? 'i' : '' - try { - var regExp = new RegExp('^' + re + '$', flags) - } catch (er) { - // If it was an invalid regular expression, then it can't match - // anything. This trick looks for a character after the end of - // the string, which is of course impossible, except in multi-line - // mode, but it's not a /m regex. - return new RegExp('$.') + toString () { + return this.range } - regExp._glob = pattern - regExp._src = re - - return regExp -} + parseRange (range) { + range = range.trim() -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} + // memoize range parsing for performance. + // this is a very hot path, and fully deterministic. + const memoOpts = Object.keys(this.options).join(',') + const memoKey = `parseRange:${memoOpts}:${range}` + const cached = cache.get(memoKey) + if (cached) + return cached -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp + const loose = this.options.loose + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) - if (!set.length) { - this.regexp = false - return this.regexp - } - var options = this.options + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - var flags = options.nocase ? 'i' : '' + // normalize spaces + range = range.split(/\s+/).join(' ') - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|') + // At this point, the range is completely trimmed and + // ready to be split into comparators. - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$' + const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const rangeList = range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + // >=0.0.0 is equivalent to * + .map(comp => replaceGTE0(comp, this.options)) + // in loose mode, throw out any that are not valid comparators + .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) + .map(comp => new Comparator(comp, this.options)) - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$' + // if any comparators are the null set, then replace with JUST null set + // if more than one comparator, remove any * comparators + // also, don't include the same comparator more than once + const l = rangeList.length + const rangeMap = new Map() + for (const comp of rangeList) { + if (isNullSet(comp)) + return [comp] + rangeMap.set(comp.value, comp) + } + if (rangeMap.size > 1 && rangeMap.has('')) + rangeMap.delete('') - try { - this.regexp = new RegExp(re, flags) - } catch (ex) { - this.regexp = false + const result = [...rangeMap.values()] + cache.set(memoKey, result) + return result } - return this.regexp -} -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} + intersects (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } -Minimatch.prototype.match = match -function match (f, partial) { - this.debug('match', f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } - if (f === '/' && partial) return true + // if ANY of the sets match ALL of its comparators, then pass + test (version) { + if (!version) { + return false + } - var options = this.options + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } - // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/') + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false } +} +module.exports = Range - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, 'split', f) +const LRU = __nccwpck_require__(7129) +const cache = new LRU({ max: 1000 }) - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. +const parseOptions = __nccwpck_require__(785) +const Comparator = __nccwpck_require__(1532) +const debug = __nccwpck_require__(427) +const SemVer = __nccwpck_require__(8088) +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = __nccwpck_require__(9523) - var set = this.set - this.debug(this.pattern, 'set', set) +const isNullSet = c => c.value === '<0.0.0-0' +const isAny = c => c.value === '' - // Find the basename of the path by looking for the last non-empty segment - var filename - var i - for (i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } +// take a set of comparators and determine whether there +// exists a version which can satisfy it +const isSatisfiable = (comparators, options) => { + let result = true + const remainingComparators = comparators.slice() + let testComparator = remainingComparators.pop() - for (i = 0; i < set.length; i++) { - var pattern = set[i] - var file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() } - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate + return result } -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +const parseComparator = (comp, options) => { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }) +const isX = id => !id || id.toLowerCase() === 'x' || id === '*' - this.debug('matchOne', file.length, pattern.length) +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +const replaceTildes = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceTilde(comp, options) + }).join(' ') - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop') - var p = pattern[pi] - var f = file[fi] +const replaceTilde = (comp, options) => { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, (_, M, m, p, pr) => { + debug('tilde', comp, _, M, m, p, pr) + let ret - this.debug(pattern, p, f) + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0` + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` + } else if (pr) { + debug('replaceTilde pr', pr) + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } else { + // ~1.2.3 == >=1.2.3 <1.3.0-0 + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0-0` + } - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false + debug('tilde return', ret) + return ret + }) +} - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 +// ^1.2.3 --> >=1.2.3 <2.0.0-0 +// ^1.2.0 --> >=1.2.0 <2.0.0-0 +const replaceCarets = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceCaret(comp, options) + }).join(' ') - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - var pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false +const replaceCaret = (comp, options) => { + debug('caret', comp, options) + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + const z = options.includePrerelease ? '-0' : '' + return comp.replace(r, (_, M, m, p, pr) => { + debug('caret', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` + } else if (isX(p)) { + if (M === '0') { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` } - return true + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0-0` + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p + }${z} <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p + }${z} <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0-0` } + } - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr] + debug('caret return', ret) + return ret + }) +} - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) +const replaceXRanges = (comp, options) => { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +} - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr) - break - } +const replaceXRange = (comp, options) => { + comp = comp.trim() + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + const xM = isX(M) + const xm = xM || isX(m) + const xp = xm || isX(p) + const anyX = xp - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr++ + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 } } - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } + if (gtlt === '<') + pr = '-0' - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug('string match', p, f, hit) - } else { - hit = f.match(p) - this.debug('pattern match', p, f, hit) + ret = `${gtlt + M}.${m}.${p}${pr}` + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` + } else if (xp) { + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0-0` } - if (!hit) return false - } + debug('xRange return', ret) - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* + return ret + }) +} - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd - } +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +const replaceStars = (comp, options) => { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') +} - // should be unreachable. - throw new Error('wtf?') +const replaceGTE0 = (comp, options) => { + debug('replaceGTE0', comp, options) + return comp.trim() + .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 +const hyphenReplace = incPr => ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = `>=${fM}.0.0${incPr ? '-0' : ''}` + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` + } else if (fpr) { + from = `>=${from}` + } else { + from = `>=${from}${incPr ? '-0' : ''}` + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = `<${+tM + 1}.0.0-0` + } else if (isX(tp)) { + to = `<${tM}.${+tm + 1}.0-0` + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}` + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0` + } else { + to = `<=${to}` + } + + return (`${from} ${to}`).trim() } -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === Comparator.ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true } /***/ }), -/***/ 502: +/***/ 8088: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +const debug = __nccwpck_require__(427) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(2293) +const { re, t } = __nccwpck_require__(9523) -const path = __nccwpck_require__(5622); -const pathKey = __nccwpck_require__(539); +const parseOptions = __nccwpck_require__(785) +const { compareIdentifiers } = __nccwpck_require__(2463) +class SemVer { + constructor (version, options) { + options = parseOptions(options) -const npmRunPath = options => { - options = { - cwd: process.cwd(), - path: process.env[pathKey()], - execPath: process.execPath, - ...options - }; + if (version instanceof SemVer) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid Version: ${version}`) + } - let previous; - let cwdPath = path.resolve(options.cwd); - const result = []; + if (version.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ) + } - while (previous !== cwdPath) { - result.push(path.join(cwdPath, 'node_modules/.bin')); - previous = cwdPath; - cwdPath = path.resolve(cwdPath, '..'); - } + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease - // Ensure the running `node` binary is used - const execPathDir = path.resolve(options.cwd, options.execPath, '..'); - result.push(execPathDir); + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) - return result.concat(options.path).join(path.delimiter); -}; + if (!m) { + throw new TypeError(`Invalid Version: ${version}`) + } -module.exports = npmRunPath; -// TODO: Remove this for the next major release -module.exports.default = npmRunPath; + this.raw = version -module.exports.env = options => { - options = { - env: process.env, - ...options - }; + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] - const env = {...options.env}; - const path = pathKey({env}); + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } - options.path = env[path]; - env[path] = module.exports(options); + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } - return env; -}; + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() + } + format () { + this.version = `${this.major}.${this.minor}.${this.patch}` + if (this.prerelease.length) { + this.version += `-${this.prerelease.join('.')}` + } + return this.version + } -/***/ }), + toString () { + return this.version + } -/***/ 1223: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + compare (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } + other = new SemVer(other, this.options) + } -var wrappy = __nccwpck_require__(2940) -module.exports = wrappy(once) -module.exports.strict = wrappy(onceStrict) + if (other.version === this.version) { + return 0 + } -once.proto = once(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once(this) - }, - configurable: true - }) + return this.compareMain(other) || this.comparePre(other) + } - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }) -}) + compareMain (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) } - f.called = false - return f -} -function onceStrict (fn) { - var f = function () { - if (f.called) - throw new Error(f.onceError) - f.called = true - return f.value = fn.apply(this, arguments) - } - var name = fn.name || 'Function wrapped with `once`' - f.onceError = name + " shouldn't be called more than once" - f.called = false - return f -} + comparePre (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } -/***/ }), + let i = 0 + do { + const a = this.prerelease[i] + const b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } -/***/ 9082: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + compareBuild (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -"use strict"; + let i = 0 + do { + const a = this.build[i] + const b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } -const mimicFn = __nccwpck_require__(6047); + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break -const calledFunctions = new WeakMap(); + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + let i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break -const onetime = (function_, options = {}) => { - if (typeof function_ !== 'function') { - throw new TypeError('Expected a function'); - } + default: + throw new Error(`invalid increment argument: ${release}`) + } + this.format() + this.raw = this.version + return this + } +} - let returnValue; - let callCount = 0; - const functionName = function_.displayName || function_.name || ''; +module.exports = SemVer - const onetime = function (...arguments_) { - calledFunctions.set(onetime, ++callCount); - if (callCount === 1) { - returnValue = function_.apply(this, arguments_); - function_ = null; - } else if (options.throw === true) { - throw new Error(`Function \`${functionName}\` can only be called once`); - } +/***/ }), - return returnValue; - }; +/***/ 8848: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - mimicFn(onetime, function_); - calledFunctions.set(onetime, callCount); +const parse = __nccwpck_require__(5925) +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} +module.exports = clean - return onetime; -}; -module.exports = onetime; -// TODO: Remove this for the next major release -module.exports.default = onetime; +/***/ }), -module.exports.callCount = function_ => { - if (!calledFunctions.has(function_)) { - throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); - } +/***/ 5098: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return calledFunctions.get(function_); -}; +const eq = __nccwpck_require__(1898) +const neq = __nccwpck_require__(6017) +const gt = __nccwpck_require__(4123) +const gte = __nccwpck_require__(5522) +const lt = __nccwpck_require__(194) +const lte = __nccwpck_require__(7520) +const cmp = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b -/***/ }), + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b -/***/ 8714: -/***/ ((module) => { + case '': + case '=': + case '==': + return eq(a, b, loose) -"use strict"; + case '!=': + return neq(a, b, loose) + case '>': + return gt(a, b, loose) -function posix(path) { - return path.charAt(0) === '/'; -} + case '>=': + return gte(a, b, loose) -function win32(path) { - // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 - var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; - var result = splitDeviceRe.exec(path); - var device = result[1] || ''; - var isUnc = Boolean(device && device.charAt(1) !== ':'); + case '<': + return lt(a, b, loose) - // UNC paths are always absolute - return Boolean(result[2] || isUnc); -} + case '<=': + return lte(a, b, loose) -module.exports = process.platform === 'win32' ? win32 : posix; -module.exports.posix = posix; -module.exports.win32 = win32; + default: + throw new TypeError(`Invalid operator: ${op}`) + } +} +module.exports = cmp /***/ }), -/***/ 539: -/***/ ((module) => { +/***/ 3466: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +const SemVer = __nccwpck_require__(8088) +const parse = __nccwpck_require__(5925) +const {re, t} = __nccwpck_require__(9523) +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version + } -const pathKey = (options = {}) => { - const environment = options.env || process.env; - const platform = options.platform || process.platform; + if (typeof version === 'number') { + version = String(version) + } - if (platform !== 'win32') { - return 'PATH'; - } + if (typeof version !== 'string') { + return null + } - return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path'; -}; + options = options || {} -module.exports = pathKey; -// TODO: Remove this for the next major release -module.exports.default = pathKey; + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) + return null + + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +} +module.exports = coerce /***/ }), -/***/ 8341: +/***/ 2156: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var once = __nccwpck_require__(1223) -var eos = __nccwpck_require__(1205) -var fs = __nccwpck_require__(5747) // we only need fs to get the ReadStream and WriteStream prototypes +const SemVer = __nccwpck_require__(8088) +const compareBuild = (a, b, loose) => { + const versionA = new SemVer(a, loose) + const versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} +module.exports = compareBuild -var noop = function () {} -var ancient = /^v?\.0/.test(process.version) -var isFn = function (fn) { - return typeof fn === 'function' -} +/***/ }), -var isFS = function (stream) { - if (!ancient) return false // newer node version do not need to care about fs is a special way - if (!fs) return false // browser - return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) -} +/***/ 2804: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var isRequest = function (stream) { - return stream.setHeader && isFn(stream.abort) -} +const compare = __nccwpck_require__(4309) +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose -var destroyer = function (stream, reading, writing, callback) { - callback = once(callback) - var closed = false - stream.on('close', function () { - closed = true - }) +/***/ }), - eos(stream, {readable: reading, writable: writing}, function (err) { - if (err) return callback(err) - closed = true - callback() - }) +/***/ 4309: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - var destroyed = false - return function (err) { - if (closed) return - if (destroyed) return - destroyed = true +const SemVer = __nccwpck_require__(8088) +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) - if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks - if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want +module.exports = compare - if (isFn(stream.destroy)) return stream.destroy() - callback(err || new Error('stream was destroyed')) - } -} +/***/ }), -var call = function (fn) { - fn() -} +/***/ 4297: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var pipe = function (from, to) { - return from.pipe(to) -} +const parse = __nccwpck_require__(5925) +const eq = __nccwpck_require__(1898) -var pump = function () { - var streams = Array.prototype.slice.call(arguments) - var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop +const diff = (version1, version2) => { + if (eq(version1, version2)) { + return null + } else { + const v1 = parse(version1) + const v2 = parse(version2) + const hasPre = v1.prerelease.length || v2.prerelease.length + const prefix = hasPre ? 'pre' : '' + const defaultResult = hasPre ? 'prerelease' : '' + for (const key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} +module.exports = diff - if (Array.isArray(streams[0])) streams = streams[0] - if (streams.length < 2) throw new Error('pump requires two streams per minimum') - var error - var destroys = streams.map(function (stream, i) { - var reading = i < streams.length - 1 - var writing = i > 0 - return destroyer(stream, reading, writing, function (err) { - if (!error) error = err - if (err) destroys.forEach(call) - if (reading) return - destroys.forEach(call) - callback(error) - }) - }) +/***/ }), - return streams.reduce(pipe) -} +/***/ 1898: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = pump +const compare = __nccwpck_require__(4309) +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq /***/ }), -/***/ 1532: +/***/ 4123: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const ANY = Symbol('SemVer ANY') -// hoisted class for cyclic dependency -class Comparator { - static get ANY () { - return ANY - } - constructor (comp, options) { - options = parseOptions(options) +const compare = __nccwpck_require__(4309) +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) +/***/ }), - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version - } +/***/ 5522: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - debug('comp', this) - } +const compare = __nccwpck_require__(4309) +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte - parse (comp) { - const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const m = comp.match(r) - if (!m) { - throw new TypeError(`Invalid comparator: ${comp}`) - } +/***/ }), - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' - } +/***/ 900: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY - } else { - this.semver = new SemVer(m[2], this.options.loose) - } +const SemVer = __nccwpck_require__(8088) + +const inc = (version, release, options, identifier) => { + if (typeof (options) === 'string') { + identifier = options + options = undefined } - toString () { - return this.value + try { + return new SemVer(version, options).inc(release, identifier).version + } catch (er) { + return null } +} +module.exports = inc - test (version) { - debug('Comparator.test', version, this.options.loose) - if (this.semver === ANY || version === ANY) { - return true - } +/***/ }), - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } +/***/ 194: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return cmp(version, this.operator, this.semver, this.options) - } +const compare = __nccwpck_require__(4309) +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt - intersects (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +/***/ }), - if (this.operator === '') { - if (this.value === '') { - return true - } - return new Range(comp.value, options).test(this.value) - } else if (comp.operator === '') { - if (comp.value === '') { - return true - } - return new Range(this.value, options).test(comp.semver) - } +/***/ 7520: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - const sameDirectionIncreasing = - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '>=' || comp.operator === '>') - const sameDirectionDecreasing = - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '<=' || comp.operator === '<') - const sameSemVer = this.semver.version === comp.semver.version - const differentDirectionsInclusive = - (this.operator === '>=' || this.operator === '<=') && - (comp.operator === '>=' || comp.operator === '<=') - const oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, options) && - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '<=' || comp.operator === '<') - const oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, options) && - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '>=' || comp.operator === '>') +const compare = __nccwpck_require__(4309) +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) - } -} -module.exports = Comparator +/***/ }), + +/***/ 6688: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const parseOptions = __nccwpck_require__(785) -const {re, t} = __nccwpck_require__(9523) -const cmp = __nccwpck_require__(5098) -const debug = __nccwpck_require__(427) const SemVer = __nccwpck_require__(8088) -const Range = __nccwpck_require__(9828) +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major /***/ }), -/***/ 9828: +/***/ 8447: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// hoisted class for cyclic dependency -class Range { - constructor (range, options) { - options = parseOptions(options) +const SemVer = __nccwpck_require__(8088) +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor - if (range instanceof Range) { - if ( - range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease - ) { - return range - } else { - return new Range(range.raw, options) - } - } - if (range instanceof Comparator) { - // just put it in the set and return - this.raw = range.value - this.set = [[range]] - this.format() - return this - } +/***/ }), - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease +/***/ 6017: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // First, split based on boolean or || - this.raw = range - this.set = range - .split(/\s*\|\|\s*/) - // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) - // throw out any comparator lists that are empty - // this generally means that it was not a valid range, which is allowed - // in loose mode, but will still throw if the WHOLE range is invalid. - .filter(c => c.length) +const compare = __nccwpck_require__(4309) +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq - if (!this.set.length) { - throw new TypeError(`Invalid SemVer Range: ${range}`) - } - // if we have any that are not the null set, throw out null sets. - if (this.set.length > 1) { - // keep the first one, in case they're all null sets - const first = this.set[0] - this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) - this.set = [first] - else if (this.set.length > 1) { - // if we have any that are *, then the range is just * - for (const c of this.set) { - if (c.length === 1 && isAny(c[0])) { - this.set = [c] - break - } - } - } - } +/***/ }), - this.format() +/***/ 5925: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const {MAX_LENGTH} = __nccwpck_require__(2293) +const { re, t } = __nccwpck_require__(9523) +const SemVer = __nccwpck_require__(8088) + +const parseOptions = __nccwpck_require__(785) +const parse = (version, options) => { + options = parseOptions(options) + + if (version instanceof SemVer) { + return version } - format () { - this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) - .join('||') - .trim() - return this.range + if (typeof version !== 'string') { + return null + } + + if (version.length > MAX_LENGTH) { + return null } - toString () { - return this.range + const r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null } - parseRange (range) { - range = range.trim() + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} - // memoize range parsing for performance. - // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` - const cached = cache.get(memoKey) - if (cached) - return cached +module.exports = parse - const loose = this.options.loose - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) - debug('hyphen replace', range) - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) +/***/ }), - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace) +/***/ 2866: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // normalize spaces - range = range.split(/\s+/).join(' ') +const SemVer = __nccwpck_require__(8088) +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch - // At this point, the range is completely trimmed and - // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range - .split(' ') - .map(comp => parseComparator(comp, this.options)) - .join(' ') - .split(/\s+/) - // >=0.0.0 is equivalent to * - .map(comp => replaceGTE0(comp, this.options)) - // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) +/***/ }), - // if any comparators are the null set, then replace with JUST null set - // if more than one comparator, remove any * comparators - // also, don't include the same comparator more than once - const l = rangeList.length - const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) - return [comp] - rangeMap.set(comp.value, comp) - } - if (rangeMap.size > 1 && rangeMap.has('')) - rangeMap.delete('') +/***/ 6014: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - const result = [...rangeMap.values()] - cache.set(memoKey, result) - return result - } +const parse = __nccwpck_require__(5925) +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease - intersects (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - return this.set.some((thisComparators) => { - return ( - isSatisfiable(thisComparators, options) && - range.set.some((rangeComparators) => { - return ( - isSatisfiable(rangeComparators, options) && - thisComparators.every((thisComparator) => { - return rangeComparators.every((rangeComparator) => { - return thisComparator.intersects(rangeComparator, options) - }) - }) - ) - }) - ) - }) - } +/***/ }), - // if ANY of the sets match ALL of its comparators, then pass - test (version) { - if (!version) { - return false - } +/***/ 7499: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } +const compare = __nccwpck_require__(4309) +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare - for (let i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } + +/***/ }), + +/***/ 8701: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const compareBuild = __nccwpck_require__(2156) +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort + + +/***/ }), + +/***/ 6055: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const Range = __nccwpck_require__(9828) +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { return false } + return range.test(version) } -module.exports = Range +module.exports = satisfies -const LRU = __nccwpck_require__(7129) -const cache = new LRU({ max: 1000 }) -const parseOptions = __nccwpck_require__(785) -const Comparator = __nccwpck_require__(1532) -const debug = __nccwpck_require__(427) -const SemVer = __nccwpck_require__(8088) -const { - re, - t, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace -} = __nccwpck_require__(9523) +/***/ }), -const isNullSet = c => c.value === '<0.0.0-0' -const isAny = c => c.value === '' +/***/ 1426: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// take a set of comparators and determine whether there -// exists a version which can satisfy it -const isSatisfiable = (comparators, options) => { - let result = true - const remainingComparators = comparators.slice() - let testComparator = remainingComparators.pop() +const compareBuild = __nccwpck_require__(2156) +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort - while (result && remainingComparators.length) { - result = remainingComparators.every((otherComparator) => { - return testComparator.intersects(otherComparator, options) - }) - testComparator = remainingComparators.pop() - } +/***/ }), - return result -} +/***/ 9601: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -const parseComparator = (comp, options) => { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp +const parse = __nccwpck_require__(5925) +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null } +module.exports = valid -const isX = id => !id || id.toLowerCase() === 'x' || id === '*' -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +/***/ }), + +/***/ 1383: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +// just pre-load all the stuff that index.js lazily exports +const internalRe = __nccwpck_require__(9523) +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: __nccwpck_require__(2293).SEMVER_SPEC_VERSION, + SemVer: __nccwpck_require__(8088), + compareIdentifiers: __nccwpck_require__(2463).compareIdentifiers, + rcompareIdentifiers: __nccwpck_require__(2463).rcompareIdentifiers, + parse: __nccwpck_require__(5925), + valid: __nccwpck_require__(9601), + clean: __nccwpck_require__(8848), + inc: __nccwpck_require__(900), + diff: __nccwpck_require__(4297), + major: __nccwpck_require__(6688), + minor: __nccwpck_require__(8447), + patch: __nccwpck_require__(2866), + prerelease: __nccwpck_require__(6014), + compare: __nccwpck_require__(4309), + rcompare: __nccwpck_require__(7499), + compareLoose: __nccwpck_require__(2804), + compareBuild: __nccwpck_require__(2156), + sort: __nccwpck_require__(1426), + rsort: __nccwpck_require__(8701), + gt: __nccwpck_require__(4123), + lt: __nccwpck_require__(194), + eq: __nccwpck_require__(1898), + neq: __nccwpck_require__(6017), + gte: __nccwpck_require__(5522), + lte: __nccwpck_require__(7520), + cmp: __nccwpck_require__(5098), + coerce: __nccwpck_require__(3466), + Comparator: __nccwpck_require__(1532), + Range: __nccwpck_require__(9828), + satisfies: __nccwpck_require__(6055), + toComparators: __nccwpck_require__(2706), + maxSatisfying: __nccwpck_require__(579), + minSatisfying: __nccwpck_require__(832), + minVersion: __nccwpck_require__(4179), + validRange: __nccwpck_require__(2098), + outside: __nccwpck_require__(420), + gtr: __nccwpck_require__(9380), + ltr: __nccwpck_require__(3323), + intersects: __nccwpck_require__(7008), + simplifyRange: __nccwpck_require__(5297), + subset: __nccwpck_require__(7863), +} -const replaceTilde = (comp, options) => { - const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, (_, M, m, p, pr) => { - debug('tilde', comp, _, M, m, p, pr) - let ret - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0-0` - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0-0 - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` - } else if (pr) { - debug('replaceTilde pr', pr) - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0-0` - } else { - // ~1.2.3 == >=1.2.3 <1.3.0-0 - ret = `>=${M}.${m}.${p - } <${M}.${+m + 1}.0-0` - } +/***/ }), - debug('tilde return', ret) - return ret - }) -} +/***/ 2293: +/***/ ((module) => { -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 -// ^1.2.3 --> >=1.2.3 <2.0.0-0 -// ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' -const replaceCaret = (comp, options) => { - debug('caret', comp, options) - const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - const z = options.includePrerelease ? '-0' : '' - return comp.replace(r, (_, M, m, p, pr) => { - debug('caret', comp, _, M, m, p, pr) - let ret +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` - } else if (isX(p)) { - if (M === '0') { - ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` - } else { - ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${m}.${+p + 1}-0` - } else { - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0-0` - } - } else { - ret = `>=${M}.${m}.${p}-${pr - } <${+M + 1}.0.0-0` - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = `>=${M}.${m}.${p - }${z} <${M}.${m}.${+p + 1}-0` - } else { - ret = `>=${M}.${m}.${p - }${z} <${M}.${+m + 1}.0-0` - } - } else { - ret = `>=${M}.${m}.${p - } <${+M + 1}.0.0-0` - } - } +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 - debug('caret return', ret) - return ret - }) +module.exports = { + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH } -const replaceXRanges = (comp, options) => { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') -} -const replaceXRange = (comp, options) => { - comp = comp.trim() - const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, (ret, gtlt, M, m, p, pr) => { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - const xM = isX(M) - const xm = xM || isX(m) - const xp = xm || isX(p) - const anyX = xp +/***/ }), - if (gtlt === '=' && anyX) { - gtlt = '' - } +/***/ 427: +/***/ ((module) => { - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' +const debug = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {} - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 +module.exports = debug - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } - if (gtlt === '<') - pr = '-0' +/***/ }), - ret = `${gtlt + M}.${m}.${p}${pr}` - } else if (xm) { - ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` - } else if (xp) { - ret = `>=${M}.${m}.0${pr - } <${M}.${+m + 1}.0-0` - } +/***/ 2463: +/***/ ((module) => { - debug('xRange return', ret) +const numeric = /^[0-9]+$/ +const compareIdentifiers = (a, b) => { + const anum = numeric.test(a) + const bnum = numeric.test(b) - return ret - }) -} + if (anum && bnum) { + a = +a + b = +b + } -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -const replaceStars = (comp, options) => { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[t.STAR], '') + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 } -const replaceGTE0 = (comp, options) => { - debug('replaceGTE0', comp, options) - return comp.trim() - .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') +const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) + +module.exports = { + compareIdentifiers, + rcompareIdentifiers } -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 -const hyphenReplace = incPr => ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) => { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = `>=${fM}.0.0${incPr ? '-0' : ''}` - } else if (isX(fp)) { - from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` - } else if (fpr) { - from = `>=${from}` - } else { - from = `>=${from}${incPr ? '-0' : ''}` - } - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = `<${+tM + 1}.0.0-0` - } else if (isX(tp)) { - to = `<${tM}.${+tm + 1}.0-0` - } else if (tpr) { - to = `<=${tM}.${tm}.${tp}-${tpr}` - } else if (incPr) { - to = `<${tM}.${tm}.${+tp + 1}-0` - } else { - to = `<=${to}` - } +/***/ }), + +/***/ 785: +/***/ ((module) => { + +// parse out just the options we care about so we always get a consistent +// obj with keys in a consistent order. +const opts = ['includePrerelease', 'loose', 'rtl'] +const parseOptions = options => + !options ? {} + : typeof options !== 'object' ? { loose: true } + : opts.filter(k => options[k]).reduce((options, k) => { + options[k] = true + return options + }, {}) +module.exports = parseOptions + - return (`${from} ${to}`).trim() +/***/ }), + +/***/ 9523: +/***/ ((module, exports, __nccwpck_require__) => { + +const { MAX_SAFE_COMPONENT_LENGTH } = __nccwpck_require__(2293) +const debug = __nccwpck_require__(427) +exports = module.exports = {} + +// The actual regexps go on exports.re +const re = exports.re = [] +const src = exports.src = [] +const t = exports.t = {} +let R = 0 + +const createToken = (name, value, isGlobal) => { + const index = R++ + debug(index, value) + t[name] = index + src[index] = value + re[index] = new RegExp(value, isGlobal ? 'g' : undefined) } -const testSet = (set, version, options) => { - for (let i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } - } +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (let i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === Comparator.ANY) { - continue - } +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. - if (set[i].semver.prerelease.length > 0) { - const allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } - } +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') - // Version has a -pre, but it's not one of the ones we like. - return false - } +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. - return true -} +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') +// ## Main Version +// Three dot-separated numeric identifiers. -/***/ }), +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`) -/***/ 8088: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`) -const debug = __nccwpck_require__(427) -const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(2293) -const { re, t } = __nccwpck_require__(9523) +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. -const parseOptions = __nccwpck_require__(785) -const { compareIdentifiers } = __nccwpck_require__(2463) -class SemVer { - constructor (version, options) { - options = parseOptions(options) +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`) - if (version instanceof SemVer) { - if (version.loose === !!options.loose && - version.includePrerelease === !!options.includePrerelease) { - return version - } else { - version = version.version - } - } else if (typeof version !== 'string') { - throw new TypeError(`Invalid Version: ${version}`) - } +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`) - if (version.length > MAX_LENGTH) { - throw new TypeError( - `version is longer than ${MAX_LENGTH} characters` - ) - } +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - // this isn't actually relevant for versions, but keep it so that we - // don't run into trouble passing this.options around. - this.includePrerelease = !!options.includePrerelease +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) - const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) - if (!m) { - throw new TypeError(`Invalid Version: ${version}`) - } +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - this.raw = version +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } +// 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. - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } else { - this.prerelease = m[4].split('.').map((id) => { - if (/^[0-9]+$/.test(id)) { - const num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) - } +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) - this.build = m[5] ? m[5].split('.') : [] - this.format() - } +createToken('FULL', `^${src[t.FULLPLAIN]}$`) - format () { - this.version = `${this.major}.${this.minor}.${this.patch}` - if (this.prerelease.length) { - this.version += `-${this.prerelease.join('.')}` - } - return this.version - } +// 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]}?`) - toString () { - return this.version - } +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) - compare (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - if (typeof other === 'string' && other === this.version) { - return 0 - } - other = new SemVer(other, this.options) - } +createToken('GTLT', '((?:<|>)?=?)') - if (other.version === this.version) { - return 0 - } +// 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|\\*`) - return this.compareMain(other) || this.comparePre(other) - } +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) - compareMain (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) - return ( - compareIdentifiers(this.major, other.major) || - compareIdentifiers(this.minor, other.minor) || - compareIdentifiers(this.patch, other.patch) - ) - } +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', '(?:~>?)') - comparePre (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) +exports.tildeTrimReplace = '$1~' - // NOT having a prerelease is > having one - if (this.prerelease.length && !other.prerelease.length) { - return -1 - } else if (!this.prerelease.length && other.prerelease.length) { - return 1 - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0 - } +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) - let i = 0 - do { - const a = this.prerelease[i] - const b = other.prerelease[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) - } +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)') - compareBuild (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) +exports.caretTrimReplace = '$1^' - let i = 0 - do { - const a = this.build[i] - const b = other.build[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) - } +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) - // preminor will bump the version up to the next minor release, and immediately - // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier) - break - case 'prepatch': - // If this is already a prerelease, it will bump to the next version - // drop any prereleases that might already exist, since they are not - // relevant at this point. - this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) - break - // If the input is a non-prerelease version, this acts the same as - // prepatch. - case 'prerelease': - if (this.prerelease.length === 0) { - this.inc('patch', identifier) - } - this.inc('pre', identifier) - break +// 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]})$|^$`) - case 'major': - // If this is a pre-major version, bump up to the same major version. - // Otherwise increment major. - // 1.0.0-5 bumps to 1.0.0 - // 1.1.0 bumps to 2.0.0 - if ( - this.minor !== 0 || - this.patch !== 0 || - this.prerelease.length === 0 - ) { - this.major++ - } - this.minor = 0 - this.patch = 0 - this.prerelease = [] - break - case 'minor': - // If this is a pre-minor version, bump up to the same minor version. - // Otherwise increment minor. - // 1.2.0-5 bumps to 1.2.0 - // 1.2.1 bumps to 1.3.0 - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++ - } - this.patch = 0 - this.prerelease = [] - break - case 'patch': - // If this is not a pre-release version, it will increment the patch. - // If it is a pre-release it will bump up to the same patch version. - // 1.2.0-5 patches to 1.2.0 - // 1.2.0 patches to 1.2.1 - if (this.prerelease.length === 0) { - this.patch++ - } - this.prerelease = [] - break - // This probably shouldn't be used publicly. - // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. - case 'pre': - if (this.prerelease.length === 0) { - this.prerelease = [0] - } else { - let i = this.prerelease.length - while (--i >= 0) { - if (typeof this.prerelease[i] === 'number') { - this.prerelease[i]++ - i = -2 - } - } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) - } - } - if (identifier) { - // 1.2.0-beta.1 bumps to 1.2.0-beta.2, - // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - if (this.prerelease[0] === identifier) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] - } - } else { - this.prerelease = [identifier, 0] - } - } - break +// 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' - default: - throw new Error(`invalid increment argument: ${release}`) - } - this.format() - this.raw = this.version - return this - } -} +// 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*$`) -module.exports = SemVer +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*$') /***/ }), -/***/ 8848: +/***/ 9380: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const parse = __nccwpck_require__(5925) -const clean = (version, options) => { - const s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} -module.exports = clean +// Determine if version is greater than all the versions possible in the range. +const outside = __nccwpck_require__(420) +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr /***/ }), -/***/ 5098: +/***/ 7008: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const eq = __nccwpck_require__(1898) -const neq = __nccwpck_require__(6017) -const gt = __nccwpck_require__(4123) -const gte = __nccwpck_require__(5522) -const lt = __nccwpck_require__(194) -const lte = __nccwpck_require__(7520) +const Range = __nccwpck_require__(9828) +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} +module.exports = intersects -const cmp = (a, op, b, loose) => { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b +/***/ }), - case '': - case '=': - case '==': - return eq(a, b, loose) +/***/ 3323: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - case '!=': - return neq(a, b, loose) +const outside = __nccwpck_require__(420) +// Determine if version is less than all the versions possible in the range +const ltr = (version, range, options) => outside(version, range, '<', options) +module.exports = ltr - case '>': - return gt(a, b, loose) - case '>=': - return gte(a, b, loose) +/***/ }), - case '<': - return lt(a, b, loose) +/***/ 579: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - case '<=': - return lte(a, b, loose) +const SemVer = __nccwpck_require__(8088) +const Range = __nccwpck_require__(9828) - default: - throw new TypeError(`Invalid operator: ${op}`) +const maxSatisfying = (versions, range, options) => { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max } -module.exports = cmp +module.exports = maxSatisfying /***/ }), -/***/ 3466: +/***/ 832: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const SemVer = __nccwpck_require__(8088) -const parse = __nccwpck_require__(5925) -const {re, t} = __nccwpck_require__(9523) - -const coerce = (version, options) => { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { +const Range = __nccwpck_require__(9828) +const minSatisfying = (versions, range, options) => { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { return null } - - options = options || {} - - let match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - let next - while ((next = re[t.COERCERTL].exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 - } - - if (match === null) - return null - - return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) + }) + return min } -module.exports = coerce +module.exports = minSatisfying /***/ }), -/***/ 2156: +/***/ 4179: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const SemVer = __nccwpck_require__(8088) -const compareBuild = (a, b, loose) => { - const versionA = new SemVer(a, loose) - const versionB = new SemVer(b, loose) - return versionA.compare(versionB) || versionA.compareBuild(versionB) -} -module.exports = compareBuild +const Range = __nccwpck_require__(9828) +const gt = __nccwpck_require__(4123) +const minVersion = (range, loose) => { + range = new Range(range, loose) -/***/ }), + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } -/***/ 2804: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } -const compare = __nccwpck_require__(4309) -const compareLoose = (a, b) => compare(a, b, true) -module.exports = compareLoose + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let setMin = null + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!setMin || gt(compver, setMin)) { + setMin = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + if (setMin && (!minver || gt(minver, setMin))) + minver = setMin + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} +module.exports = minVersion /***/ }), -/***/ 4309: +/***/ 420: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const SemVer = __nccwpck_require__(8088) -const compare = (a, b, loose) => - new SemVer(a, loose).compare(new SemVer(b, loose)) +const Comparator = __nccwpck_require__(1532) +const {ANY} = Comparator +const Range = __nccwpck_require__(9828) +const satisfies = __nccwpck_require__(6055) +const gt = __nccwpck_require__(4123) +const lt = __nccwpck_require__(194) +const lte = __nccwpck_require__(7520) +const gte = __nccwpck_require__(5522) -module.exports = compare +const outside = (version, range, hilo, options) => { + version = new SemVer(version, options) + range = new Range(range, options) + + let gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + // If it satisfies the range it is not outside + if (satisfies(version, range, options)) { + return false + } -/***/ }), + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. -/***/ 4297: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] -const parse = __nccwpck_require__(5925) -const eq = __nccwpck_require__(1898) + let high = null + let low = null -const diff = (version1, version2) => { - if (eq(version1, version2)) { - return null - } else { - const v1 = parse(version1) - const v2 = parse(version2) - const hasPre = v1.prerelease.length || v2.prerelease.length - const prefix = hasPre ? 'pre' : '' - const defaultResult = hasPre ? 'prerelease' : '' - for (const key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key - } + comparators.forEach((comparator) => { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false } - return defaultResult // may be undefined } + return true } -module.exports = diff - - -/***/ }), -/***/ 1898: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const compare = __nccwpck_require__(4309) -const eq = (a, b, loose) => compare(a, b, loose) === 0 -module.exports = eq +module.exports = outside /***/ }), -/***/ 4123: +/***/ 5297: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies = __nccwpck_require__(6055) const compare = __nccwpck_require__(4309) -const gt = (a, b, loose) => compare(a, b, loose) > 0 -module.exports = gt +module.exports = (versions, range, options) => { + const set = [] + let min = null + let prev = null + const v = versions.sort((a, b) => compare(a, b, options)) + for (const version of v) { + const included = satisfies(version, range, options) + if (included) { + prev = version + if (!min) + min = version + } else { + if (prev) { + set.push([min, prev]) + } + prev = null + min = null + } + } + if (min) + set.push([min, null]) + + const ranges = [] + for (const [min, max] of set) { + if (min === max) + ranges.push(min) + else if (!max && min === v[0]) + ranges.push('*') + else if (!max) + ranges.push(`>=${min}`) + else if (min === v[0]) + ranges.push(`<=${max}`) + else + ranges.push(`${min} - ${max}`) + } + const simplified = ranges.join(' || ') + const original = typeof range.raw === 'string' ? range.raw : String(range) + return simplified.length < original.length ? simplified : range +} /***/ }), -/***/ 5522: +/***/ 7863: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const Range = __nccwpck_require__(9828) +const Comparator = __nccwpck_require__(1532) +const { ANY } = Comparator +const satisfies = __nccwpck_require__(6055) const compare = __nccwpck_require__(4309) -const gte = (a, b, loose) => compare(a, b, loose) >= 0 -module.exports = gte - - -/***/ }), -/***/ 900: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a null set, OR +// - Every simple range `r1, r2, ...` which is not a null set is a subset of +// some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else if in prerelease mode, return false +// - else replace c with `[>=0.0.0]` +// - If C is only the ANY comparator +// - if in prerelease mode, return true +// - else replace C with `[>=0.0.0]` +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If any C is a = range, and GT or LT are set, return false +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT.semver is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If GT.semver has a prerelease, and not in prerelease mode +// - If no C has a prerelease and the GT.semver tuple, return false +// - If LT +// - If LT.semver is greater than any < or <= comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If GT.semver has a prerelease, and not in prerelease mode +// - If no C has a prerelease and the LT.semver tuple, return false +// - Else return true -const SemVer = __nccwpck_require__(8088) +const subset = (sub, dom, options = {}) => { + if (sub === dom) + return true -const inc = (version, release, options, identifier) => { - if (typeof (options) === 'string') { - identifier = options - options = undefined - } + sub = new Range(sub, options) + dom = new Range(dom, options) + let sawNonNull = false - try { - return new SemVer(version, options).inc(release, identifier).version - } catch (er) { - return null + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options) + sawNonNull = sawNonNull || isSub !== null + if (isSub) + continue OUTER + } + // the null set is a subset of everything, but null simple ranges in + // a complex range should be ignored. so if we saw a non-null range, + // then we know this isn't a subset, but if EVERY simple range was null, + // then it is a subset. + if (sawNonNull) + return false } + return true } -module.exports = inc - -/***/ }), +const simpleSubset = (sub, dom, options) => { + if (sub === dom) + return true -/***/ 194: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (sub.length === 1 && sub[0].semver === ANY) { + if (dom.length === 1 && dom[0].semver === ANY) + return true + else if (options.includePrerelease) + sub = [ new Comparator('>=0.0.0-0') ] + else + sub = [ new Comparator('>=0.0.0') ] + } -const compare = __nccwpck_require__(4309) -const lt = (a, b, loose) => compare(a, b, loose) < 0 -module.exports = lt + if (dom.length === 1 && dom[0].semver === ANY) { + if (options.includePrerelease) + return true + else + dom = [ new Comparator('>=0.0.0') ] + } + const eqSet = new Set() + let gt, lt + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') + gt = higherGT(gt, c, options) + else if (c.operator === '<' || c.operator === '<=') + lt = lowerLT(lt, c, options) + else + eqSet.add(c.semver) + } -/***/ }), + if (eqSet.size > 1) + return null -/***/ 7520: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + let gtltComp + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options) + if (gtltComp > 0) + return null + else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + return null + } -const compare = __nccwpck_require__(4309) -const lte = (a, b, loose) => compare(a, b, loose) <= 0 -module.exports = lte + // will iterate one or zero times + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) + return null + if (lt && !satisfies(eq, String(lt), options)) + return null -/***/ }), + for (const c of dom) { + if (!satisfies(eq, String(c), options)) + return false + } -/***/ 6688: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + return true + } -const SemVer = __nccwpck_require__(8088) -const major = (a, loose) => new SemVer(a, loose).major -module.exports = major + let higher, lower + let hasDomLT, hasDomGT + // if the subset has a prerelease, we need a comparator in the superset + // with the same tuple and a prerelease, or it's not a subset + let needDomLTPre = lt && + !options.includePrerelease && + lt.semver.prerelease.length ? lt.semver : false + let needDomGTPre = gt && + !options.includePrerelease && + gt.semver.prerelease.length ? gt.semver : false + // exception: <1.2.3-0 is the same as <1.2.3 + if (needDomLTPre && needDomLTPre.prerelease.length === 1 && + lt.operator === '<' && needDomLTPre.prerelease[0] === 0) { + needDomLTPre = false + } + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' + if (gt) { + if (needDomGTPre) { + if (c.semver.prerelease && c.semver.prerelease.length && + c.semver.major === needDomGTPre.major && + c.semver.minor === needDomGTPre.minor && + c.semver.patch === needDomGTPre.patch) { + needDomGTPre = false + } + } + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options) + if (higher === c && higher !== gt) + return false + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + return false + } + if (lt) { + if (needDomLTPre) { + if (c.semver.prerelease && c.semver.prerelease.length && + c.semver.major === needDomLTPre.major && + c.semver.minor === needDomLTPre.minor && + c.semver.patch === needDomLTPre.patch) { + needDomLTPre = false + } + } + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options) + if (lower === c && lower !== lt) + return false + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + return false + } + if (!c.operator && (lt || gt) && gtltComp !== 0) + return false + } -/***/ }), + // if there was a < or >, and nothing in the dom, then must be false + // UNLESS it was limited by another range in the other direction. + // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 + if (gt && hasDomLT && !lt && gtltComp !== 0) + return false -/***/ 8447: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (lt && hasDomGT && !gt && gtltComp !== 0) + return false -const SemVer = __nccwpck_require__(8088) -const minor = (a, loose) => new SemVer(a, loose).minor -module.exports = minor + // we needed a prerelease range in a specific tuple, but didn't get one + // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, + // because it includes prereleases in the 1.2.3 tuple + if (needDomGTPre || needDomLTPre) + return false + return true +} -/***/ }), +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +} -/***/ 6017: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +} -const compare = __nccwpck_require__(4309) -const neq = (a, b, loose) => compare(a, b, loose) !== 0 -module.exports = neq +module.exports = subset /***/ }), -/***/ 5925: +/***/ 2706: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(2293) -const { re, t } = __nccwpck_require__(9523) -const SemVer = __nccwpck_require__(8088) +const Range = __nccwpck_require__(9828) -const parseOptions = __nccwpck_require__(785) -const parse = (version, options) => { - options = parseOptions(options) +// Mostly just for testing and legacy API reasons +const toComparators = (range, options) => + new Range(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) - if (version instanceof SemVer) { - return version - } +module.exports = toComparators - if (typeof version !== 'string') { - return null - } - if (version.length > MAX_LENGTH) { - return null - } +/***/ }), - const r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } +/***/ 2098: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const Range = __nccwpck_require__(9828) +const validRange = (range, options) => { try { - return new SemVer(version, options) + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' } catch (er) { return null } } - -module.exports = parse +module.exports = validRange /***/ }), -/***/ 2866: +/***/ 7032: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const SemVer = __nccwpck_require__(8088) -const patch = (a, loose) => new SemVer(a, loose).patch -module.exports = patch - - -/***/ }), +"use strict"; -/***/ 4016: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const shebangRegex = __nccwpck_require__(2638); -const parse = __nccwpck_require__(5925) -const prerelease = (version, options) => { - const parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} -module.exports = prerelease +module.exports = (string = '') => { + const match = string.match(shebangRegex); + if (!match) { + return null; + } -/***/ }), + const [path, argument] = match[0].replace(/#! ?/, '').split(' '); + const binary = path.split('/').pop(); -/***/ 6417: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (binary === 'env') { + return argument; + } -const compare = __nccwpck_require__(4309) -const rcompare = (a, b, loose) => compare(b, a, loose) -module.exports = rcompare + return argument ? `${binary} ${argument}` : binary; +}; /***/ }), -/***/ 8701: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const compareBuild = __nccwpck_require__(2156) -const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) -module.exports = rsort - - -/***/ }), +/***/ 2638: +/***/ ((module) => { -/***/ 6055: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +"use strict"; -const Range = __nccwpck_require__(9828) -const satisfies = (version, range, options) => { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} -module.exports = satisfies +module.exports = /^#!(.*)/; /***/ }), -/***/ 1426: +/***/ 4931: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const compareBuild = __nccwpck_require__(2156) -const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) -module.exports = sort - - -/***/ }), - -/***/ 9601: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// Note: since nyc uses this module to output coverage, any lines +// that are in the direct sync flow of nyc's outputCoverage are +// ignored, since we can never get coverage for them. +var assert = __nccwpck_require__(2357) +var signals = __nccwpck_require__(3710) +var isWin = /^win/i.test(process.platform) -const parse = __nccwpck_require__(5925) -const valid = (version, options) => { - const v = parse(version, options) - return v ? v.version : null +var EE = __nccwpck_require__(8614) +/* istanbul ignore if */ +if (typeof EE !== 'function') { + EE = EE.EventEmitter } -module.exports = valid - - -/***/ }), - -/***/ 1383: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// just pre-load all the stuff that index.js lazily exports -const internalRe = __nccwpck_require__(9523) -module.exports = { - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: __nccwpck_require__(2293).SEMVER_SPEC_VERSION, - SemVer: __nccwpck_require__(8088), - compareIdentifiers: __nccwpck_require__(2463).compareIdentifiers, - rcompareIdentifiers: __nccwpck_require__(2463).rcompareIdentifiers, - parse: __nccwpck_require__(5925), - valid: __nccwpck_require__(9601), - clean: __nccwpck_require__(8848), - inc: __nccwpck_require__(900), - diff: __nccwpck_require__(4297), - major: __nccwpck_require__(6688), - minor: __nccwpck_require__(8447), - patch: __nccwpck_require__(2866), - prerelease: __nccwpck_require__(4016), - compare: __nccwpck_require__(4309), - rcompare: __nccwpck_require__(6417), - compareLoose: __nccwpck_require__(2804), - compareBuild: __nccwpck_require__(2156), - sort: __nccwpck_require__(1426), - rsort: __nccwpck_require__(8701), - gt: __nccwpck_require__(4123), - lt: __nccwpck_require__(194), - eq: __nccwpck_require__(1898), - neq: __nccwpck_require__(6017), - gte: __nccwpck_require__(5522), - lte: __nccwpck_require__(7520), - cmp: __nccwpck_require__(5098), - coerce: __nccwpck_require__(3466), - Comparator: __nccwpck_require__(1532), - Range: __nccwpck_require__(9828), - satisfies: __nccwpck_require__(6055), - toComparators: __nccwpck_require__(2706), - maxSatisfying: __nccwpck_require__(579), - minSatisfying: __nccwpck_require__(832), - minVersion: __nccwpck_require__(4179), - validRange: __nccwpck_require__(2098), - outside: __nccwpck_require__(420), - gtr: __nccwpck_require__(9380), - ltr: __nccwpck_require__(3323), - intersects: __nccwpck_require__(7008), - simplifyRange: __nccwpck_require__(5297), - subset: __nccwpck_require__(7863), +var emitter +if (process.__signal_exit_emitter__) { + emitter = process.__signal_exit_emitter__ +} else { + emitter = process.__signal_exit_emitter__ = new EE() + emitter.count = 0 + emitter.emitted = {} } +// Because this emitter is a global, we have to check to see if a +// previous version of this library failed to enable infinite listeners. +// I know what you're about to say. But literally everything about +// signal-exit is a compromise with evil. Get used to it. +if (!emitter.infinite) { + emitter.setMaxListeners(Infinity) + emitter.infinite = true +} -/***/ }), - -/***/ 2293: -/***/ ((module) => { +module.exports = function (cb, opts) { + assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -const SEMVER_SPEC_VERSION = '2.0.0' + if (loaded === false) { + load() + } -const MAX_LENGTH = 256 -const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 + var ev = 'exit' + if (opts && opts.alwaysLast) { + ev = 'afterexit' + } -// Max safe segment length for coercion. -const MAX_SAFE_COMPONENT_LENGTH = 16 + var remove = function () { + emitter.removeListener(ev, cb) + if (emitter.listeners('exit').length === 0 && + emitter.listeners('afterexit').length === 0) { + unload() + } + } + emitter.on(ev, cb) -module.exports = { - SEMVER_SPEC_VERSION, - MAX_LENGTH, - MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + return remove } +module.exports.unload = unload +function unload () { + if (!loaded) { + return + } + loaded = false -/***/ }), + signals.forEach(function (sig) { + try { + process.removeListener(sig, sigListeners[sig]) + } catch (er) {} + }) + process.emit = originalProcessEmit + process.reallyExit = originalProcessReallyExit + emitter.count -= 1 +} -/***/ 427: -/***/ ((module) => { +function emit (event, code, signal) { + if (emitter.emitted[event]) { + return + } + emitter.emitted[event] = true + emitter.emit(event, code, signal) +} -const debug = ( - typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG) -) ? (...args) => console.error('SEMVER', ...args) - : () => {} +// { : , ... } +var sigListeners = {} +signals.forEach(function (sig) { + sigListeners[sig] = function listener () { + // If there are no other listeners, an exit is coming! + // Simplest way: remove us and then re-send the signal. + // We know that this will kill the process, so we can + // safely emit now. + var listeners = process.listeners(sig) + if (listeners.length === emitter.count) { + unload() + emit('exit', null, sig) + /* istanbul ignore next */ + emit('afterexit', null, sig) + /* istanbul ignore next */ + if (isWin && sig === 'SIGHUP') { + // "SIGHUP" throws an `ENOSYS` error on Windows, + // so use a supported signal instead + sig = 'SIGINT' + } + process.kill(process.pid, sig) + } + } +}) -module.exports = debug +module.exports.signals = function () { + return signals +} +module.exports.load = load -/***/ }), +var loaded = false -/***/ 2463: -/***/ ((module) => { +function load () { + if (loaded) { + return + } + loaded = true -const numeric = /^[0-9]+$/ -const compareIdentifiers = (a, b) => { - const anum = numeric.test(a) - const bnum = numeric.test(b) + // This is the number of onSignalExit's that are in play. + // It's important so that we can count the correct number of + // listeners on signals, and don't wait for the other one to + // handle it instead of us. + emitter.count += 1 - if (anum && bnum) { - a = +a - b = +b - } + signals = signals.filter(function (sig) { + try { + process.on(sig, sigListeners[sig]) + return true + } catch (er) { + return false + } + }) - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 + process.emit = processEmit + process.reallyExit = processReallyExit } -const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) +var originalProcessReallyExit = process.reallyExit +function processReallyExit (code) { + process.exitCode = code || 0 + emit('exit', process.exitCode, null) + /* istanbul ignore next */ + emit('afterexit', process.exitCode, null) + /* istanbul ignore next */ + originalProcessReallyExit.call(process, process.exitCode) +} -module.exports = { - compareIdentifiers, - rcompareIdentifiers +var originalProcessEmit = process.emit +function processEmit (ev, arg) { + if (ev === 'exit') { + if (arg !== undefined) { + process.exitCode = arg + } + var ret = originalProcessEmit.apply(this, arguments) + emit('exit', process.exitCode, null) + /* istanbul ignore next */ + emit('afterexit', process.exitCode, null) + return ret + } else { + return originalProcessEmit.apply(this, arguments) + } } /***/ }), -/***/ 785: +/***/ 3710: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) -module.exports = parseOptions - - -/***/ }), - -/***/ 9523: -/***/ ((module, exports, __nccwpck_require__) => { - -const { MAX_SAFE_COMPONENT_LENGTH } = __nccwpck_require__(2293) -const debug = __nccwpck_require__(427) -exports = module.exports = {} +// This is not the set of all possible signals. +// +// It IS, however, the set of all signals that trigger +// an exit on either Linux or BSD systems. Linux is a +// superset of the signal names supported on BSD, and +// the unknown signals just fail to register, so we can +// catch that easily enough. +// +// Don't bother with SIGKILL. It's uncatchable, which +// means that we can't fire any callbacks anyway. +// +// If a user does happen to register a handler on a non- +// fatal signal like SIGWINCH or something, and then +// exit, it'll end up firing `process.emit('exit')`, so +// the handler will be fired anyway. +// +// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised +// artificially, inherently leave the process in a +// state from which it is not safe to try and enter JS +// listeners. +module.exports = [ + 'SIGABRT', + 'SIGALRM', + 'SIGHUP', + 'SIGINT', + 'SIGTERM' +] -// The actual regexps go on exports.re -const re = exports.re = [] -const src = exports.src = [] -const t = exports.t = {} -let R = 0 +if (process.platform !== 'win32') { + module.exports.push( + 'SIGVTALRM', + 'SIGXCPU', + 'SIGXFSZ', + 'SIGUSR2', + 'SIGTRAP', + 'SIGSYS', + 'SIGQUIT', + 'SIGIOT' + // should detect profiler and enable/disable accordingly. + // see #21 + // 'SIGPROF' + ) +} -const createToken = (name, value, isGlobal) => { - const index = R++ - debug(index, value) - t[name] = index - src[index] = value - re[index] = new RegExp(value, isGlobal ? 'g' : undefined) +if (process.platform === 'linux') { + module.exports.push( + 'SIGIO', + 'SIGPOLL', + 'SIGPWR', + 'SIGSTKFLT', + 'SIGUNUSED' + ) } -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. +/***/ }), -createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') -createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') +/***/ 8174: +/***/ ((module) => { -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. +"use strict"; -createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') -// ## Main Version -// Three dot-separated numeric identifiers. +module.exports = input => { + const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt(); + const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt(); -createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + - `(${src[t.NUMERICIDENTIFIER]})\\.` + - `(${src[t.NUMERICIDENTIFIER]})`) + if (input[input.length - 1] === LF) { + input = input.slice(0, input.length - 1); + } -createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + - `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + - `(${src[t.NUMERICIDENTIFIERLOOSE]})`) + if (input[input.length - 1] === CR) { + input = input.slice(0, input.length - 1); + } -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. + return input; +}; -createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] -}|${src[t.NONNUMERICIDENTIFIER]})`) -createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] -}|${src[t.NONNUMERICIDENTIFIER]})`) +/***/ }), -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. +/***/ 4294: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] -}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) +module.exports = __nccwpck_require__(4219); -createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] -}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. +/***/ }), -createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') +/***/ 4219: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. +"use strict"; -createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] -}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. +var net = __nccwpck_require__(1631); +var tls = __nccwpck_require__(4016); +var http = __nccwpck_require__(8605); +var https = __nccwpck_require__(7211); +var events = __nccwpck_require__(8614); +var assert = __nccwpck_require__(2357); +var util = __nccwpck_require__(1669); -// 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]}?`) +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; -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]}?`) +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} -createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -createToken('GTLT', '((?:<|>)?=?)') +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} -// 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|\\*`) +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -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]}?` + - `)?)?`) +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; -createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) -createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); -// 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) +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); -// Tilde ranges. -// Meaning is "reasonably at or greater than" -createToken('LONETILDE', '(?:~>?)') + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } -createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) -exports.tildeTrimReplace = '$1~' + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); -createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) -createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) + function onFree() { + self.emit('free', socket, options); + } -// Caret ranges. -// Meaning is "at least and backwards compatible with" -createToken('LONECARET', '(?:\\^)') + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; -createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) -exports.caretTrimReplace = '$1^' +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } -createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) -createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; -// 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]})$|^$`) +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); -// 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' + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; -// 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*$`) +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); -createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + - `\\s+-\\s+` + - `(${src[t.XRANGEPLAINLOOSE]})` + - `\\s*$`) + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} -// 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*$') +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} -/***/ }), +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} -/***/ 9380: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -// Determine if version is greater than all the versions possible in the range. -const outside = __nccwpck_require__(420) -const gtr = (version, range, options) => outside(version, range, '>', options) -module.exports = gtr +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test /***/ }), -/***/ 7008: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 5840: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const Range = __nccwpck_require__(9828) -const intersects = (r1, r2, options) => { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} -module.exports = intersects +"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; + } +})); -/***/ 3323: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var _v = _interopRequireDefault(__nccwpck_require__(8628)); -const outside = __nccwpck_require__(420) -// Determine if version is less than all the versions possible in the range -const ltr = (version, range, options) => outside(version, range, '<', options) -module.exports = ltr +var _v2 = _interopRequireDefault(__nccwpck_require__(6409)); +var _v3 = _interopRequireDefault(__nccwpck_require__(5122)); -/***/ }), +var _v4 = _interopRequireDefault(__nccwpck_require__(9120)); -/***/ 579: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var _nil = _interopRequireDefault(__nccwpck_require__(5332)); -const SemVer = __nccwpck_require__(8088) -const Range = __nccwpck_require__(9828) +var _version = _interopRequireDefault(__nccwpck_require__(1595)); -const maxSatisfying = (versions, range, options) => { - let max = null - let maxSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max -} -module.exports = maxSatisfying +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); -/***/ }), +var _parse = _interopRequireDefault(__nccwpck_require__(2746)); -/***/ 832: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const SemVer = __nccwpck_require__(8088) -const Range = __nccwpck_require__(9828) -const minSatisfying = (versions, range, options) => { - let min = null - let minSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min -} -module.exports = minSatisfying +/***/ }), + +/***/ 4569: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +"use strict"; -/***/ }), -/***/ 4179: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; -const SemVer = __nccwpck_require__(8088) -const Range = __nccwpck_require__(9828) -const gt = __nccwpck_require__(4123) +var _crypto = _interopRequireDefault(__nccwpck_require__(6417)); -const minVersion = (range, loose) => { - range = new Range(range, loose) +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - let minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); } - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } + return _crypto.default.createHash('md5').update(bytes).digest(); +} - minver = null - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] +var _default = md5; +exports.default = _default; - let setMin = null - comparators.forEach((comparator) => { - // Clone to avoid manipulating the comparator's semver object. - const compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!setMin || gt(compver, setMin)) { - setMin = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error(`Unexpected operation: ${comparator.operator}`) - } - }) - if (setMin && (!minver || gt(minver, setMin))) - minver = setMin - } +/***/ }), - if (minver && range.test(minver)) { - return minver - } +/***/ 5332: +/***/ ((__unused_webpack_module, exports) => { - return null -} -module.exports = minVersion +"use strict"; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports.default = _default; + /***/ }), -/***/ 420: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 2746: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const SemVer = __nccwpck_require__(8088) -const Comparator = __nccwpck_require__(1532) -const {ANY} = Comparator -const Range = __nccwpck_require__(9828) -const satisfies = __nccwpck_require__(6055) -const gt = __nccwpck_require__(4123) -const lt = __nccwpck_require__(194) -const lte = __nccwpck_require__(7520) -const gte = __nccwpck_require__(5522) +"use strict"; -const outside = (version, range, hilo, options) => { - version = new SemVer(version, options) - range = new Range(range, options) - let gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; - // If it satisfies the range it is not outside - if (satisfies(version, range, options)) { - return false +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); } - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] + 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 ........-####-....-....-............ - let high = null - let low = null + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ - comparators.forEach((comparator) => { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } + 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) - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true + 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; } -module.exports = outside - +var _default = parse; +exports.default = _default; /***/ }), -/***/ 5297: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 814: +/***/ ((__unused_webpack_module, exports) => { -// given a set of versions and a range, create a "simplified" range -// that includes the same versions that the original range does -// If the original range is shorter than the simplified one, return that. -const satisfies = __nccwpck_require__(6055) -const compare = __nccwpck_require__(4309) -module.exports = (versions, range, options) => { - const set = [] - let min = null - let prev = null - const v = versions.sort((a, b) => compare(a, b, options)) - for (const version of v) { - const included = satisfies(version, range, options) - if (included) { - prev = version - if (!min) - min = version - } else { - if (prev) { - set.push([min, prev]) - } - prev = null - min = null - } - } - if (min) - set.push([min, null]) +"use strict"; - const ranges = [] - for (const [min, max] of set) { - if (min === max) - ranges.push(min) - else if (!max && min === v[0]) - ranges.push('*') - else if (!max) - ranges.push(`>=${min}`) - else if (min === v[0]) - ranges.push(`<=${max}`) - else - ranges.push(`${min} - ${max}`) - } - const simplified = ranges.join(' || ') - const original = typeof range.raw === 'string' ? range.raw : String(range) - return simplified.length < original.length ? simplified : range -} +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; /***/ }), -/***/ 7863: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 807: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const Range = __nccwpck_require__(9828) -const Comparator = __nccwpck_require__(1532) -const { ANY } = Comparator -const satisfies = __nccwpck_require__(6055) -const compare = __nccwpck_require__(4309) +"use strict"; -// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: -// - Every simple range `r1, r2, ...` is a null set, OR -// - Every simple range `r1, r2, ...` which is not a null set is a subset of -// some `R1, R2, ...` -// -// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: -// - If c is only the ANY comparator -// - If C is only the ANY comparator, return true -// - Else if in prerelease mode, return false -// - else replace c with `[>=0.0.0]` -// - If C is only the ANY comparator -// - if in prerelease mode, return true -// - else replace C with `[>=0.0.0]` -// - Let EQ be the set of = comparators in c -// - If EQ is more than one, return true (null set) -// - Let GT be the highest > or >= comparator in c -// - Let LT be the lowest < or <= comparator in c -// - If GT and LT, and GT.semver > LT.semver, return true (null set) -// - If any C is a = range, and GT or LT are set, return false -// - If EQ -// - If GT, and EQ does not satisfy GT, return true (null set) -// - If LT, and EQ does not satisfy LT, return true (null set) -// - If EQ satisfies every C, return true -// - Else return false -// - If GT -// - If GT.semver is lower than any > or >= comp in C, return false -// - If GT is >=, and GT.semver does not satisfy every C, return false -// - If GT.semver has a prerelease, and not in prerelease mode -// - If no C has a prerelease and the GT.semver tuple, return false -// - If LT -// - If LT.semver is greater than any < or <= comp in C, return false -// - If LT is <=, and LT.semver does not satisfy every C, return false -// - If GT.semver has a prerelease, and not in prerelease mode -// - If no C has a prerelease and the LT.semver tuple, return false -// - Else return true -const subset = (sub, dom, options = {}) => { - if (sub === dom) - return true +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = rng; - sub = new Range(sub, options) - dom = new Range(dom, options) - let sawNonNull = false +var _crypto = _interopRequireDefault(__nccwpck_require__(6417)); - OUTER: for (const simpleSub of sub.set) { - for (const simpleDom of dom.set) { - const isSub = simpleSubset(simpleSub, simpleDom, options) - sawNonNull = sawNonNull || isSub !== null - if (isSub) - continue OUTER - } - // the null set is a subset of everything, but null simple ranges in - // a complex range should be ignored. so if we saw a non-null range, - // then we know this isn't a subset, but if EVERY simple range was null, - // then it is a subset. - if (sawNonNull) - return false +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 true + + return rnds8Pool.slice(poolPtr, poolPtr += 16); } -const simpleSubset = (sub, dom, options) => { - if (sub === dom) - return true +/***/ }), - if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) - return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] - } +/***/ 5274: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) - return true - else - dom = [ new Comparator('>=0.0.0') ] - } +"use strict"; - const eqSet = new Set() - let gt, lt - for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') - gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') - lt = lowerLT(lt, c, options) - else - eqSet.add(c.semver) - } - if (eqSet.size > 1) - return null +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; - let gtltComp - if (gt && lt) { - gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) - return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) - return null +var _crypto = _interopRequireDefault(__nccwpck_require__(6417)); + +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'); } - // will iterate one or zero times - for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) - return null + return _crypto.default.createHash('sha1').update(bytes).digest(); +} - if (lt && !satisfies(eq, String(lt), options)) - return null +var _default = sha1; +exports.default = _default; - for (const c of dom) { - if (!satisfies(eq, String(c), options)) - return false - } +/***/ }), - return true - } +/***/ 8950: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - let higher, lower - let hasDomLT, hasDomGT - // if the subset has a prerelease, we need a comparator in the superset - // with the same tuple and a prerelease, or it's not a subset - let needDomLTPre = lt && - !options.includePrerelease && - lt.semver.prerelease.length ? lt.semver : false - let needDomGTPre = gt && - !options.includePrerelease && - gt.semver.prerelease.length ? gt.semver : false - // exception: <1.2.3-0 is the same as <1.2.3 - if (needDomLTPre && needDomLTPre.prerelease.length === 1 && - lt.operator === '<' && needDomLTPre.prerelease[0] === 0) { - needDomLTPre = false - } +"use strict"; - for (const c of dom) { - hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' - hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' - if (gt) { - if (needDomGTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && - c.semver.major === needDomGTPre.major && - c.semver.minor === needDomGTPre.minor && - c.semver.patch === needDomGTPre.patch) { - needDomGTPre = false - } - } - if (c.operator === '>' || c.operator === '>=') { - higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) - return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) - return false - } - if (lt) { - if (needDomLTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && - c.semver.major === needDomLTPre.major && - c.semver.minor === needDomLTPre.minor && - c.semver.patch === needDomLTPre.patch) { - needDomLTPre = false - } - } - if (c.operator === '<' || c.operator === '<=') { - lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) - return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) - return false - } - if (!c.operator && (lt || gt) && gtltComp !== 0) - return false - } - // if there was a < or >, and nothing in the dom, then must be false - // UNLESS it was limited by another range in the other direction. - // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) - return false +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; - if (lt && hasDomGT && !gt && gtltComp !== 0) - return false +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - // we needed a prerelease range in a specific tuple, but didn't get one - // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, - // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) - return false +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - return true -} +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; -// >=1.2.3 is lower than >1.2.3 -const higherGT = (a, b, options) => { - if (!a) - return b - const comp = compare(a.semver, b.semver, options) - return comp > 0 ? a - : comp < 0 ? b - : b.operator === '>' && a.operator === '>=' ? b - : a +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); } -// <=1.2.3 is higher than <1.2.3 -const lowerLT = (a, b, options) => { - if (!a) - return b - const comp = compare(a.semver, b.semver, options) - return comp < 0 ? a - : comp > 0 ? b - : b.operator === '<' && a.operator === '<=' ? b - : a -} +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 -module.exports = subset + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + return uuid; +} + +var _default = stringify; +exports.default = _default; /***/ }), -/***/ 2706: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 8628: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -const Range = __nccwpck_require__(9828) +"use strict"; -// Mostly just for testing and legacy API reasons -const toComparators = (range, options) => - new Range(range, options).set - .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) -module.exports = toComparators +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; +var _rng = _interopRequireDefault(__nccwpck_require__(807)); -/***/ }), +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); -/***/ 2098: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const Range = __nccwpck_require__(9828) -const validRange = (range, options) => { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null +// **`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]]; + } + + 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"); } -} -module.exports = validRange + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch -/***/ }), + msecs += 12219292800000; // `time_low` -/***/ 7032: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + 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` -"use strict"; + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` -const shebangRegex = __nccwpck_require__(2638); + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version -module.exports = (string = '') => { - const match = string.match(shebangRegex); + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - if (!match) { - return null; - } + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - const [path, argument] = match[0].replace(/#! ?/, '').split(' '); - const binary = path.split('/').pop(); + b[i++] = clockseq & 0xff; // `node` - if (binary === 'env') { - return argument; - } + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } - return argument ? `${binary} ${argument}` : binary; -}; + return buf || (0, _stringify.default)(b); +} +var _default = v1; +exports.default = _default; /***/ }), -/***/ 2638: -/***/ ((module) => { +/***/ 6409: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = /^#!(.*)/; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; -/***/ }), +var _v = _interopRequireDefault(__nccwpck_require__(5998)); -/***/ 4931: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var _md = _interopRequireDefault(__nccwpck_require__(4569)); -// Note: since nyc uses this module to output coverage, any lines -// that are in the direct sync flow of nyc's outputCoverage are -// ignored, since we can never get coverage for them. -var assert = __nccwpck_require__(2357) -var signals = __nccwpck_require__(3710) -var isWin = /^win/i.test(process.platform) +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var EE = __nccwpck_require__(8614) -/* istanbul ignore if */ -if (typeof EE !== 'function') { - EE = EE.EventEmitter -} +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports.default = _default; -var emitter -if (process.__signal_exit_emitter__) { - emitter = process.__signal_exit_emitter__ -} else { - emitter = process.__signal_exit_emitter__ = new EE() - emitter.count = 0 - emitter.emitted = {} -} +/***/ }), + +/***/ 5998: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; -// Because this emitter is a global, we have to check to see if a -// previous version of this library failed to enable infinite listeners. -// I know what you're about to say. But literally everything about -// signal-exit is a compromise with evil. Get used to it. -if (!emitter.infinite) { - emitter.setMaxListeners(Infinity) - emitter.infinite = true -} -module.exports = function (cb, opts) { - assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = _default; +exports.URL = exports.DNS = void 0; - if (loaded === false) { - load() - } +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); - var ev = 'exit' - if (opts && opts.alwaysLast) { - ev = 'afterexit' - } +var _parse = _interopRequireDefault(__nccwpck_require__(2746)); - var remove = function () { - emitter.removeListener(ev, cb) - if (emitter.listeners('exit').length === 0 && - emitter.listeners('afterexit').length === 0) { - unload() - } - } - emitter.on(ev, cb) +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - return remove -} +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape -module.exports.unload = unload -function unload () { - if (!loaded) { - return + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); } - loaded = false - signals.forEach(function (sig) { - try { - process.removeListener(sig, sigListeners[sig]) - } catch (er) {} - }) - process.emit = originalProcessEmit - process.reallyExit = originalProcessReallyExit - emitter.count -= 1 + return bytes; } -function emit (event, code, signal) { - if (emitter.emitted[event]) { - return - } - emitter.emitted[event] = true - emitter.emit(event, code, signal) -} +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; -// { : , ... } -var sigListeners = {} -signals.forEach(function (sig) { - sigListeners[sig] = function listener () { - // If there are no other listeners, an exit is coming! - // Simplest way: remove us and then re-send the signal. - // We know that this will kill the process, so we can - // safely emit now. - var listeners = process.listeners(sig) - if (listeners.length === emitter.count) { - unload() - emit('exit', null, sig) - /* istanbul ignore next */ - emit('afterexit', null, sig) - /* istanbul ignore next */ - if (isWin && sig === 'SIGHUP') { - // "SIGHUP" throws an `ENOSYS` error on Windows, - // so use a supported signal instead - sig = 'SIGINT' - } - process.kill(process.pid, sig) +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); } - } -}) -module.exports.signals = function () { - return signals -} + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } -module.exports.load = load + 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])` -var loaded = false -function load () { - if (loaded) { - return - } - loaded = true + 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; - // This is the number of onSignalExit's that are in play. - // It's important so that we can count the correct number of - // listeners on signals, and don't wait for the other one to - // handle it instead of us. - emitter.count += 1 + if (buf) { + offset = offset || 0; - signals = signals.filter(function (sig) { - try { - process.on(sig, sigListeners[sig]) - return true - } catch (er) { - return false + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; } - }) - process.emit = processEmit - process.reallyExit = processReallyExit -} + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) -var originalProcessReallyExit = process.reallyExit -function processReallyExit (code) { - process.exitCode = code || 0 - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - /* istanbul ignore next */ - originalProcessReallyExit.call(process, process.exitCode) + + 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; } -var originalProcessEmit = process.emit -function processEmit (ev, arg) { - if (ev === 'exit') { - if (arg !== undefined) { - process.exitCode = arg +/***/ }), + +/***/ 5122: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(807)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(8950)); + +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]; } - var ret = originalProcessEmit.apply(this, arguments) - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - return ret - } else { - return originalProcessEmit.apply(this, arguments) + + return buf; } + + return (0, _stringify.default)(rnds); } +var _default = v4; +exports.default = _default; /***/ }), -/***/ 3710: -/***/ ((module) => { +/***/ 9120: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// This is not the set of all possible signals. -// -// It IS, however, the set of all signals that trigger -// an exit on either Linux or BSD systems. Linux is a -// superset of the signal names supported on BSD, and -// the unknown signals just fail to register, so we can -// catch that easily enough. -// -// Don't bother with SIGKILL. It's uncatchable, which -// means that we can't fire any callbacks anyway. -// -// If a user does happen to register a handler on a non- -// fatal signal like SIGWINCH or something, and then -// exit, it'll end up firing `process.emit('exit')`, so -// the handler will be fired anyway. -// -// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised -// artificially, inherently leave the process in a -// state from which it is not safe to try and enter JS -// listeners. -module.exports = [ - 'SIGABRT', - 'SIGALRM', - 'SIGHUP', - 'SIGINT', - 'SIGTERM' -] +"use strict"; -if (process.platform !== 'win32') { - module.exports.push( - 'SIGVTALRM', - 'SIGXCPU', - 'SIGXFSZ', - 'SIGUSR2', - 'SIGTRAP', - 'SIGSYS', - 'SIGQUIT', - 'SIGIOT' - // should detect profiler and enable/disable accordingly. - // see #21 - // 'SIGPROF' - ) -} -if (process.platform === 'linux') { - module.exports.push( - 'SIGIO', - 'SIGPOLL', - 'SIGPWR', - 'SIGSTKFLT', - 'SIGUNUSED' - ) +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5998)); + +var _sha = _interopRequireDefault(__nccwpck_require__(5274)); + +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; + +/***/ }), + +/***/ 6900: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(814)); + +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; /***/ }), -/***/ 8174: -/***/ ((module) => { +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -module.exports = input => { - const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt(); - const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt(); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.default = void 0; - if (input[input.length - 1] === LF) { - input = input.slice(0, input.length - 1); - } +var _validate = _interopRequireDefault(__nccwpck_require__(6900)); - if (input[input.length - 1] === CR) { - input = input.slice(0, input.length - 1); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - return input; -}; +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; /***/ }), @@ -12056,6 +14349,14 @@ module.exports = require("child_process");; /***/ }), +/***/ 6417: +/***/ ((module) => { + +"use strict"; +module.exports = require("crypto");; + +/***/ }), + /***/ 8614: /***/ ((module) => { @@ -12072,6 +14373,30 @@ module.exports = require("fs");; /***/ }), +/***/ 8605: +/***/ ((module) => { + +"use strict"; +module.exports = require("http");; + +/***/ }), + +/***/ 7211: +/***/ ((module) => { + +"use strict"; +module.exports = require("https");; + +/***/ }), + +/***/ 1631: +/***/ ((module) => { + +"use strict"; +module.exports = require("net");; + +/***/ }), + /***/ 2087: /***/ ((module) => { @@ -12096,6 +14421,14 @@ module.exports = require("stream");; /***/ }), +/***/ 4016: +/***/ ((module) => { + +"use strict"; +module.exports = require("tls");; + +/***/ }), + /***/ 1669: /***/ ((module) => {