diff --git a/action.yml b/action.yml index ae76e7a94e..d9e665f3a9 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,7 @@ inputs: CONFIG_FILE: description: "Path to configuration file" default: "./.github/recent-activity.config.yml" + required: false branding: color: orange diff --git a/dist/index.js b/dist/index.js index f7f4ec7233..b4e9a56844 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,765 +1,6 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 5532: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const core = __nccwpck_require__(2186); - -const parseYaml = __nccwpck_require__(8414); - -const defaultVals = { - username: core.getInput("GH_USERNAME"), - commit_msg: "⚡ Update README with the recent activity", - max_lines: 5, - readme_file: "./README.md", - disabled_events: [], - url_text: "{REPO}{ID}", - date: { - timezone: "0", - text: "Last Updated: {DATE}", - format: "dddd, mmmm dS, yyyy, h:MM:ss TT", - }, - comments: "💬 Commented on {ID} in {REPO}", - issue_opened: "❗️ Opened issue {ID} in {REPO}", - issue_closed: "✔️ Closed issue {ID} in {REPO}", - pr_opened: "💪 Opened PR {ID} in {REPO}", - pr_closed: "❌ Closed PR {ID} in {REPO}", - pr_merged: "🎉 Merged PR {ID} in {REPO}", - create_repo: "📔 Created new repository {REPO}", - fork_repo: "🔱 Forked {FORK} from {REPO}", - wiki_create: "📖 Created new wiki page {WIKI} in {REPO}", - added_member: "🤝 Became collaborator on {REPO}", - changes_approved: "👍 Approved {ID} in {REPO}", - changes_requested: "🔴 Requested changes in {ID} in {REPO}", - new_release: "✌️ Released {ID} in {REPO}", - new_star: "⭐ Starred {REPO}", -}; - -const userVals = parseYaml(core.getInput("CONFIG_FILE")); - -if (userVals.settings) { - userVals.settings.date = { ...defaultVals.date, ...userVals.settings.date }; -} - -let conf = { - ...defaultVals, - ...userVals.settings, - ...userVals.messages, -}; - -let disabled = []; -conf.disabled_events.forEach((event) => { - disabled.push(event.trim().toLowerCase()); -}); - -conf.disabled_events = disabled; - -const urlPrefix = "https://github.com"; - -module.exports = { - ...conf, - urlPrefix, -}; - - -/***/ }), - -/***/ 6986: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { comments } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const CommitCommentEvent = (item) => { - if (item.payload.action === "created") { - return comments - .replace(/{ID}/g, toUrlFormat(item, "commit_comment")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "commit_comment")) - .replace(/{URL}/g, makeCustomUrl(item, "commit_comment")); - } else { - return ""; - } -}; - -module.exports = CommitCommentEvent; - - -/***/ }), - -/***/ 7744: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { create_repo } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const CreateEvent = (item) => { - if (item.payload.ref_type === "repository") { - return create_repo - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "create_repo")) - .replace(/{URL}/g, makeCustomUrl(item, "create_repo")); - } else { - return ""; - } -}; - -module.exports = CreateEvent; - - -/***/ }), - -/***/ 9634: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { fork_repo } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const ForkEvent = (item) => { - return fork_repo - .replace(/{FORK}/g, toUrlFormat(item, "fork")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "fork")) - .replace(/{URL}/g, makeCustomUrl(item, "fork")); -}; - -module.exports = ForkEvent; - - -/***/ }), - -/***/ 7021: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { wiki_create } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const GollumEvent = (item) => { - let finalArray = []; - item.payload.pages.forEach((page) => { - if (page.action === "created") { - page.repo_name = item.repo.name; - finalArray.push( - wiki_create - .replace(/{WIKI}/g, toUrlFormat(page, "wiki")) - .replace(/{REPO}/g, toUrlFormat(page.repo_name, "wiki")) - .replace(/{URL}/g, makeCustomUrl(page, "wiki")) - ); - } - }); - - if (finalArray.length == 0) { - return ""; - } else { - return finalArray; - } -}; - -module.exports = GollumEvent; - - -/***/ }), - -/***/ 454: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { comments } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const IssueCommentEvent = (item) => { - if (item.payload.action === "created") { - return comments - .replace(/{ID}/g, toUrlFormat(item, "issue_comment")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_comment")) - .replace(/{URL}/g, makeCustomUrl(item, "issue_comment")); - } else { - return ""; - } -}; - -module.exports = IssueCommentEvent; - - -/***/ }), - -/***/ 1183: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { issue_opened, issue_closed } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const IssuesEvent = (item) => { - if (item.payload.action === "opened") { - return issue_opened - .replace(/{ID}/g, toUrlFormat(item, "issue_open")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_open")) - .replace(/{URL}/g, makeCustomUrl(item, "issue_open")); - } else if (item.payload.action === "closed") { - return issue_closed - .replace(/{ID}/g, toUrlFormat(item, "issue_close")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_close")) - .replace(/{URL}/g, makeCustomUrl(item, "issue_close")); - } else { - return ""; - } -}; - -module.exports = IssuesEvent; - - -/***/ }), - -/***/ 466: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { added_member } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const MemberEvent = (item) => { - if (item.payload.action === "added") { - return added_member - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "member")) - .replace(/{URL}/g, makeCustomUrl(item, "member")); - } else { - return ""; - } -}; - -module.exports = MemberEvent; - - -/***/ }), - -/***/ 8089: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { pr_opened, pr_merged, pr_closed } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const PullRequestEvent = (item) => { - if (item.payload.action === "opened") { - return pr_opened - .replace(/{ID}/g, toUrlFormat(item, "pr_open")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_open")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_open")); - } else if (item.payload.pull_request.merged) { - return pr_merged - .replace(/{ID}/g, toUrlFormat(item, "pr_merge")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_merge")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_merge")); - } else if ( - item.payload.action === "closed" && - !item.payload.pull_request.merged - ) { - return pr_closed - .replace(/{ID}/g, toUrlFormat(item, "pr_close")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_close")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_close")); - } else { - return ""; - } -}; - -module.exports = PullRequestEvent; - - -/***/ }), - -/***/ 1552: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { comments } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const PullRequestReviewCommentEvent = (item) => { - if (item.payload.action === "created") { - return comments - .replace(/{ID}/g, toUrlFormat(item, "pr_review_comment")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review_comment")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_review_comment")); - } else { - return ""; - } -}; - -module.exports = PullRequestReviewCommentEvent; - - -/***/ }), - -/***/ 2185: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { changes_approved, changes_requested } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const PullRequestReviewEvent = (item) => { - if ( - item.payload.action === "created" && - item.payload.review.state == "approved" - ) { - return changes_approved - .replace(/{ID}/g, toUrlFormat(item, "pr_review")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_review")); - } else if ( - item.payload.action === "created" && - item.payload.review.state == "changes_requested" - ) { - return changes_requested - .replace(/{ID}/g, toUrlFormat(item, "pr_review")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review")) - .replace(/{URL}/g, makeCustomUrl(item, "pr_review")); - } else { - return ""; - } -}; - -module.exports = PullRequestReviewEvent; - - -/***/ }), - -/***/ 2348: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { new_release } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const ReleaseEvent = (item) => { - if (item.payload.action === "published") { - return new_release - .replace(/{ID}/g, toUrlFormat(item, "release")) - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "release")) - .replace(/{URL}/g, makeCustomUrl(item, "release")); - } else { - return ""; - } -}; - -module.exports = ReleaseEvent; - - -/***/ }), - -/***/ 7137: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const { new_star } = __nccwpck_require__(5532); -const makeCustomUrl = __nccwpck_require__(9397); -const toUrlFormat = __nccwpck_require__(394); - -const WatchEvent = (item) => { - if (item.payload.action === "started") { - return new_star - .replace(/{REPO}/g, toUrlFormat(item.repo.name, "star")) - .replace(/{URL}/g, makeCustomUrl(item, "star")); - } else { - return ""; - } -}; - -module.exports = WatchEvent; - - -/***/ }), - -/***/ 2310: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const dateFormat = __nccwpck_require__(1512); - -const { date } = __nccwpck_require__(5532); - -const appendDate = (fullContent) => { - let dateStartIdx = fullContent.findIndex( - (content) => content.trim() === "" - ); - - if (dateStartIdx !== -1) { - let dateEndIdx = fullContent.findIndex( - (content, index) => - content.trim() === "" && - index > dateStartIdx - ); - - let offset; - let finalDate; - - if (date.timezone.split("/").length === 2) { - process.env.TZ = date.timezone; - finalDate = new Date(); - } else { - let tz = date.timezone.replace("GMT", "").split(":"); - let tz_hours = parseInt(tz[0].trim()); - - if (tz.length > 1) { - offset = tz_hours * 60 + parseInt(tz[1].trim()); - } else { - if (tz_hours > 99) { - offset = Math.floor(tz_hours / 100) * 60 + (tz_hours % 100); - } else { - offset = tz_hours * 60; - } - } - - const utc = new Date().getTime() + new Date().getTimezoneOffset() * 60000; - finalDate = new Date(utc + offset * 60000); - } - - finalDateString = date.text.replace( - "{DATE}", - dateFormat(finalDate, date.format) - ); - - if (dateEndIdx === -1) { - fullContent.splice( - dateStartIdx + 1, - 0, - finalDateString, - "" - ); - } else { - fullContent.splice( - dateStartIdx + 1, - dateEndIdx - dateStartIdx - 1, - finalDateString - ); - } - } - return fullContent; -}; - -module.exports = appendDate; - - -/***/ }), - -/***/ 3803: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const { readme_file, commit_msg } = __nccwpck_require__(5532); - -const exec = __nccwpck_require__(4058); - -/** - * Make a commit - * - * @returns {Promise} - */ - -const commitFile = async () => { - await exec("git", [ - "config", - "--global", - "user.email", - "41898282+github-actions[bot]@users.noreply.github.com", - ]); - await exec("git", ["config", "--global", "user.name", "readme-bot"]); - await exec("git", ["add", readme_file]); - await exec("git", ["commit", "-m", commit_msg]); - await exec("git", ["push"]); -}; - -module.exports = commitFile; - - -/***/ }), - -/***/ 4058: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const { spawn } = __nccwpck_require__(3129); - -/** - * Execute shell command - * @param {String} cmd - root command - * @param {String[]} args - args to be passed along with - * - * @returns {Promise} - */ - -const exec = (cmd, args = []) => - new Promise((resolve, reject) => { - const app = spawn(cmd, args, { stdio: "pipe" }); - let stdout = ""; - app.stdout.on("data", (data) => { - stdout = data; - }); - app.on("close", (code) => { - if (code !== 0 && !stdout.includes("nothing to commit")) { - err = new Error(`Invalid status code: ${code}`); - err.code = code; - return reject(err); - } - return resolve(code); - }); - app.on("error", reject); - }); - -module.exports = exec; - - -/***/ }), - -/***/ 9347: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const serializers = __nccwpck_require__(102); -const { max_lines } = __nccwpck_require__(5532); - -const filterContent = (eventData) => { - let temp_content = []; - - for (i = 0; i < eventData.length; i++) { - let event_string = serializers[eventData[i].type](eventData[i]); - - if (event_string !== "") { - temp_content.push(event_string); - } - if (temp_content.length == max_lines) { - break; - } - } - - temp_content = temp_content.flat(); - temp_content.length = max_lines; - - console.log(temp_content); - - return temp_content; -}; - -module.exports = filterContent; - - -/***/ }), - -/***/ 9397: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const { url_text, urlPrefix } = __nccwpck_require__(5532); - -const makeCustomUrl = (item, type) => { - let url; - switch (type.toLowerCase()) { - case "issue_open": - case "issue_close": - url = - `[` + - url_text - .replace(/{ID}/g, `#${item.payload.issue.number}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.issue.html_url})`; - break; - case "issue_comment": - url = - `[` + - url_text - .replace(/{ID}/g, `#${item.payload.issue.number}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.comment.html_url})`; - break; - case "commit_comment": - url = - `[` + - url_text - .replace(/{ID}/g, `#commit`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.comment.html_url})`; - break; - case "pr_review_comment": - url = - `[` + - url_text - .replace(/{ID}/g, `#${item.payload.pull_request.number}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.comment.html_url})`; - break; - case "pr_open": - case "pr_close": - case "pr_merge": - url = - `[` + - url_text - .replace(/{ID}/g, `#${item.payload.pull_request.number}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.pull_request.html_url})`; - break; - case "pr_review": - url = - `[` + - url_text - .replace(/{ID}/g, `#${item.payload.pull_request.number}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.review.html_url})`; - break; - case "create_repo": - case "member": - case "star": - url = - `[` + - url_text.replace(/{REPO}/g, item.repo.name) + - `](${urlPrefix}/${item.repo.name})`; - break; - case "fork": - url = - `[` + - url_text - .replace(/{ID}/g, `${item.payload.forkee.full_name}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.forkee.html_url})`; - break; - case "wiki": - url = - `[` + - url_text - .replace(/{ID}/g, `${item.page_name}`) - .replace(/{REPO}/g, item.repo_name) + - `](${item.html_url})`; - break; - case "release": - url = - `[` + - url_text - .replace(/{ID}/g, `${item.payload.release.name}`) - .replace(/{REPO}/g, item.repo.name) + - `](${item.payload.release.html_url})`; - break; - default: - tools.exit.failure("Failed while creating the url string."); - break; - } - return url; -}; - -module.exports = makeCustomUrl; - - -/***/ }), - -/***/ 8414: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const yaml = __nccwpck_require__(1917); -const fs = __nccwpck_require__(5747); - -//const { config_file } = require("../config"); - -const parseYaml = (file) => { - try { - return yaml.load(fs.readFileSync(file, "utf8")); - } catch (error) { - console.error(error); - return {}; - } -}; - -module.exports = parseYaml; - - -/***/ }), - -/***/ 394: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * Copyright (c) 2020 James George - * Copyright (c) 2021 The Readme-Workflows organisation and Contributors - */ - -const { urlPrefix } = __nccwpck_require__(5532); - -const toUrlFormat = (item, type) => { - let url; - if (typeof item === "object") { - switch (type.toLowerCase()) { - case "issue_open": - case "issue_close": - url = `[#${item.payload.issue.number}](${item.payload.issue.html_url})`; - break; - case "issue_comment": - url = `[#${item.payload.issue.number}](${item.payload.comment.html_url})`; - break; - case "commit_comment": - url = `[commit](${item.payload.comment.html_url})`; - break; - case "pr_review_comment": - url = `[#${item.payload.pull_request.number}](${item.payload.comment.html_url})`; - break; - case "pr_open": - case "pr_close": - case "pr_merge": - url = `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`; - break; - case "pr_review": - url = `[#${item.payload.pull_request.number}](${item.payload.review.html_url})`; - break; - case "fork": - url = `[${item.payload.forkee.full_name}](${item.payload.forkee.html_url})`; - break; - case "wiki": - url = `[${item.page_name}](${item.html_url})`; - break; - case "release": - url = `[${item.payload.release.name}](${item.payload.release.html_url})`; - break; - default: - tools.exit.failure("Failed while creating the url format."); - break; - } - return url; - } - return `[${item}](${urlPrefix}/${item})`; -}; - -module.exports = toUrlFormat; - - -/***/ }), - /***/ 7351: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { @@ -14669,5515 +13910,6274 @@ var YAML_TIMESTAMP_REGEXP = new RegExp( '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour '(?::([0-9][0-9]))?))?$'); // [11] tz_minute -function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; -} +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} + +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; +} + +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} + +module.exports = new Type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); + + +/***/ }), + +/***/ 5586: +/***/ ((module) => { + +"use strict"; + + +module.exports = parseJson +function parseJson (txt, reviver, context) { + context = context || 20 + try { + return JSON.parse(txt, reviver) + } catch (e) { + if (typeof txt !== 'string') { + const isEmptyArray = Array.isArray(txt) && txt.length === 0 + const errorMessage = 'Cannot parse ' + + (isEmptyArray ? 'an empty array' : String(txt)) + throw new TypeError(errorMessage) + } + const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i) + const errIdx = syntaxErr + ? +syntaxErr[1] + : e.message.match(/^Unexpected end of JSON.*/i) + ? txt.length - 1 + : null + if (errIdx != null) { + const start = errIdx <= context + ? 0 + : errIdx - context + const end = errIdx + context >= txt.length + ? txt.length + : errIdx + context + e.message += ` while parsing near '${ + start === 0 ? '' : '...' + }${txt.slice(start, end)}${ + end === txt.length ? '' : '...' + }'` + } else { + e.message += ` while parsing '${txt.slice(0, context * 2)}'` + } + throw e + } +} + + +/***/ }), + +/***/ 5978: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const path = __nccwpck_require__(5622); +const fs = __nccwpck_require__(7758); +const stripBom = __nccwpck_require__(8551); +const parseJson = __nccwpck_require__(6615); +const pify = __nccwpck_require__(4810); + +const parse = (data, fp) => parseJson(stripBom(data), path.relative('.', fp)); + +module.exports = fp => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp)); +module.exports.sync = fp => parse(fs.readFileSync(fp, 'utf8'), fp); + + +/***/ }), + +/***/ 3447: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const path = __nccwpck_require__(5622); +const pathExists = __nccwpck_require__(6978); +const pLocate = __nccwpck_require__(104); + +module.exports = (iterable, opts) => { + opts = Object.assign({ + cwd: process.cwd() + }, opts); + + return pLocate(iterable, el => pathExists(path.resolve(opts.cwd, el)), opts); +}; + +module.exports.sync = (iterable, opts) => { + opts = Object.assign({ + cwd: process.cwd() + }, opts); + + for (const el of iterable) { + if (pathExists.sync(path.resolve(opts.cwd, el))) { + return el; + } + } +}; + + +/***/ }), + +/***/ 7493: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const os = __nccwpck_require__(2087); + +const nameMap = new Map([ + [20, ['Big Sur', '11']], + [19, ['Catalina', '10.15']], + [18, ['Mojave', '10.14']], + [17, ['High Sierra', '10.13']], + [16, ['Sierra', '10.12']], + [15, ['El Capitan', '10.11']], + [14, ['Yosemite', '10.10']], + [13, ['Mavericks', '10.9']], + [12, ['Mountain Lion', '10.8']], + [11, ['Lion', '10.7']], + [10, ['Snow Leopard', '10.6']], + [9, ['Leopard', '10.5']], + [8, ['Tiger', '10.4']], + [7, ['Panther', '10.3']], + [6, ['Jaguar', '10.2']], + [5, ['Puma', '10.1']] +]); + +const macosRelease = release => { + release = Number((release || os.release()).split('.')[0]); + + const [name, version] = nameMap.get(release); + + return { + name, + version + }; +}; + +module.exports = macosRelease; +// TODO: remove this in the next major version +module.exports.default = macosRelease; + -function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; +/***/ }), - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); +/***/ 5871: +/***/ ((module) => { - if (match === null) throw new Error('Date resolve error'); +module.exports = function (args, opts) { + if (!opts) opts = {}; + + var flags = { bools : {}, strings : {}, unknownFn: null }; - // match: [1] year [2] month [3] day + if (typeof opts['unknown'] === 'function') { + flags.unknownFn = opts['unknown']; + } - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); + if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { + flags.allBools = true; + } else { + [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { + flags.bools[key] = true; + }); + } + + var aliases = {}; + Object.keys(opts.alias || {}).forEach(function (key) { + aliases[key] = [].concat(opts.alias[key]); + aliases[key].forEach(function (x) { + aliases[x] = [key].concat(aliases[key].filter(function (y) { + return x !== y; + })); + }); + }); - if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); - } + [].concat(opts.string).filter(Boolean).forEach(function (key) { + flags.strings[key] = true; + if (aliases[key]) { + flags.strings[aliases[key]] = true; + } + }); - // match: [4] hour [5] minute [6] second [7] fraction + var defaults = opts['default'] || {}; + + var argv = { _ : [] }; + Object.keys(flags.bools).forEach(function (key) { + setArg(key, defaults[key] === undefined ? false : defaults[key]); + }); + + var notFlags = []; - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); + if (args.indexOf('--') !== -1) { + notFlags = args.slice(args.indexOf('--')+1); + args = args.slice(0, args.indexOf('--')); + } - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { // milli-seconds - fraction += '0'; + function argDefined(key, arg) { + return (flags.allBools && /^--[^=]+$/.test(arg)) || + flags.strings[key] || flags.bools[key] || aliases[key]; } - fraction = +fraction; - } - // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + function setArg (key, val, arg) { + if (arg && flags.unknownFn && !argDefined(key, arg)) { + if (flags.unknownFn(arg) === false) return; + } - if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; - } + var value = !flags.strings[key] && isNumber(val) + ? Number(val) : val + ; + setKey(argv, key.split('.'), value); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), value); + }); + } + + function setKey (obj, keys, value) { + var o = obj; + for (var i = 0; i < keys.length-1; i++) { + var key = keys[i]; + if (key === '__proto__') return; + if (o[key] === undefined) o[key] = {}; + if (o[key] === Object.prototype || o[key] === Number.prototype + || o[key] === String.prototype) o[key] = {}; + if (o[key] === Array.prototype) o[key] = []; + o = o[key]; + } + + var key = keys[keys.length - 1]; + if (key === '__proto__') return; + if (o === Object.prototype || o === Number.prototype + || o === String.prototype) o = {}; + if (o === Array.prototype) o = []; + if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { + o[key] = value; + } + else if (Array.isArray(o[key])) { + o[key].push(value); + } + else { + o[key] = [ o[key], value ]; + } + } + + function aliasIsBoolean(key) { + return aliases[key].some(function (x) { + return flags.bools[x]; + }); + } + + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + + if (/^--.+=/.test(arg)) { + // Using [\s\S] instead of . because js doesn't support the + // 'dotall' regex modifier. See: + // http://stackoverflow.com/a/1068308/13216 + var m = arg.match(/^--([^=]+)=([\s\S]*)$/); + var key = m[1]; + var value = m[2]; + if (flags.bools[key]) { + value = value !== 'false'; + } + setArg(key, value, arg); + } + else if (/^--no-.+/.test(arg)) { + var key = arg.match(/^--no-(.+)/)[1]; + setArg(key, false, arg); + } + else if (/^--.+/.test(arg)) { + var key = arg.match(/^--(.+)/)[1]; + var next = args[i + 1]; + if (next !== undefined && !/^-/.test(next) + && !flags.bools[key] + && !flags.allBools + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, next, arg); + i++; + } + else if (/^(true|false)$/.test(next)) { + setArg(key, next === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + else if (/^-[^-]+/.test(arg)) { + var letters = arg.slice(1,-1).split(''); + + var broken = false; + for (var j = 0; j < letters.length; j++) { + var next = arg.slice(j+2); + + if (next === '-') { + setArg(letters[j], next, arg) + continue; + } + + if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { + setArg(letters[j], next.split('=')[1], arg); + broken = true; + break; + } + + if (/[A-Za-z]/.test(letters[j]) + && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { + setArg(letters[j], next, arg); + broken = true; + break; + } + + if (letters[j+1] && letters[j+1].match(/\W/)) { + setArg(letters[j], arg.slice(j+2), arg); + broken = true; + break; + } + else { + setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); + } + } + + var key = arg.slice(-1)[0]; + if (!broken && key !== '-') { + if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) + && !flags.bools[key] + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, args[i+1], arg); + i++; + } + else if (args[i+1] && /^(true|false)$/.test(args[i+1])) { + setArg(key, args[i+1] === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + } + else { + if (!flags.unknownFn || flags.unknownFn(arg) !== false) { + argv._.push( + flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) + ); + } + if (opts.stopEarly) { + argv._.push.apply(argv._, args.slice(i + 1)); + break; + } + } + } + + Object.keys(defaults).forEach(function (key) { + if (!hasKey(argv, key.split('.'))) { + setKey(argv, key.split('.'), defaults[key]); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), defaults[key]); + }); + } + }); + + if (opts['--']) { + argv['--'] = new Array(); + notFlags.forEach(function(key) { + argv['--'].push(key); + }); + } + else { + notFlags.forEach(function(key) { + argv._.push(key); + }); + } - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + return argv; +}; - if (delta) date.setTime(date.getTime() - delta); +function hasKey (obj, keys) { + var o = obj; + keys.slice(0,-1).forEach(function (key) { + o = (o[key] || {}); + }); - return date; + var key = keys[keys.length - 1]; + return key in o; } -function representYamlTimestamp(object /*, style*/) { - return object.toISOString(); +function isNumber (x) { + if (typeof x === 'number') return true; + if (/^0x[0-9a-f]+$/i.test(x)) return true; + return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); } -module.exports = new Type('tag:yaml.org,2002:timestamp', { - kind: 'scalar', - resolve: resolveYamlTimestamp, - construct: constructYamlTimestamp, - instanceOf: Date, - represent: representYamlTimestamp -}); /***/ }), -/***/ 5586: +/***/ 8560: /***/ ((module) => { "use strict"; -module.exports = parseJson -function parseJson (txt, reviver, context) { - context = context || 20 - try { - return JSON.parse(txt, reviver) - } catch (e) { - if (typeof txt !== 'string') { - const isEmptyArray = Array.isArray(txt) && txt.length === 0 - const errorMessage = 'Cannot parse ' + - (isEmptyArray ? 'an empty array' : String(txt)) - throw new TypeError(errorMessage) - } - const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i) - const errIdx = syntaxErr - ? +syntaxErr[1] - : e.message.match(/^Unexpected end of JSON.*/i) - ? txt.length - 1 - : null - if (errIdx != null) { - const start = errIdx <= context - ? 0 - : errIdx - context - const end = errIdx + context >= txt.length - ? txt.length - : errIdx + context - e.message += ` while parsing near '${ - start === 0 ? '' : '...' - }${txt.slice(start, end)}${ - end === txt.length ? '' : '...' - }'` - } else { - e.message += ` while parsing '${txt.slice(0, context * 2)}'` - } - throw e - } -} +/** + * Tries to execute a function and discards any error that occurs. + * @param {Function} fn - Function that might or might not throw an error. + * @returns {?*} Return-value of the function when no error occurred. + */ +module.exports = function(fn) { + + try { return fn() } catch (e) {} +} /***/ }), -/***/ 5978: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 467: +/***/ ((module, exports, __nccwpck_require__) => { "use strict"; -const path = __nccwpck_require__(5622); -const fs = __nccwpck_require__(7758); -const stripBom = __nccwpck_require__(8551); -const parseJson = __nccwpck_require__(6615); -const pify = __nccwpck_require__(4810); -const parse = (data, fp) => parseJson(stripBom(data), path.relative('.', fp)); +Object.defineProperty(exports, "__esModule", ({ value: true })); -module.exports = fp => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp)); -module.exports.sync = fp => parse(fs.readFileSync(fp, 'utf8'), fp); +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } +var Stream = _interopDefault(__nccwpck_require__(2413)); +var http = _interopDefault(__nccwpck_require__(8605)); +var Url = _interopDefault(__nccwpck_require__(8835)); +var https = _interopDefault(__nccwpck_require__(7211)); +var zlib = _interopDefault(__nccwpck_require__(8761)); -/***/ }), +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js -/***/ 3447: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; -"use strict"; +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); -const path = __nccwpck_require__(5622); -const pathExists = __nccwpck_require__(6978); -const pLocate = __nccwpck_require__(104); +class Blob { + constructor() { + this[TYPE] = ''; -module.exports = (iterable, opts) => { - opts = Object.assign({ - cwd: process.cwd() - }, opts); + const blobParts = arguments[0]; + const options = arguments[1]; - return pLocate(iterable, el => pathExists(path.resolve(opts.cwd, el)), opts); -}; + const buffers = []; + let size = 0; -module.exports.sync = (iterable, opts) => { - opts = Object.assign({ - cwd: process.cwd() - }, opts); + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } - for (const el of iterable) { - if (pathExists.sync(path.resolve(opts.cwd, el))) { - return el; + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; } } -}; + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = __nccwpck_require__(2877).convert; +} catch (e) {} +const INTERNALS = Symbol('Body internals'); -/***/ }), +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; -/***/ 7493: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; -"use strict"; + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; -const os = __nccwpck_require__(2087); + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; -const nameMap = new Map([ - [20, ['Big Sur', '11']], - [19, ['Catalina', '10.15']], - [18, ['Mojave', '10.14']], - [17, ['High Sierra', '10.13']], - [16, ['Sierra', '10.12']], - [15, ['El Capitan', '10.11']], - [14, ['Yosemite', '10.10']], - [13, ['Mavericks', '10.9']], - [12, ['Mountain Lion', '10.8']], - [11, ['Lion', '10.7']], - [10, ['Snow Leopard', '10.6']], - [9, ['Leopard', '10.5']], - [8, ['Tiger', '10.4']], - [7, ['Panther', '10.3']], - [6, ['Jaguar', '10.2']], - [5, ['Puma', '10.1']] -]); + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; -const macosRelease = release => { - release = Number((release || os.release()).split('.')[0]); + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} - const [name, version] = nameMap.get(release); +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, - return { - name, - version - }; -}; + get bodyUsed() { + return this[INTERNALS].disturbed; + }, -module.exports = macosRelease; -// TODO: remove this in the next major version -module.exports.default = macosRelease; + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, -/***/ }), + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; -/***/ 5871: -/***/ ((module) => { + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, -module.exports = function (args, opts) { - if (!opts) opts = {}; - - var flags = { bools : {}, strings : {}, unknownFn: null }; + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, - if (typeof opts['unknown'] === 'function') { - flags.unknownFn = opts['unknown']; - } + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, - if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { - flags.allBools = true; - } else { - [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { - flags.bools[key] = true; - }); - } - - var aliases = {}; - Object.keys(opts.alias || {}).forEach(function (key) { - aliases[key] = [].concat(opts.alias[key]); - aliases[key].forEach(function (x) { - aliases[x] = [key].concat(aliases[key].filter(function (y) { - return x !== y; - })); - }); - }); + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; - [].concat(opts.string).filter(Boolean).forEach(function (key) { - flags.strings[key] = true; - if (aliases[key]) { - flags.strings[aliases[key]] = true; - } - }); + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; - var defaults = opts['default'] || {}; - - var argv = { _ : [] }; - Object.keys(flags.bools).forEach(function (key) { - setArg(key, defaults[key] === undefined ? false : defaults[key]); - }); - - var notFlags = []; +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); - if (args.indexOf('--') !== -1) { - notFlags = args.slice(args.indexOf('--')+1); - args = args.slice(0, args.indexOf('--')); - } +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; - function argDefined(key, arg) { - return (flags.allBools && /^--[^=]+$/.test(arg)) || - flags.strings[key] || flags.bools[key] || aliases[key]; - } +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; - function setArg (key, val, arg) { - if (arg && flags.unknownFn && !argDefined(key, arg)) { - if (flags.unknownFn(arg) === false) return; - } + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } - var value = !flags.strings[key] && isNumber(val) - ? Number(val) : val - ; - setKey(argv, key.split('.'), value); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), value); - }); - } + this[INTERNALS].disturbed = true; - function setKey (obj, keys, value) { - var o = obj; - for (var i = 0; i < keys.length-1; i++) { - var key = keys[i]; - if (key === '__proto__') return; - if (o[key] === undefined) o[key] = {}; - if (o[key] === Object.prototype || o[key] === Number.prototype - || o[key] === String.prototype) o[key] = {}; - if (o[key] === Array.prototype) o[key] = []; - o = o[key]; - } + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } - var key = keys[keys.length - 1]; - if (key === '__proto__') return; - if (o === Object.prototype || o === Number.prototype - || o === String.prototype) o = {}; - if (o === Array.prototype) o = []; - if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { - o[key] = value; - } - else if (Array.isArray(o[key])) { - o[key].push(value); - } - else { - o[key] = [ o[key], value ]; - } - } - - function aliasIsBoolean(key) { - return aliases[key].some(function (x) { - return flags.bools[x]; - }); - } + let body = this.body; - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - - if (/^--.+=/.test(arg)) { - // Using [\s\S] instead of . because js doesn't support the - // 'dotall' regex modifier. See: - // http://stackoverflow.com/a/1068308/13216 - var m = arg.match(/^--([^=]+)=([\s\S]*)$/); - var key = m[1]; - var value = m[2]; - if (flags.bools[key]) { - value = value !== 'false'; - } - setArg(key, value, arg); - } - else if (/^--no-.+/.test(arg)) { - var key = arg.match(/^--no-(.+)/)[1]; - setArg(key, false, arg); - } - else if (/^--.+/.test(arg)) { - var key = arg.match(/^--(.+)/)[1]; - var next = args[i + 1]; - if (next !== undefined && !/^-/.test(next) - && !flags.bools[key] - && !flags.allBools - && (aliases[key] ? !aliasIsBoolean(key) : true)) { - setArg(key, next, arg); - i++; - } - else if (/^(true|false)$/.test(next)) { - setArg(key, next === 'true', arg); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true, arg); - } - } - else if (/^-[^-]+/.test(arg)) { - var letters = arg.slice(1,-1).split(''); - - var broken = false; - for (var j = 0; j < letters.length; j++) { - var next = arg.slice(j+2); - - if (next === '-') { - setArg(letters[j], next, arg) - continue; - } - - if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { - setArg(letters[j], next.split('=')[1], arg); - broken = true; - break; - } - - if (/[A-Za-z]/.test(letters[j]) - && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { - setArg(letters[j], next, arg); - broken = true; - break; - } - - if (letters[j+1] && letters[j+1].match(/\W/)) { - setArg(letters[j], arg.slice(j+2), arg); - broken = true; - break; - } - else { - setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); - } - } - - var key = arg.slice(-1)[0]; - if (!broken && key !== '-') { - if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) - && !flags.bools[key] - && (aliases[key] ? !aliasIsBoolean(key) : true)) { - setArg(key, args[i+1], arg); - i++; - } - else if (args[i+1] && /^(true|false)$/.test(args[i+1])) { - setArg(key, args[i+1] === 'true', arg); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true, arg); - } - } - } - else { - if (!flags.unknownFn || flags.unknownFn(arg) !== false) { - argv._.push( - flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) - ); - } - if (opts.stopEarly) { - argv._.push.apply(argv._, args.slice(i + 1)); - break; - } - } - } - - Object.keys(defaults).forEach(function (key) { - if (!hasKey(argv, key.split('.'))) { - setKey(argv, key.split('.'), defaults[key]); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), defaults[key]); - }); - } - }); - - if (opts['--']) { - argv['--'] = new Array(); - notFlags.forEach(function(key) { - argv['--'].push(key); - }); - } - else { - notFlags.forEach(function(key) { - argv._.push(key); - }); - } + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } - return argv; -}; + // body is blob + if (isBlob(body)) { + body = body.stream(); + } -function hasKey (obj, keys) { - var o = obj; - keys.slice(0,-1).forEach(function (key) { - o = (o[key] || {}); - }); + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } - var key = keys[keys.length - 1]; - return key in o; -} + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } -function isNumber (x) { - if (typeof x === 'number') return true; - if (/^0x[0-9a-f]+$/i.test(x)) return true; - return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); -} + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + return new Body.Promise(function (resolve, reject) { + let resTimeout; + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } -/***/ }), + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); -/***/ 8560: -/***/ ((module) => { + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } -"use strict"; + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} /** - * Tries to execute a function and discards any error that occurs. - * @param {Function} fn - Function that might or might not throw an error. - * @returns {?*} Return-value of the function when no error occurred. + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String */ -module.exports = function(fn) { +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } - try { return fn() } catch (e) {} + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; -} + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } -/***/ }), + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); -/***/ 467: -/***/ ((module, exports, __nccwpck_require__) => { + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; - // when err.type is `system`, err.code contains system error code - if (systemError) { - this.code = this.errno = systemError.code; - } + this[MAP] = Object.create(null); - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } -let convert; -try { - convert = __nccwpck_require__(2877).convert; -} catch (e) {} + return; + } -const INTERNALS = Symbol('Body internals'); + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream.PassThrough; + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } -/** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -function Body(body) { - var _this = this; + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + return this[MAP][key].join(', '); + } - if (body == null) { - // body is undefined or null - body = null; - } else if (isURLSearchParams(body)) { - // body is a URLSearchParams - body = Buffer.from(body.toString()); - } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { - // body is ArrayBuffer - body = Buffer.from(body); - } else if (ArrayBuffer.isView(body)) { - // body is ArrayBufferView - body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof Stream) ; else { - // none of the above - // coerce to string then buffer - body = Buffer.from(String(body)); + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } } - this[INTERNALS] = { - body, - disturbed: false, - error: null - }; - this.size = size; - this.timeout = timeout; - if (body instanceof Stream) { - body.on('error', function (err) { - const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); - _this[INTERNALS].error = error; - }); + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; } -} - -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, - - get bodyUsed() { - return this[INTERNALS].disturbed; - }, /** - * Decode response as ArrayBuffer + * Append a value onto existing header * - * @return Promise + * @param String name Header name + * @param String value Header value + * @return Void */ - arrayBuffer() { - return consumeBody.call(this).then(function (buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } /** - * Return raw response as Blob + * Check for header name existence * - * @return Promise + * @param String name Header name + * @return Boolean */ - blob() { - let ct = this.headers && this.headers.get('content-type') || ''; - return consumeBody.call(this).then(function (buf) { - return Object.assign( - // Prevent copying - new Blob([], { - type: ct.toLowerCase() - }), { - [BUFFER]: buf - }); - }); - }, + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } /** - * Decode response as json + * Delete all header values given name * - * @return Promise + * @param String name Header name + * @return Void */ - json() { - var _this2 = this; + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } - return consumeBody.call(this).then(function (buffer) { - try { - return JSON.parse(buffer.toString()); - } catch (err) { - return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); - } - }); - }, + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } /** - * Decode response as text + * Get an iterator on keys. * - * @return Promise + * @return Iterator */ - text() { - return consumeBody.call(this).then(function (buffer) { - return buffer.toString(); - }); - }, + keys() { + return createHeadersIterator(this, 'key'); + } /** - * Decode response as buffer (non-spec api) + * Get an iterator on values. * - * @return Promise + * @return Iterator */ - buffer() { - return consumeBody.call(this); - }, + values() { + return createHeadersIterator(this, 'value'); + } /** - * Decode response as text, while automatically detecting the encoding and - * trying to decode to UTF-8 (non-spec api) + * Get an iterator on entries. * - * @return Promise + * This is the default iterator of the Headers object. + * + * @return Iterator */ - textConverted() { - var _this3 = this; + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; - return consumeBody.call(this).then(function (buffer) { - return convertBody(buffer, _this3.headers); - }); +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; } -}; +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); -// In browsers, all properties are enumerable. -Object.defineProperties(Body.prototype, { - body: { enumerable: true }, - bodyUsed: { enumerable: true }, - arrayBuffer: { enumerable: true }, - blob: { enumerable: true }, - json: { enumerable: true }, - text: { enumerable: true } +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true }); -Body.mixIn = function (proto) { - for (const name of Object.getOwnPropertyNames(Body.prototype)) { - // istanbul ignore else: future proof - if (!(name in proto)) { - const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); - Object.defineProperty(proto, name, desc); +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; } } -}; + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; /** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * Response class * - * @return Promise + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void */ -function consumeBody() { - var _this4 = this; +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } + Body.call(this, body, opts); - this[INTERNALS].disturbed = true; + const status = opts.status || 200; + const headers = new Headers(opts.headers); - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; } - let body = this.body; + get url() { + return this[INTERNALS$1].url || ''; + } - // body is null - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); + get status() { + return this[INTERNALS$1].status; } - // body is blob - if (isBlob(body)) { - body = body.stream(); + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; } - // body is buffer - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); + get redirected() { + return this[INTERNALS$1].counter > 0; } - // istanbul ignore if: should never happen - if (!(body instanceof Stream)) { - return Body.Promise.resolve(Buffer.alloc(0)); + get statusText() { + return this[INTERNALS$1].statusText; } - // body is stream - // get ready to actually consume the body - let accum = []; - let accumBytes = 0; - let abort = false; + get headers() { + return this[INTERNALS$1].headers; + } - return new Body.Promise(function (resolve, reject) { - let resTimeout; + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} - // allow timeout on slow response body - if (_this4.timeout) { - resTimeout = setTimeout(function () { - abort = true; - reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); - }, _this4.timeout); - } +Body.mixIn(Response.prototype); - // handle stream errors - body.on('error', function (err) { - if (err.name === 'AbortError') { - // if the request was aborted, reject with this Error - abort = true; - reject(err); - } else { - // other errors, such as incorrect content-encoding - reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); - } - }); +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); - body.on('data', function (chunk) { - if (abort || chunk === null) { - return; - } +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); - if (_this4.size && accumBytes + chunk.length > _this4.size) { - abort = true; - reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); - return; - } +const INTERNALS$2 = Symbol('Request internals'); - accumBytes += chunk.length; - accum.push(chunk); - }); +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; - body.on('end', function () { - if (abort) { - return; - } +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; - clearTimeout(resTimeout); +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} - try { - resolve(Buffer.concat(accum, accumBytes)); - } catch (err) { - // handle streams that have accumulated too much data (issue #414) - reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); - } - }); - }); +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); } /** - * Detect buffer encoding and convert to target encoding - * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * Request class * - * @param Buffer buffer Incoming buffer - * @param String encoding Target encoding - * @return String + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void */ -function convertBody(buffer, headers) { - if (typeof convert !== 'function') { - throw new Error('The package `encoding` must be installed to use the textConverted() function'); - } +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - const ct = headers.get('content-type'); - let charset = 'utf-8'; - let res, str; + let parsedURL; - // header - if (ct) { - res = /charset=([^;]*)/i.exec(ct); - } + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parse_url(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parse_url(`${input}`); + } + input = {}; + } else { + parsedURL = parse_url(input.url); + } - // no charset in content type, peek at response body for at most 1024 bytes - str = buffer.slice(0, 1024).toString(); + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); - // html5 - if (!res && str) { - res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; - - this[MAP] = Object.create(null); +function fetch(url, opts) { - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } + Body.Promise = fetch.Promise; - return; - } + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); - // We don't worry about converting prop to ByteString here as append() - // will handle it. - if (init == null) ; else if (typeof init === 'object') { - const method = init[Symbol.iterator]; - if (method != null) { - if (typeof method !== 'function') { - throw new TypeError('Header pairs must be iterable'); - } + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; - // sequence> - // Note: per spec we have to first exhaust the lists then process them - const pairs = []; - for (const pair of init) { - if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { - throw new TypeError('Each header pair must be iterable'); - } - pairs.push(Array.from(pair)); - } + let response = null; - for (const pair of pairs) { - if (pair.length !== 2) { - throw new TypeError('Each header pair must be a name/value tuple'); - } - this.append(pair[0], pair[1]); - } - } else { - // record - for (const key of Object.keys(init)) { - const value = init[key]; - this.append(key, value); - } + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + request.body.destroy(error); } - } else { - throw new TypeError('Provided initializer must be an object'); - } - } + if (!response || !response.body) return; + response.body.emit('error', error); + }; - /** - * Return combined header value given name - * - * @param String name Header name - * @return Mixed - */ - get(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key === undefined) { - return null; + if (signal && signal.aborted) { + abort(); + return; } - return this[MAP][key].join(', '); - } - - /** - * Iterate over all headers - * - * @param Function callback Executed for each item with parameters (value, name, thisArg) - * @param Boolean thisArg `this` context for callback function - * @return Void - */ - forEach(callback) { - let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; - let pairs = getHeaders(this); - let i = 0; - while (i < pairs.length) { - var _pairs$i = pairs[i]; - const name = _pairs$i[0], - value = _pairs$i[1]; + // send request + const req = send(options); + let reqTimeout; - callback.call(thisArg, value, name, this); - pairs = getHeaders(this); - i++; + if (signal) { + signal.addEventListener('abort', abortAndFinalize); } - } - - /** - * Overwrite header values given name - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - set(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - this[MAP][key !== undefined ? key : name] = [value]; - } - /** - * Append a value onto existing header - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - append(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - if (key !== undefined) { - this[MAP][key].push(value); - } else { - this[MAP][name] = [value]; + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); } - } - - /** - * Check for header name existence - * - * @param String name Header name - * @return Boolean - */ - has(name) { - name = `${name}`; - validateName(name); - return find(this[MAP], name) !== undefined; - } - /** - * Delete all header values given name - * - * @param String name Header name - * @return Void - */ - delete(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key !== undefined) { - delete this[MAP][key]; + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); } - } - /** - * Return raw headers (non-spec api) - * - * @return Object - */ - raw() { - return this[MAP]; - } + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); - /** - * Get an iterator on keys. - * - * @return Iterator - */ - keys() { - return createHeadersIterator(this, 'key'); - } + req.on('response', function (res) { + clearTimeout(reqTimeout); - /** - * Get an iterator on values. - * - * @return Iterator - */ - values() { - return createHeadersIterator(this, 'value'); - } + const headers = createHeadersLenient(res.headers); - /** - * Get an iterator on entries. - * - * This is the default iterator of the Headers object. - * - * @return Iterator - */ - [Symbol.iterator]() { - return createHeadersIterator(this, 'key+value'); - } -} -Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); -Object.defineProperty(Headers.prototype, Symbol.toStringTag, { - value: 'Headers', - writable: false, - enumerable: false, - configurable: true -}); + // HTTP fetch step 5.3 + const locationURL = location === null ? null : resolve_url(request.url, location); -Object.defineProperties(Headers.prototype, { - get: { enumerable: true }, - forEach: { enumerable: true }, - set: { enumerable: true }, - append: { enumerable: true }, - has: { enumerable: true }, - delete: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true } -}); + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } -function getHeaders(headers) { - let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } - const keys = Object.keys(headers[MAP]).sort(); - return keys.map(kind === 'key' ? function (k) { - return k.toLowerCase(); - } : kind === 'value' ? function (k) { - return headers[MAP][k].join(', '); - } : function (k) { - return [k.toLowerCase(), headers[MAP][k].join(', ')]; - }); -} + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; -const INTERNAL = Symbol('internal'); + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } -function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; -} + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } -const HeadersIteratorPrototype = Object.setPrototypeOf({ - next() { - // istanbul ignore if - if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { - throw new TypeError('Value of `this` is not a HeadersIterator'); - } + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } - var _INTERNAL = this[INTERNAL]; - const target = _INTERNAL.target, - kind = _INTERNAL.kind, - index = _INTERNAL.index; + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: undefined, - done: true + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter }; - } - this[INTERNAL].index = index + 1; + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); - return { - value: values[index], - done: false - }; - } -}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + // HTTP-network fetch step 12.1.1.4: handle content codings -Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: 'HeadersIterator', - writable: false, - enumerable: false, - configurable: true -}); + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } -/** - * Export the Headers object in a form that Node.js can consume. - * - * @param Headers headers - * @return Object - */ -function exportNodeCompatibleHeaders(headers) { - const obj = Object.assign({ __proto__: null }, headers[MAP]); + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib.createInflate()); + } else { + body = body.pipe(zlib.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } - // http.request() only supports string as Host header. This hack makes - // specifying custom Host header possible. - const hostHeaderKey = find(headers[MAP], 'Host'); - if (hostHeaderKey !== undefined) { - obj[hostHeaderKey] = obj[hostHeaderKey][0]; - } + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); - return obj; + writeToStream(req, request); + }); } - /** - * Create a Headers object from an object of headers, ignoring those that do - * not conform to HTTP grammar productions. + * Redirect code matching * - * @param Object obj Object of headers - * @return Headers + * @param Number code Status code + * @return Boolean */ -function createHeadersLenient(obj) { - const headers = new Headers(); - for (const name of Object.keys(obj)) { - if (invalidTokenRegex.test(name)) { - continue; - } - if (Array.isArray(obj[name])) { - for (const val of obj[name]) { - if (invalidHeaderCharRegex.test(val)) { - continue; - } - if (headers[MAP][name] === undefined) { - headers[MAP][name] = [val]; - } else { - headers[MAP][name].push(val); - } - } - } else if (!invalidHeaderCharRegex.test(obj[name])) { - headers[MAP][name] = [obj[name]]; - } - } - return headers; -} +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; -const INTERNALS$1 = Symbol('Response internals'); +// expose Promise +fetch.Promise = global.Promise; -// fix an issue where "STATUS_CODES" aren't a named export for node <10 -const STATUS_CODES = http.STATUS_CODES; +module.exports = exports = fetch; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.default = exports; +exports.Headers = Headers; +exports.Request = Request; +exports.Response = Response; +exports.FetchError = FetchError; -/** - * Response class - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -class Response { - constructor() { - let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - Body.call(this, body, opts); +/***/ }), - const status = opts.status || 200; - const headers = new Headers(opts.headers); +/***/ 502: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (body != null && !headers.has('Content-Type')) { - const contentType = extractContentType(body); - if (contentType) { - headers.append('Content-Type', contentType); - } - } +"use strict"; - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } +const path = __nccwpck_require__(5622); +const pathKey = __nccwpck_require__(539); - get url() { - return this[INTERNALS$1].url || ''; - } +module.exports = opts => { + opts = Object.assign({ + cwd: process.cwd(), + path: process.env[pathKey()] + }, opts); - get status() { - return this[INTERNALS$1].status; - } + let prev; + let pth = path.resolve(opts.cwd); + const ret = []; - /** - * Convenience property representing if the request ended normally - */ - get ok() { - return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + while (prev !== pth) { + ret.push(path.join(pth, 'node_modules/.bin')); + prev = pth; + pth = path.resolve(pth, '..'); } - get redirected() { - return this[INTERNALS$1].counter > 0; - } + // ensure the running `node` binary is used + ret.push(path.dirname(process.execPath)); - get statusText() { - return this[INTERNALS$1].statusText; - } + return ret.concat(opts.path).join(path.delimiter); +}; - get headers() { - return this[INTERNALS$1].headers; - } +module.exports.env = opts => { + opts = Object.assign({ + env: process.env + }, opts); - /** - * Clone this response - * - * @return Response - */ - clone() { - return new Response(clone(this), { - url: this.url, - status: this.status, - statusText: this.statusText, - headers: this.headers, - ok: this.ok, - redirected: this.redirected - }); - } -} + const env = Object.assign({}, opts.env); + const path = pathKey({env}); -Body.mixIn(Response.prototype); + opts.path = env[path]; + env[path] = module.exports(opts); -Object.defineProperties(Response.prototype, { - url: { enumerable: true }, - status: { enumerable: true }, - ok: { enumerable: true }, - redirected: { enumerable: true }, - statusText: { enumerable: true }, - headers: { enumerable: true }, - clone: { enumerable: true } -}); + return env; +}; -Object.defineProperty(Response.prototype, Symbol.toStringTag, { - value: 'Response', - writable: false, - enumerable: false, - configurable: true -}); -const INTERNALS$2 = Symbol('Request internals'); +/***/ }), -// fix an issue where "format", "parse" aren't a named export for node <10 -const parse_url = Url.parse; -const format_url = Url.format; +/***/ 1223: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; +var wrappy = __nccwpck_require__(2940) +module.exports = wrappy(once) +module.exports.strict = wrappy(onceStrict) -/** - * Check if a value is an instance of Request. - * - * @param Mixed input - * @return Boolean - */ -function isRequest(input) { - return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; -} +once.proto = once(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once(this) + }, + configurable: true + }) -function isAbortSignal(signal) { - const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); - return !!(proto && proto.constructor.name === 'AbortSignal'); + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function () { + return onceStrict(this) + }, + configurable: true + }) +}) + +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 } -/** - * Request class - * - * @param Mixed input Url or Request instance - * @param Object init Custom options - * @return Void - */ -class Request { - constructor(input) { - let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; +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 +} - let parsedURL; - // normalize input - if (!isRequest(input)) { - if (input && input.href) { - // in order to support Node.js' Url objects; though WHATWG's URL objects - // will fall into this branch also (since their `toString()` will return - // `href` property anyway) - parsedURL = parse_url(input.href); - } else { - // coerce input to a string before attempting to parse - parsedURL = parse_url(`${input}`); - } - input = {}; - } else { - parsedURL = parse_url(input.url); - } +/***/ }), - let method = init.method || input.method || 'GET'; - method = method.toUpperCase(); +/***/ 4824: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { - throw new TypeError('Request with GET/HEAD method cannot have body'); - } +"use strict"; - let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; +const os = __nccwpck_require__(2087); +const macosRelease = __nccwpck_require__(7493); +const winRelease = __nccwpck_require__(3515); - Body.call(this, inputBody, { - timeout: init.timeout || input.timeout || 0, - size: init.size || input.size || 0 - }); +const osName = (platform, release) => { + if (!platform && release) { + throw new Error('You can\'t specify a `release` without specifying `platform`'); + } - const headers = new Headers(init.headers || input.headers || {}); + platform = platform || os.platform(); - if (inputBody != null && !headers.has('Content-Type')) { - const contentType = extractContentType(inputBody); - if (contentType) { - headers.append('Content-Type', contentType); - } + let id; + + if (platform === 'darwin') { + if (!release && os.platform() === 'darwin') { + release = os.release(); } - let signal = isRequest(input) ? input.signal : null; - if ('signal' in init) signal = init.signal; + const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; + id = release ? macosRelease(release).name : ''; + return prefix + (id ? ' ' + id : ''); + } - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError('Expected signal to be an instanceof AbortSignal'); + if (platform === 'linux') { + if (!release && os.platform() === 'linux') { + release = os.release(); } - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || 'follow', - headers, - parsedURL, - signal - }; - - // node-fetch-only options - this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; - this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; - this.counter = init.counter || input.counter || 0; - this.agent = init.agent || input.agent; + id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; + return 'Linux' + (id ? ' ' + id : ''); } - get method() { - return this[INTERNALS$2].method; - } + if (platform === 'win32') { + if (!release && os.platform() === 'win32') { + release = os.release(); + } - get url() { - return format_url(this[INTERNALS$2].parsedURL); + id = release ? winRelease(release) : ''; + return 'Windows' + (id ? ' ' + id : ''); } - get headers() { - return this[INTERNALS$2].headers; - } + return platform; +}; - get redirect() { - return this[INTERNALS$2].redirect; - } +module.exports = osName; - get signal() { - return this[INTERNALS$2].signal; - } - /** - * Clone this request - * - * @return Request - */ - clone() { - return new Request(this); - } -} +/***/ }), -Body.mixIn(Request.prototype); +/***/ 1330: +/***/ ((module) => { -Object.defineProperty(Request.prototype, Symbol.toStringTag, { - value: 'Request', - writable: false, - enumerable: false, - configurable: true -}); +"use strict"; -Object.defineProperties(Request.prototype, { - method: { enumerable: true }, - url: { enumerable: true }, - headers: { enumerable: true }, - redirect: { enumerable: true }, - clone: { enumerable: true }, - signal: { enumerable: true } -}); +module.exports = (promise, onFinally) => { + onFinally = onFinally || (() => {}); -/** - * Convert a Request to Node.js http request options. - * - * @param Request A Request instance - * @return Object The options object to be passed to http.request - */ -function getNodeRequestOptions(request) { - const parsedURL = request[INTERNALS$2].parsedURL; - const headers = new Headers(request[INTERNALS$2].headers); + return promise.then( + val => new Promise(resolve => { + resolve(onFinally()); + }).then(() => val), + err => new Promise(resolve => { + resolve(onFinally()); + }).then(() => { + throw err; + }) + ); +}; - // fetch step 1.3 - if (!headers.has('Accept')) { - headers.set('Accept', '*/*'); - } - // Basic fetch - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError('Only absolute URLs are supported'); - } +/***/ }), - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError('Only HTTP(S) protocols are supported'); - } +/***/ 7684: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { - throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); - } +"use strict"; - // HTTP-network-or-cache fetch steps 2.4-2.7 - let contentLengthValue = null; - if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { - contentLengthValue = '0'; - } - if (request.body != null) { - const totalBytes = getTotalBytes(request); - if (typeof totalBytes === 'number') { - contentLengthValue = String(totalBytes); - } - } - if (contentLengthValue) { - headers.set('Content-Length', contentLengthValue); - } +const pTry = __nccwpck_require__(746); - // HTTP-network-or-cache fetch step 2.11 - if (!headers.has('User-Agent')) { - headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); +module.exports = concurrency => { + if (concurrency < 1) { + throw new TypeError('Expected `concurrency` to be a number from 1 and up'); } - // HTTP-network-or-cache fetch step 2.15 - if (request.compress && !headers.has('Accept-Encoding')) { - headers.set('Accept-Encoding', 'gzip,deflate'); - } + const queue = []; + let activeCount = 0; - let agent = request.agent; - if (typeof agent === 'function') { - agent = agent(parsedURL); - } + const next = () => { + activeCount--; - if (!headers.has('Connection') && !agent) { - headers.set('Connection', 'close'); - } + if (queue.length > 0) { + queue.shift()(); + } + }; - // HTTP-network fetch step 4.2 - // chunked encoding is handled by Node.js + return fn => new Promise((resolve, reject) => { + const run = () => { + activeCount++; - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent + pTry(fn).then( + val => { + resolve(val); + next(); + }, + err => { + reject(err); + next(); + } + ); + }; + + if (activeCount < concurrency) { + run(); + } else { + queue.push(run); + } }); +}; + + +/***/ }), + +/***/ 104: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + +const pLimit = __nccwpck_require__(7684); + +class EndError extends Error { + constructor(value) { + super(); + this.value = value; + } } -/** - * abort-error.js - * - * AbortError interface for cancelled requests - */ +// the input can also be a promise, so we `Promise.all()` them both +const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0]))); + +module.exports = (iterable, tester, opts) => { + opts = Object.assign({ + concurrency: Infinity, + preserveOrder: true + }, opts); + + const limit = pLimit(opts.concurrency); + + // start all the promises concurrently with optional limit + const items = Array.from(iterable).map(el => [el, limit(() => Promise.resolve(el).then(tester))]); + + // check the promises either serially or concurrently + const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity); + + return Promise.all(items.map(el => checkLimit(() => finder(el)))) + .then(() => {}) + .catch(err => err instanceof EndError ? err.value : Promise.reject(err)); +}; + + +/***/ }), -/** - * Create AbortError instance - * - * @param String message Error message for human - * @return AbortError - */ -function AbortError(message) { - Error.call(this, message); +/***/ 746: +/***/ ((module) => { - this.type = 'aborted'; - this.message = message; +"use strict"; - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} +module.exports = cb => new Promise(resolve => { + resolve(cb()); +}); -AbortError.prototype = Object.create(Error.prototype); -AbortError.prototype.constructor = AbortError; -AbortError.prototype.name = 'AbortError'; -// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 -const PassThrough$1 = Stream.PassThrough; -const resolve_url = Url.resolve; +/***/ }), -/** - * Fetch function - * - * @param Mixed url Absolute url or Request instance - * @param Object opts Fetch options - * @return Promise - */ -function fetch(url, opts) { +/***/ 6615: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // allow custom promise - if (!fetch.Promise) { - throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); - } +"use strict"; - Body.Promise = fetch.Promise; +const errorEx = __nccwpck_require__(3505); +const fallback = __nccwpck_require__(5586); - // wrap http.request into fetch - return new fetch.Promise(function (resolve, reject) { - // build request object - const request = new Request(url, opts); - const options = getNodeRequestOptions(request); +const JSONError = errorEx('JSONError', { + fileName: errorEx.append('in %s') +}); - const send = (options.protocol === 'https:' ? https : http).request; - const signal = request.signal; +module.exports = (input, reviver, filename) => { + if (typeof reviver === 'string') { + filename = reviver; + reviver = null; + } - let response = null; + try { + try { + return JSON.parse(input, reviver); + } catch (err) { + fallback(input, reviver); - const abort = function abort() { - let error = new AbortError('The user aborted a request.'); - reject(error); - if (request.body && request.body instanceof Stream.Readable) { - request.body.destroy(error); - } - if (!response || !response.body) return; - response.body.emit('error', error); - }; + throw err; + } + } catch (err) { + err.message = err.message.replace(/\n/g, ''); - if (signal && signal.aborted) { - abort(); - return; + const jsonErr = new JSONError(err); + if (filename) { + jsonErr.fileName = filename; } - const abortAndFinalize = function abortAndFinalize() { - abort(); - finalize(); - }; + throw jsonErr; + } +}; - // send request - const req = send(options); - let reqTimeout; - if (signal) { - signal.addEventListener('abort', abortAndFinalize); - } +/***/ }), - function finalize() { - req.abort(); - if (signal) signal.removeEventListener('abort', abortAndFinalize); - clearTimeout(reqTimeout); - } +/***/ 6978: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (request.timeout) { - req.once('socket', function (socket) { - reqTimeout = setTimeout(function () { - reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); - finalize(); - }, request.timeout); - }); - } +"use strict"; - req.on('error', function (err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); - finalize(); - }); +const fs = __nccwpck_require__(5747); - req.on('response', function (res) { - clearTimeout(reqTimeout); +module.exports = fp => new Promise(resolve => { + fs.access(fp, err => { + resolve(!err); + }); +}); - const headers = createHeadersLenient(res.headers); +module.exports.sync = fp => { + try { + fs.accessSync(fp); + return true; + } catch (err) { + return false; + } +}; - // HTTP fetch step 5 - if (fetch.isRedirect(res.statusCode)) { - // HTTP fetch step 5.2 - const location = headers.get('Location'); - // HTTP fetch step 5.3 - const locationURL = location === null ? null : resolve_url(request.url, location); +/***/ }), - // HTTP fetch step 5.5 - switch (request.redirect) { - case 'error': - reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); - finalize(); - return; - case 'manual': - // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. - if (locationURL !== null) { - // handle corrupted header - try { - headers.set('Location', locationURL); - } catch (err) { - // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request - reject(err); - } - } - break; - case 'follow': - // HTTP-redirect fetch step 2 - if (locationURL === null) { - break; - } +/***/ 539: +/***/ ((module) => { - // HTTP-redirect fetch step 5 - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); - finalize(); - return; - } +"use strict"; - // HTTP-redirect fetch step 6 (counter increment) - // Create a new Request object. - const requestOpts = { - headers: new Headers(request.headers), - follow: request.follow, - counter: request.counter + 1, - agent: request.agent, - compress: request.compress, - method: request.method, - body: request.body, - signal: request.signal, - timeout: request.timeout, - size: request.size - }; +module.exports = opts => { + opts = opts || {}; - // HTTP-redirect fetch step 9 - if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { - reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); - finalize(); - return; - } + const env = opts.env || process.env; + const platform = opts.platform || process.platform; - // HTTP-redirect fetch step 11 - if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { - requestOpts.method = 'GET'; - requestOpts.body = undefined; - requestOpts.headers.delete('content-length'); - } + if (platform !== 'win32') { + return 'PATH'; + } - // HTTP-redirect fetch step 15 - resolve(fetch(new Request(locationURL, requestOpts))); - finalize(); - return; - } - } + return Object.keys(env).find(x => x.toUpperCase() === 'PATH') || 'Path'; +}; - // prepare response - res.once('end', function () { - if (signal) signal.removeEventListener('abort', abortAndFinalize); - }); - let body = res.pipe(new PassThrough$1()); - const response_options = { - url: request.url, - status: res.statusCode, - statusText: res.statusMessage, - headers: headers, - size: request.size, - timeout: request.timeout, - counter: request.counter - }; +/***/ }), - // HTTP-network fetch step 12.1.1.3 - const codings = headers.get('Content-Encoding'); +/***/ 4810: +/***/ ((module) => { - // HTTP-network fetch step 12.1.1.4: handle content codings +"use strict"; - // in following scenarios we ignore compression support - // 1. compression support is disabled - // 2. HEAD request - // 3. no Content-Encoding header - // 4. no content response (204) - // 5. content not modified response (304) - if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { - response = new Response(body, response_options); - resolve(response); - return; - } - // For Node v6+ - // Be less strict when decoding compressed responses, since sometimes - // servers send slightly invalid responses that are still accepted - // by common browsers. - // Always using Z_SYNC_FLUSH is what cURL does. - const zlibOptions = { - flush: zlib.Z_SYNC_FLUSH, - finishFlush: zlib.Z_SYNC_FLUSH - }; +const processFn = (fn, opts) => function () { + const P = opts.promiseModule; + const args = new Array(arguments.length); + + for (let i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } - // for gzip - if (codings == 'gzip' || codings == 'x-gzip') { - body = body.pipe(zlib.createGunzip(zlibOptions)); - response = new Response(body, response_options); - resolve(response); - return; - } + return new P((resolve, reject) => { + if (opts.errorFirst) { + args.push(function (err, result) { + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); - // for deflate - if (codings == 'deflate' || codings == 'x-deflate') { - // handle the infamous raw deflate response from old servers - // a hack for old IIS and Apache servers - const raw = res.pipe(new PassThrough$1()); - raw.once('data', function (chunk) { - // see http://stackoverflow.com/questions/37519828 - if ((chunk[0] & 0x0F) === 0x08) { - body = body.pipe(zlib.createInflate()); + for (let i = 1; i < arguments.length; i++) { + results[i - 1] = arguments[i]; + } + + if (err) { + results.unshift(err); + reject(results); } else { - body = body.pipe(zlib.createInflateRaw()); + resolve(results); } - response = new Response(body, response_options); - resolve(response); - }); - return; - } + } else if (err) { + reject(err); + } else { + resolve(result); + } + }); + } else { + args.push(function (result) { + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); - // for br - if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { - body = body.pipe(zlib.createBrotliDecompress()); - response = new Response(body, response_options); - resolve(response); - return; - } + for (let i = 0; i < arguments.length; i++) { + results[i] = arguments[i]; + } - // otherwise, use response as-is - response = new Response(body, response_options); - resolve(response); - }); + resolve(results); + } else { + resolve(result); + } + }); + } - writeToStream(req, request); + fn.apply(this, args); }); -} -/** - * Redirect code matching - * - * @param Number code Status code - * @return Boolean - */ -fetch.isRedirect = function (code) { - return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; }; -// expose Promise -fetch.Promise = global.Promise; +module.exports = (obj, opts) => { + opts = Object.assign({ + exclude: [/.+(Sync|Stream)$/], + errorFirst: true, + promiseModule: Promise + }, opts); -module.exports = exports = fetch; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.default = exports; -exports.Headers = Headers; -exports.Request = Request; -exports.Response = Response; -exports.FetchError = FetchError; + const filter = key => { + const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); + return opts.include ? opts.include.some(match) : !opts.exclude.some(match); + }; + + let ret; + if (typeof obj === 'function') { + ret = function () { + if (opts.excludeMain) { + return obj.apply(this, arguments); + } + + return processFn(obj, opts).apply(this, arguments); + }; + } else { + ret = Object.create(Object.getPrototypeOf(obj)); + } + + for (const key in obj) { // eslint-disable-line guard-for-in + const x = obj[key]; + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x; + } + + return ret; +}; /***/ }), -/***/ 502: +/***/ 1235: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; const path = __nccwpck_require__(5622); -const pathKey = __nccwpck_require__(539); +const findUp = __nccwpck_require__(9486); +const loadJsonFile = __nccwpck_require__(5978); -module.exports = opts => { - opts = Object.assign({ - cwd: process.cwd(), - path: process.env[pathKey()] - }, opts); +const filepaths = new WeakMap(); +const filepath = conf => filepaths.get(conf); +const findNextCwd = pkgPath => path.resolve(path.dirname(pkgPath), '..'); - let prev; - let pth = path.resolve(opts.cwd); - const ret = []; +const addFp = (obj, fp) => { + filepaths.set(obj, fp); + return obj; +}; - while (prev !== pth) { - ret.push(path.join(pth, 'node_modules/.bin')); - prev = pth; - pth = path.resolve(pth, '..'); +const pkgConf = (namespace, opts) => { + if (!namespace) { + return Promise.reject(new TypeError('Expected a namespace')); } - // ensure the running `node` binary is used - ret.push(path.dirname(process.execPath)); + opts = opts || {}; - return ret.concat(opts.path).join(path.delimiter); + return findUp('package.json', opts.cwd ? {cwd: opts.cwd} : {}) + .then(fp => { + if (!fp) { + return addFp(Object.assign({}, opts.defaults), fp); + } + + return loadJsonFile(fp).then(pkg => { + if (opts.skipOnFalse && pkg[namespace] === false) { + const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)}); + return pkgConf(namespace, newOpts); + } + + return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp); + }); + }); }; -module.exports.env = opts => { - opts = Object.assign({ - env: process.env - }, opts); +const sync = (namespace, opts) => { + if (!namespace) { + throw new TypeError('Expected a namespace'); + } - const env = Object.assign({}, opts.env); - const path = pathKey({env}); + opts = opts || {}; - opts.path = env[path]; - env[path] = module.exports(opts); + const fp = findUp.sync('package.json', opts.cwd ? {cwd: opts.cwd} : {}); - return env; + if (!fp) { + return addFp(Object.assign({}, opts.defaults), fp); + } + + const pkg = loadJsonFile.sync(fp); + + if (opts.skipOnFalse && pkg[namespace] === false) { + const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)}); + return sync(namespace, newOpts); + } + + return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp); }; +module.exports = pkgConf; +module.exports.filepath = filepath; +module.exports.sync = sync; + /***/ }), -/***/ 1223: +/***/ 8341: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var wrappy = __nccwpck_require__(2940) -module.exports = wrappy(once) -module.exports.strict = wrappy(onceStrict) +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 -once.proto = once(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once(this) - }, - configurable: true +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) +} + +var isRequest = function (stream) { + return stream.setHeader && isFn(stream.abort) +} + +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() }) - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }) -}) + var destroyed = false + return function (err) { + if (closed) return + if (destroyed) return + destroyed = true + + 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 + + if (isFn(stream.destroy)) return stream.destroy() -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) + callback(err || new Error('stream was destroyed')) } - 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 +var call = function (fn) { + fn() } +var pipe = function (from, to) { + return from.pipe(to) +} -/***/ }), - -/***/ 4824: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; +var pump = function () { + var streams = Array.prototype.slice.call(arguments) + var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop -const os = __nccwpck_require__(2087); -const macosRelease = __nccwpck_require__(7493); -const winRelease = __nccwpck_require__(3515); + if (Array.isArray(streams[0])) streams = streams[0] + if (streams.length < 2) throw new Error('pump requires two streams per minimum') -const osName = (platform, release) => { - if (!platform && release) { - throw new Error('You can\'t specify a `release` without specifying `platform`'); - } + 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) + }) + }) - platform = platform || os.platform(); + return streams.reduce(pipe) +} - let id; +module.exports = pump - if (platform === 'darwin') { - if (!release && os.platform() === 'darwin') { - release = os.release(); - } - const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; - id = release ? macosRelease(release).name : ''; - return prefix + (id ? ' ' + id : ''); - } +/***/ }), - if (platform === 'linux') { - if (!release && os.platform() === 'linux') { - release = os.release(); - } +/***/ 5911: +/***/ ((module, exports) => { - id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; - return 'Linux' + (id ? ' ' + id : ''); - } +exports = module.exports = SemVer - if (platform === 'win32') { - if (!release && os.platform() === 'win32') { - release = os.release(); - } +var debug +/* istanbul ignore next */ +if (typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function () { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } +} else { + debug = function () {} +} - id = release ? winRelease(release) : ''; - return 'Windows' + (id ? ' ' + id : ''); - } +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0' - return platform; -}; +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 -module.exports = osName; +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var R = 0 -/***/ }), +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. -/***/ 1330: -/***/ ((module) => { +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. -"use strict"; +var NUMERICIDENTIFIER = R++ +src[NUMERICIDENTIFIER] = '0|[1-9]\\d*' +var NUMERICIDENTIFIERLOOSE = R++ +src[NUMERICIDENTIFIERLOOSE] = '[0-9]+' -module.exports = (promise, onFinally) => { - onFinally = onFinally || (() => {}); +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. - return promise.then( - val => new Promise(resolve => { - resolve(onFinally()); - }).then(() => val), - err => new Promise(resolve => { - resolve(onFinally()); - }).then(() => { - throw err; - }) - ); -}; +var NONNUMERICIDENTIFIER = R++ +src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' +// ## Main Version +// Three dot-separated numeric identifiers. -/***/ }), +var MAINVERSION = R++ +src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')' -/***/ 7684: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var MAINVERSIONLOOSE = R++ +src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')' -"use strict"; +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. -const pTry = __nccwpck_require__(746); +var PRERELEASEIDENTIFIER = R++ +src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + + '|' + src[NONNUMERICIDENTIFIER] + ')' -module.exports = concurrency => { - if (concurrency < 1) { - throw new TypeError('Expected `concurrency` to be a number from 1 and up'); - } +var PRERELEASEIDENTIFIERLOOSE = R++ +src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + + '|' + src[NONNUMERICIDENTIFIER] + ')' - const queue = []; - let activeCount = 0; +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. - const next = () => { - activeCount--; +var PRERELEASE = R++ +src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))' - if (queue.length > 0) { - queue.shift()(); - } - }; +var PRERELEASELOOSE = R++ +src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))' - return fn => new Promise((resolve, reject) => { - const run = () => { - activeCount++; +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - pTry(fn).then( - val => { - resolve(val); - next(); - }, - err => { - reject(err); - next(); - } - ); - }; +var BUILDIDENTIFIER = R++ +src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - if (activeCount < concurrency) { - run(); - } else { - queue.push(run); - } - }); -}; +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. +var BUILD = R++ +src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))' -/***/ }), +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. -/***/ 104: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// 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. -"use strict"; +var FULL = R++ +var FULLPLAIN = 'v?' + src[MAINVERSION] + + src[PRERELEASE] + '?' + + src[BUILD] + '?' -const pLimit = __nccwpck_require__(7684); +src[FULL] = '^' + FULLPLAIN + '$' -class EndError extends Error { - constructor(value) { - super(); - this.value = value; - } -} +// 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. +var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + + src[PRERELEASELOOSE] + '?' + + src[BUILD] + '?' -// the input can also be a promise, so we `Promise.all()` them both -const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0]))); +var LOOSE = R++ +src[LOOSE] = '^' + LOOSEPLAIN + '$' -module.exports = (iterable, tester, opts) => { - opts = Object.assign({ - concurrency: Infinity, - preserveOrder: true - }, opts); +var GTLT = R++ +src[GTLT] = '((?:<|>)?=?)' - const limit = pLimit(opts.concurrency); +// 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. +var XRANGEIDENTIFIERLOOSE = R++ +src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +var XRANGEIDENTIFIER = R++ +src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*' - // start all the promises concurrently with optional limit - const items = Array.from(iterable).map(el => [el, limit(() => Promise.resolve(el).then(tester))]); +var XRANGEPLAIN = R++ +src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:' + src[PRERELEASE] + ')?' + + src[BUILD] + '?' + + ')?)?' - // check the promises either serially or concurrently - const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity); +var XRANGEPLAINLOOSE = R++ +src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[PRERELEASELOOSE] + ')?' + + src[BUILD] + '?' + + ')?)?' - return Promise.all(items.map(el => checkLimit(() => finder(el)))) - .then(() => {}) - .catch(err => err instanceof EndError ? err.value : Promise.reject(err)); -}; +var XRANGE = R++ +src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$' +var XRANGELOOSE = R++ +src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$' +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +var COERCE = R++ +src[COERCE] = '(?:^|[^\\d])' + + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:$|[^\\d])' -/***/ }), +// Tilde ranges. +// Meaning is "reasonably at or greater than" +var LONETILDE = R++ +src[LONETILDE] = '(?:~>?)' -/***/ 746: -/***/ ((module) => { +var TILDETRIM = R++ +src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+' +re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g') +var tildeTrimReplace = '$1~' -"use strict"; +var TILDE = R++ +src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$' +var TILDELOOSE = R++ +src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$' -module.exports = cb => new Promise(resolve => { - resolve(cb()); -}); +// Caret ranges. +// Meaning is "at least and backwards compatible with" +var LONECARET = R++ +src[LONECARET] = '(?:\\^)' +var CARETTRIM = R++ +src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+' +re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g') +var caretTrimReplace = '$1^' -/***/ }), +var CARET = R++ +src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$' +var CARETLOOSE = R++ +src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$' -/***/ 6615: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +// A simple gt/lt/eq thing, or just "" to indicate "any version" +var COMPARATORLOOSE = R++ +src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$' +var COMPARATOR = R++ +src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$' -"use strict"; +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +var COMPARATORTRIM = R++ +src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')' -const errorEx = __nccwpck_require__(3505); -const fallback = __nccwpck_require__(5586); +// this one has to use the /g flag +re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g') +var comparatorTrimReplace = '$1$2$3' -const JSONError = errorEx('JSONError', { - fileName: errorEx.append('in %s') -}); +// 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. +var HYPHENRANGE = R++ +src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAIN] + ')' + + '\\s*$' -module.exports = (input, reviver, filename) => { - if (typeof reviver === 'string') { - filename = reviver; - reviver = null; - } +var HYPHENRANGELOOSE = R++ +src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s*$' - try { - try { - return JSON.parse(input, reviver); - } catch (err) { - fallback(input, reviver); +// Star ranges basically just allow anything at all. +var STAR = R++ +src[STAR] = '(<|>)?=?\\s*\\*' - throw err; - } - } catch (err) { - err.message = err.message.replace(/\n/g, ''); +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + debug(i, src[i]) + if (!re[i]) { + re[i] = new RegExp(src[i]) + } +} - const jsonErr = new JSONError(err); - if (filename) { - jsonErr.fileName = filename; - } +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - throw jsonErr; - } -}; + if (version instanceof SemVer) { + return version + } + if (typeof version !== 'string') { + return null + } -/***/ }), + if (version.length > MAX_LENGTH) { + return null + } -/***/ 6978: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + var r = options.loose ? re[LOOSE] : re[FULL] + if (!r.test(version)) { + return null + } -"use strict"; + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} -const fs = __nccwpck_require__(5747); +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} -module.exports = fp => new Promise(resolve => { - fs.access(fp, err => { - resolve(!err); - }); -}); +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} -module.exports.sync = fp => { - try { - fs.accessSync(fp); - return true; - } catch (err) { - return false; - } -}; +exports.SemVer = SemVer + +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } -/***/ }), + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } -/***/ 539: -/***/ ((module) => { + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose -"use strict"; + var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]) -module.exports = opts => { - opts = opts || {}; + if (!m) { + throw new TypeError('Invalid Version: ' + version) + } - const env = opts.env || process.env; - const platform = opts.platform || process.platform; + this.raw = version - if (platform !== 'win32') { - return 'PATH'; - } + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] - return Object.keys(env).find(x => x.toUpperCase() === 'PATH') || 'Path'; -}; + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } -/***/ }), + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } -/***/ 4810: -/***/ ((module) => { + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } -"use strict"; + this.build = m[5] ? m[5].split('.') : [] + this.format() +} +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} -const processFn = (fn, opts) => function () { - const P = opts.promiseModule; - const args = new Array(arguments.length); +SemVer.prototype.toString = function () { + return this.version +} - for (let i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - return new P((resolve, reject) => { - if (opts.errorFirst) { - args.push(function (err, result) { - if (opts.multiArgs) { - const results = new Array(arguments.length - 1); + return this.compareMain(other) || this.comparePre(other) +} - for (let i = 1; i < arguments.length; i++) { - results[i - 1] = arguments[i]; - } +SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - if (err) { - results.unshift(err); - reject(results); - } else { - resolve(results); - } - } else if (err) { - reject(err); - } else { - resolve(result); - } - }); - } else { - args.push(function (result) { - if (opts.multiArgs) { - const results = new Array(arguments.length - 1); + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) +} - for (let i = 0; i < arguments.length; i++) { - results[i] = arguments[i]; - } +SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } - resolve(results); - } else { - resolve(result); - } - }); - } + // 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 + } - fn.apply(this, args); - }); -}; + var i = 0 + do { + var a = this.prerelease[i] + var 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) +} -module.exports = (obj, opts) => { - opts = Object.assign({ - exclude: [/.+(Sync|Stream)$/], - errorFirst: true, - promiseModule: Promise - }, opts); +// preminor will bump the version up to the next minor release, and immediately +// down to pre-release. premajor and prepatch work the same way. +SemVer.prototype.inc = function (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // 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 filter = key => { - const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); - return opts.include ? opts.include.some(match) : !opts.exclude.some(match); - }; + 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 { + var 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 - let ret; - if (typeof obj === 'function') { - ret = function () { - if (opts.excludeMain) { - return obj.apply(this, arguments); - } + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } - return processFn(obj, opts).apply(this, arguments); - }; - } else { - ret = Object.create(Object.getPrototypeOf(obj)); - } + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} - for (const key in obj) { // eslint-disable-line guard-for-in - const x = obj[key]; - ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x; - } +exports.diff = diff +function diff (version1, version2) { + if (eq(version1, version2)) { + return null + } else { + var v1 = parse(version1) + var v2 = parse(version2) + var prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = 'prerelease' + } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} - return ret; -}; +exports.compareIdentifiers = compareIdentifiers +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) -/***/ }), + if (anum && bnum) { + a = +a + b = +b + } -/***/ 1235: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} -"use strict"; +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} -const path = __nccwpck_require__(5622); -const findUp = __nccwpck_require__(9486); -const loadJsonFile = __nccwpck_require__(5978); +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} -const filepaths = new WeakMap(); -const filepath = conf => filepaths.get(conf); -const findNextCwd = pkgPath => path.resolve(path.dirname(pkgPath), '..'); +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} -const addFp = (obj, fp) => { - filepaths.set(obj, fp); - return obj; -}; +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} -const pkgConf = (namespace, opts) => { - if (!namespace) { - return Promise.reject(new TypeError('Expected a namespace')); - } +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} - opts = opts || {}; +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} - return findUp('package.json', opts.cwd ? {cwd: opts.cwd} : {}) - .then(fp => { - if (!fp) { - return addFp(Object.assign({}, opts.defaults), fp); - } +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} - return loadJsonFile(fp).then(pkg => { - if (opts.skipOnFalse && pkg[namespace] === false) { - const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)}); - return pkgConf(namespace, newOpts); - } +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compare(a, b, loose) + }) +} - return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp); - }); - }); -}; +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.rcompare(a, b, loose) + }) +} -const sync = (namespace, opts) => { - if (!namespace) { - throw new TypeError('Expected a namespace'); - } +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} - opts = opts || {}; +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} - const fp = findUp.sync('package.json', opts.cwd ? {cwd: opts.cwd} : {}); +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} - if (!fp) { - return addFp(Object.assign({}, opts.defaults), fp); - } +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} - const pkg = loadJsonFile.sync(fp); +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} - if (opts.skipOnFalse && pkg[namespace] === false) { - const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)}); - return sync(namespace, newOpts); - } +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} - return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp); -}; +exports.cmp = cmp +function cmp (a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b -module.exports = pkgConf; -module.exports.filepath = filepath; -module.exports.sync = sync; + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + case '': + case '=': + case '==': + return eq(a, b, loose) -/***/ }), + case '!=': + return neq(a, b, loose) -/***/ 8341: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + case '>': + return gt(a, b, loose) -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 + case '>=': + return gte(a, b, loose) -var noop = function () {} -var ancient = /^v?\.0/.test(process.version) + case '<': + return lt(a, b, loose) -var isFn = function (fn) { - return typeof fn === 'function' -} + case '<=': + return lte(a, b, loose) -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) + default: + throw new TypeError('Invalid operator: ' + op) + } } -var isRequest = function (stream) { - return stream.setHeader && isFn(stream.abort) -} +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -var destroyer = function (stream, reading, writing, callback) { - callback = once(callback) + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } - var closed = false - stream.on('close', function () { - closed = true - }) + if (!(this instanceof Comparator)) { + return new Comparator(comp, options) + } - eos(stream, {readable: reading, writable: writing}, function (err) { - if (err) return callback(err) - closed = true - callback() - }) + 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 + } - var destroyed = false - return function (err) { - if (closed) return - if (destroyed) return - destroyed = true + debug('comp', this) +} - 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 ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR] + var m = comp.match(r) - if (isFn(stream.destroy)) return stream.destroy() + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } - callback(err || new Error('stream was destroyed')) + this.operator = m[1] + if (this.operator === '=') { + this.operator = '' } -} -var call = function (fn) { - fn() + // 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) + } } -var pipe = function (from, to) { - return from.pipe(to) +Comparator.prototype.toString = function () { + return this.value } -var pump = function () { - var streams = Array.prototype.slice.call(arguments) - var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop +Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) - if (Array.isArray(streams[0])) streams = streams[0] - if (streams.length < 2) throw new Error('pump requires two streams per minimum') + if (this.semver === ANY) { + return true + } - 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 (typeof version === 'string') { + version = new SemVer(version, this.options) + } - return streams.reduce(pipe) + return cmp(version, this.operator, this.semver, this.options) } -module.exports = pump - - -/***/ }), +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } -/***/ 5911: -/***/ ((module, exports) => { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -exports = module.exports = SemVer + var rangeTmp -var debug -/* istanbul ignore next */ -if (typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function () { - var args = Array.prototype.slice.call(arguments, 0) - args.unshift('SEMVER') - console.log.apply(console, args) + if (this.operator === '') { + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) } -} else { - debug = function () {} -} -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -exports.SEMVER_SPEC_VERSION = '2.0.0' + var sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + var sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + var sameSemVer = this.semver.version === comp.semver.version + var differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + var oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + ((this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<')) + var oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + ((this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>')) -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 + return sameDirectionIncreasing || sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +} -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var R = 0 + if (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } + } -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. + if (range instanceof Comparator) { + return new Range(range.value, options) + } -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. + if (!(this instanceof Range)) { + return new Range(range, options) + } -var NUMERICIDENTIFIER = R++ -src[NUMERICIDENTIFIER] = '0|[1-9]\\d*' -var NUMERICIDENTIFIERLOOSE = R++ -src[NUMERICIDENTIFIERLOOSE] = '[0-9]+' + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. + // First, split based on boolean or || + this.raw = range + this.set = range.split(/\s*\|\|\s*/).map(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) -var NONNUMERICIDENTIFIER = R++ -src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } -// ## Main Version -// Three dot-separated numeric identifiers. + this.format() +} -var MAINVERSION = R++ -src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + - '(' + src[NUMERICIDENTIFIER] + ')\\.' + - '(' + src[NUMERICIDENTIFIER] + ')' +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} -var MAINVERSIONLOOSE = R++ -src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[NUMERICIDENTIFIERLOOSE] + ')' +Range.prototype.toString = function () { + return this.range +} -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. +Range.prototype.parseRange = function (range) { + var loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[COMPARATORTRIM]) -var PRERELEASEIDENTIFIER = R++ -src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + - '|' + src[NONNUMERICIDENTIFIER] + ')' + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[TILDETRIM], tildeTrimReplace) -var PRERELEASEIDENTIFIERLOOSE = R++ -src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + - '|' + src[NONNUMERICIDENTIFIER] + ')' + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[CARETTRIM], caretTrimReplace) -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. + // normalize spaces + range = range.split(/\s+/).join(' ') -var PRERELEASE = R++ -src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + - '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))' + // At this point, the range is completely trimmed and + // ready to be split into comparators. -var PRERELEASELOOSE = R++ -src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))' + var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR] + var set = range.split(' ').map(function (comp) { + return parseComparator(comp, this.options) + }, this).join(' ').split(/\s+/) + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function (comp) { + return !!comp.match(compRe) + }) + } + set = set.map(function (comp) { + return new Comparator(comp, this.options) + }, this) -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. + return set +} -var BUILDIDENTIFIER = R++ -src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+' +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. + return this.set.some(function (thisComparators) { + return thisComparators.every(function (thisComparator) { + return range.set.some(function (rangeComparators) { + return rangeComparators.every(function (rangeComparator) { + return thisComparator.intersects(rangeComparator, options) + }) + }) + }) + }) +} -var BUILD = R++ -src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + - '(?:\\.' + src[BUILDIDENTIFIER] + ')*))' +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators +function toComparators (range, options) { + return new Range(range, options).set.map(function (comp) { + return comp.map(function (c) { + return c.value + }).join(' ').trim().split(' ') + }) +} -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator (comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} -// 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. +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' +} -var FULL = R++ -var FULLPLAIN = 'v?' + src[MAINVERSION] + - src[PRERELEASE] + '?' + - src[BUILD] + '?' +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceTilde(comp, options) + }).join(' ') +} -src[FULL] = '^' + FULLPLAIN + '$' +function replaceTilde (comp, options) { + var r = options.loose ? re[TILDELOOSE] : re[TILDE] + return comp.replace(r, function (_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr) + var ret -// 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. -var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + - src[PRERELEASELOOSE] + '?' + - src[BUILD] + '?' + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else if (pr) { + debug('replaceTilde pr', pr) + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } -var LOOSE = R++ -src[LOOSE] = '^' + LOOSEPLAIN + '$' + debug('tilde return', ret) + return ret + }) +} -var GTLT = R++ -src[GTLT] = '((?:<|>)?=?)' +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceCaret(comp, options) + }).join(' ') +} -// 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. -var XRANGEIDENTIFIERLOOSE = R++ -src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -var XRANGEIDENTIFIER = R++ -src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*' +function replaceCaret (comp, options) { + debug('caret', comp, options) + var r = options.loose ? re[CARETLOOSE] : re[CARET] + return comp.replace(r, function (_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr) + var ret -var XRANGEPLAIN = R++ -src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + - '(?:' + src[PRERELEASE] + ')?' + - src[BUILD] + '?' + - ')?)?' + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + if (M === '0') { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else { + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + (+M + 1) + '.0.0' + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + (+M + 1) + '.0.0' + } + } -var XRANGEPLAINLOOSE = R++ -src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[PRERELEASELOOSE] + ')?' + - src[BUILD] + '?' + - ')?)?' + debug('caret return', ret) + return ret + }) +} -var XRANGE = R++ -src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$' -var XRANGELOOSE = R++ -src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$' +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map(function (comp) { + return replaceXRange(comp, options) + }).join(' ') +} -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -var COERCE = R++ -src[COERCE] = '(?:^|[^\\d])' + - '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:$|[^\\d])' +function replaceXRange (comp, options) { + comp = comp.trim() + var r = options.loose ? re[XRANGELOOSE] : re[XRANGE] + return comp.replace(r, function (ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + var xM = isX(M) + var xm = xM || isX(m) + var xp = xm || isX(p) + var anyX = xp -// Tilde ranges. -// Meaning is "reasonably at or greater than" -var LONETILDE = R++ -src[LONETILDE] = '(?:~>?)' + if (gtlt === '=' && anyX) { + gtlt = '' + } -var TILDETRIM = R++ -src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+' -re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g') -var tildeTrimReplace = '$1~' + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<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 -var TILDE = R++ -src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$' -var TILDELOOSE = R++ -src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$' + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + 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 + } + } -// Caret ranges. -// Meaning is "at least and backwards compatible with" -var LONECARET = R++ -src[LONECARET] = '(?:\\^)' + ret = gtlt + M + '.' + m + '.' + p + } else if (xm) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (xp) { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } -var CARETTRIM = R++ -src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+' -re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g') -var caretTrimReplace = '$1^' + debug('xRange return', ret) -var CARET = R++ -src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$' -var CARETLOOSE = R++ -src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$' + return ret + }) +} -// A simple gt/lt/eq thing, or just "" to indicate "any version" -var COMPARATORLOOSE = R++ -src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$' -var COMPARATOR = R++ -src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$' +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars (comp, options) { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[STAR], '') +} -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -var COMPARATORTRIM = R++ -src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + - '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')' +// This function is passed to string.replace(re[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 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0 +function hyphenReplace ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = '>=' + fM + '.0.0' + } else if (isX(fp)) { + from = '>=' + fM + '.' + fm + '.0' + } else { + from = '>=' + from + } -// this one has to use the /g flag -re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = '<' + (+tM + 1) + '.0.0' + } else if (isX(tp)) { + to = '<' + tM + '.' + (+tm + 1) + '.0' + } else if (tpr) { + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr + } else { + to = '<=' + to + } -// 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. -var HYPHENRANGE = R++ -src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + - '\\s+-\\s+' + - '(' + src[XRANGEPLAIN] + ')' + - '\\s*$' + return (from + ' ' + to).trim() +} -var HYPHENRANGELOOSE = R++ -src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[XRANGEPLAINLOOSE] + ')' + - '\\s*$' +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false + } -// Star ranges basically just allow anything at all. -var STAR = R++ -src[STAR] = '(<|>)?=?\\s*\\*' + if (typeof version === 'string') { + version = new SemVer(version, this.options) + } -// Compile to actual regexp objects. -// All are flag-free, unless they were created above with a flag. -for (var i = 0; i < R; i++) { - debug(i, src[i]) - if (!re[i]) { - re[i] = new RegExp(src[i]) + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } } + return false } -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false } } - if (version instanceof SemVer) { - return version - } + 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 (i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue + } - if (typeof version !== 'string') { - return null - } + if (set[i].semver.prerelease.length > 0) { + var allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } - if (version.length > MAX_LENGTH) { - return null + // Version has a -pre, but it's not one of the ones we like. + return false } - var r = options.loose ? re[LOOSE] : re[FULL] - if (!r.test(version)) { - return null - } + return true +} +exports.satisfies = satisfies +function satisfies (version, range, options) { try { - return new SemVer(version, options) + range = new Range(range, options) } catch (er) { - return null + return false } + return range.test(version) } -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null -} - -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} - -exports.SemVer = SemVer - -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } +exports.maxSatisfying = maxSatisfying +function maxSatisfying (versions, range, options) { + var max = null + var maxSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version - } else { - version = version.version + versions.forEach(function (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) + } } - } else if (typeof version !== 'string') { - throw new TypeError('Invalid Version: ' + version) - } - - if (version.length > MAX_LENGTH) { - throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') - } - - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - - var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]) + }) + return max +} - if (!m) { - throw new TypeError('Invalid Version: ' + version) +exports.minSatisfying = minSatisfying +function minSatisfying (versions, range, options) { + var min = null + var minSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null } + versions.forEach(function (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 +} - this.raw = version - - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] +exports.minVersion = minVersion +function minVersion (range, loose) { + range = new Range(range, loose) - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') + var minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } else { - this.prerelease = m[4].split('.').map(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } + comparators.forEach(function (comparator) { + // Clone to avoid manipulating the comparator's semver object. + var 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 (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error('Unexpected operation: ' + comparator.operator) } - return id }) } - this.build = m[5] ? m[5].split('.') : [] - this.format() -} - -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') + if (minver && range.test(minver)) { + return minver } - return this.version -} -SemVer.prototype.toString = function () { - return this.version + return null } -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) +exports.validRange = validRange +function 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 } - - return this.compareMain(other) || this.comparePre(other) } -SemVer.prototype.compareMain = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr +function ltr (version, range, options) { + return outside(version, range, '<', options) +} - return compareIdentifiers(this.major, other.major) || - compareIdentifiers(this.minor, other.minor) || - compareIdentifiers(this.patch, other.patch) +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr +function gtr (version, range, options) { + return outside(version, range, '>', options) } -SemVer.prototype.comparePre = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) +exports.outside = outside +function outside (version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) + + var gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') } - // 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 + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false } - var i = 0 - do { - var a = this.prerelease[i] - var 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) -} + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. -// preminor will bump the version up to the next minor release, and immediately -// down to pre-release. premajor and prepatch work the same way. -SemVer.prototype.inc = function (release, identifier) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier) - break - case 'prepatch': - // 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 + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] - 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 { - var 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) - } + var high = null + var low = null + + comparators.forEach(function (comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.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] - } + 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 } - break + }) - default: - throw new Error('invalid increment argument: ' + release) + // 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 + } } - this.format() - this.raw = this.version - return this + return true } -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined +exports.prerelease = prerelease +function prerelease (version, options) { + var parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} + +exports.intersects = intersects +function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} + +exports.coerce = coerce +function coerce (version) { + if (version instanceof SemVer) { + return version } - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { + if (typeof version !== 'string') { return null } -} -exports.diff = diff -function diff (version1, version2) { - if (eq(version1, version2)) { + var match = version.match(re[COERCE]) + + if (match == null) { return null - } else { - var v1 = parse(version1) - var v2 = parse(version2) - var prefix = '' - if (v1.prerelease.length || v2.prerelease.length) { - prefix = 'pre' - var defaultResult = 'prerelease' - } - for (var key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key - } - } - } - return defaultResult // may be undefined } + + return parse(match[1] + + '.' + (match[2] || '0') + + '.' + (match[3] || '0')) } -exports.compareIdentifiers = compareIdentifiers -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) +/***/ }), - if (anum && bnum) { - a = +a - b = +b - } +/***/ 7032: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 -} +"use strict"; -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} +var shebangRegex = __nccwpck_require__(2638); -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} +module.exports = function (str) { + var match = str.match(shebangRegex); -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} + if (!match) { + return null; + } -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} + var arr = match[0].replace(/#! ?/, '').split(' '); + var bin = arr[0].split('/').pop(); + var arg = arr[1]; -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} + return (bin === 'env' ? + arg : + bin + (arg ? ' ' + arg : '') + ); +}; -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} +/***/ }), -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compare(a, b, loose) - }) -} +/***/ 2638: +/***/ ((module) => { -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.rcompare(a, b, loose) - }) -} +"use strict"; -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} +module.exports = /^#!.*/; -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} +/***/ }), -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} +/***/ 4931: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 +// 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) + +var EE = __nccwpck_require__(8614) +/* istanbul ignore if */ +if (typeof EE !== 'function') { + EE = EE.EventEmitter } -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 +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 = {} } -exports.cmp = cmp -function cmp (a, op, b, loose) { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b +// 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 +} - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b +module.exports = function (cb, opts) { + assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') - case '': - case '=': - case '==': - return eq(a, b, loose) + if (loaded === false) { + load() + } - case '!=': - return neq(a, b, loose) + var ev = 'exit' + if (opts && opts.alwaysLast) { + ev = 'afterexit' + } - case '>': - return gt(a, b, loose) + var remove = function () { + emitter.removeListener(ev, cb) + if (emitter.listeners('exit').length === 0 && + emitter.listeners('afterexit').length === 0) { + unload() + } + } + emitter.on(ev, cb) - case '>=': - return gte(a, b, loose) + return remove +} - case '<': - return lt(a, b, loose) +module.exports.unload = unload +function unload () { + if (!loaded) { + return + } + loaded = false - case '<=': - return lte(a, b, loose) + signals.forEach(function (sig) { + try { + process.removeListener(sig, sigListeners[sig]) + } catch (er) {} + }) + process.emit = originalProcessEmit + process.reallyExit = originalProcessReallyExit + emitter.count -= 1 +} - default: - throw new TypeError('Invalid operator: ' + op) +function emit (event, code, signal) { + if (emitter.emitted[event]) { + return } + emitter.emitted[event] = true + emitter.emit(event, code, signal) } -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +// { : , ... } +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) } } +}) - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } +module.exports.signals = function () { + return signals +} - if (!(this instanceof Comparator)) { - return new Comparator(comp, options) - } +module.exports.load = load - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) +var loaded = false - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version +function load () { + if (loaded) { + return } + loaded = true - debug('comp', this) -} + // 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 -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR] - var m = comp.match(r) + signals = signals.filter(function (sig) { + try { + process.on(sig, sigListeners[sig]) + return true + } catch (er) { + return false + } + }) - if (!m) { - throw new TypeError('Invalid comparator: ' + comp) - } + process.emit = processEmit + process.reallyExit = processReallyExit +} - this.operator = m[1] - if (this.operator === '=') { - this.operator = '' - } +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) +} - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY +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 { - this.semver = new SemVer(m[2], this.options.loose) + return originalProcessEmit.apply(this, arguments) } } -Comparator.prototype.toString = function () { - return this.value -} -Comparator.prototype.test = function (version) { - debug('Comparator.test', version, this.options.loose) +/***/ }), - if (this.semver === ANY) { - return true - } +/***/ 3710: +/***/ ((module) => { - if (typeof version === 'string') { - version = new SemVer(version, this.options) - } +// 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' +] - return cmp(version, this.operator, this.semver, this.options) +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' + ) } -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } +if (process.platform === 'linux') { + module.exports.push( + 'SIGIO', + 'SIGPOLL', + 'SIGPWR', + 'SIGSTKFLT', + 'SIGUNUSED' + ) +} - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - var rangeTmp +/***/ }), - if (this.operator === '') { - rangeTmp = new Range(comp.value, options) - return satisfies(this.value, rangeTmp, options) - } else if (comp.operator === '') { - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) - } +/***/ 528: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - var sameDirectionIncreasing = - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '>=' || comp.operator === '>') - var sameDirectionDecreasing = - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '<=' || comp.operator === '<') - var sameSemVer = this.semver.version === comp.semver.version - var differentDirectionsInclusive = - (this.operator === '>=' || this.operator === '<=') && - (comp.operator === '>=' || comp.operator === '<=') - var oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, options) && - ((this.operator === '>=' || this.operator === '>') && - (comp.operator === '<=' || comp.operator === '<')) - var oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, options) && - ((this.operator === '<=' || this.operator === '<') && - (comp.operator === '>=' || comp.operator === '>')) +"use strict"; - return sameDirectionIncreasing || sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || oppositeDirectionsGreaterThan -} +const Signale = __nccwpck_require__(5132); + +module.exports = Object.assign(new Signale(), {Signale}); -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - 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) { - return new Range(range.value, options) - } +/***/ 5132: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (!(this instanceof Range)) { - return new Range(range, options) - } +"use strict"; - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease +const util = __nccwpck_require__(1669); +const path = __nccwpck_require__(5622); +const readline = __nccwpck_require__(1058); +const chalk = __nccwpck_require__(8707); +const figures = __nccwpck_require__(7099); +const pkgConf = __nccwpck_require__(1235); +const pkg = __nccwpck_require__(2728); +const defaultTypes = __nccwpck_require__(9881); - // First, split based on boolean or || - this.raw = range - this.set = range.split(/\s*\|\|\s*/).map(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) +const {green, grey, red, underline, yellow} = chalk; - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) +let isPreviousLogInteractive = false; +const defaults = pkg.options.default; +const namespace = pkg.name; + +class Signale { + constructor(options = {}) { + this._interactive = options.interactive || false; + this._config = Object.assign(this.packageConfiguration, options.config); + this._customTypes = Object.assign({}, options.types); + this._disabled = options.disabled || false; + this._scopeName = options.scope || ''; + this._timers = options.timers || new Map(); + this._types = this._mergeTypes(defaultTypes, this._customTypes); + this._stream = options.stream || process.stdout; + this._longestLabel = this._getLongestLabel(); + this._secrets = options.secrets || []; + this._generalLogLevel = this._validateLogLevel(options.logLevel); + + Object.keys(this._types).forEach(type => { + this[type] = this._logger.bind(this, type); + }); } - this.format() -} + get _now() { + return Date.now(); + } -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} + get scopeName() { + return this._scopeName; + } -Range.prototype.toString = function () { - return this.range -} + get currentOptions() { + return Object.assign({}, { + config: this._config, + disabled: this._disabled, + types: this._customTypes, + interactive: this._interactive, + timers: this._timers, + stream: this._stream, + secrets: this._secrets, + logLevel: this._generalLogLevel + }); + } -Range.prototype.parseRange = function (range) { - var loose = this.options.loose - range = range.trim() - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE] - range = range.replace(hr, hyphenReplace) - debug('hyphen replace', range) - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[COMPARATORTRIM]) + get date() { + return new Date().toLocaleDateString(); + } - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[TILDETRIM], tildeTrimReplace) + get timestamp() { + return new Date().toLocaleTimeString(); + } - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[CARETTRIM], caretTrimReplace) + get filename() { + const _ = Error.prepareStackTrace; + Error.prepareStackTrace = (error, stack) => stack; + const {stack} = new Error(); + Error.prepareStackTrace = _; - // normalize spaces - range = range.split(/\s+/).join(' ') + const callers = stack.map(x => x.getFileName()); - // At this point, the range is completely trimmed and - // ready to be split into comparators. + const firstExternalFilePath = callers.find(x => { + return x !== callers[0]; + }); - var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR] - var set = range.split(' ').map(function (comp) { - return parseComparator(comp, this.options) - }, this).join(' ').split(/\s+/) - if (this.options.loose) { - // in loose mode, throw out any that are not valid comparators - set = set.filter(function (comp) { - return !!comp.match(compRe) - }) + return firstExternalFilePath ? path.basename(firstExternalFilePath) : 'anonymous'; } - set = set.map(function (comp) { - return new Comparator(comp, this.options) - }, this) - return set -} - -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') + get packageConfiguration() { + return pkgConf.sync(namespace, {defaults}); } - return this.set.some(function (thisComparators) { - return thisComparators.every(function (thisComparator) { - return range.set.some(function (rangeComparators) { - return rangeComparators.every(function (rangeComparator) { - return thisComparator.intersects(rangeComparator, options) - }) - }) - }) - }) -} + get _longestUnderlinedLabel() { + return underline(this._longestLabel); + } -// Mostly just for testing and legacy API reasons -exports.toComparators = toComparators -function toComparators (range, options) { - return new Range(range, options).set.map(function (comp) { - return comp.map(function (c) { - return c.value - }).join(' ').trim().split(' ') - }) -} + get _logLevels() { + return { + info: 0, + timer: 1, + debug: 2, + warn: 3, + error: 4 + }; + } -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -function parseComparator (comp, options) { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp -} + set configuration(configObj) { + this._config = Object.assign(this.packageConfiguration, configObj); + } -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' -} + _arrayify(x) { + return Array.isArray(x) ? x : [x]; + } -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceTilde(comp, options) - }).join(' ') -} + _timeSpan(then) { + return (this._now - then); + } -function replaceTilde (comp, options) { - var r = options.loose ? re[TILDELOOSE] : re[TILDE] - return comp.replace(r, function (_, M, m, p, pr) { - debug('tilde', comp, _, M, m, p, pr) - var ret + _getLongestLabel() { + const {_types} = this; + const labels = Object.keys(_types).map(x => _types[x].label); + return labels.reduce((x, y) => x.length > y.length ? x : y); + } - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else if (pr) { - debug('replaceTilde pr', pr) - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } + _validateLogLevel(level) { + return Object.keys(this._logLevels).includes(level) ? level : 'info'; + } - debug('tilde return', ret) - return ret - }) -} + _mergeTypes(standard, custom) { + const types = Object.assign({}, standard); -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceCaret(comp, options) - }).join(' ') -} + Object.keys(custom).forEach(type => { + types[type] = Object.assign({}, types[type], custom[type]); + }); -function replaceCaret (comp, options) { - debug('caret', comp, options) - var r = options.loose ? re[CARETLOOSE] : re[CARET] - return comp.replace(r, function (_, M, m, p, pr) { - debug('caret', comp, _, M, m, p, pr) - var ret + return types; + } - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - if (M === '0') { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else { - ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + (+M + 1) + '.0.0' - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } + _filterSecrets(message) { + const {_secrets} = this; + + if (_secrets.length === 0) { + return message; } - debug('caret return', ret) - return ret - }) -} + let safeMessage = message; -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') -} + _secrets.forEach(secret => { + safeMessage = safeMessage.replace(new RegExp(secret, 'g'), '[secure]'); + }); -function replaceXRange (comp, options) { - comp = comp.trim() - var r = options.loose ? re[XRANGELOOSE] : re[XRANGE] - return comp.replace(r, function (ret, gtlt, M, m, p, pr) { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - var xM = isX(M) - var xm = xM || isX(m) - var xp = xm || isX(p) - var anyX = xp + return safeMessage; + } - if (gtlt === '=' && anyX) { - gtlt = '' + _formatStream(stream) { + return this._arrayify(stream); + } + + _formatDate() { + return `[${this.date}]`; + } + + _formatFilename() { + return `[${this.filename}]`; + } + + _formatScopeName() { + if (Array.isArray(this._scopeName)) { + const scopes = this._scopeName.filter(x => x.length !== 0); + return `${scopes.map(x => `[${x.trim()}]`).join(' ')}`; } - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<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 + return `[${this._scopeName}]`; + } - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - 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 - } - } + _formatTimestamp() { + return `[${this.timestamp}]`; + } - ret = gtlt + M + '.' + m + '.' + p - } else if (xm) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (xp) { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + _formatMessage(str) { + return util.format(...this._arrayify(str)); + } + + _meta() { + const meta = []; + + if (this._config.displayDate) { + meta.push(this._formatDate()); } - debug('xRange return', ret) + if (this._config.displayTimestamp) { + meta.push(this._formatTimestamp()); + } - return ret - }) -} + if (this._config.displayFilename) { + meta.push(this._formatFilename()); + } -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -function replaceStars (comp, options) { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[STAR], '') -} + if (this._scopeName.length !== 0 && this._config.displayScope) { + meta.push(this._formatScopeName()); + } -// This function is passed to string.replace(re[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 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = '>=' + fM + '.0.0' - } else if (isX(fp)) { - from = '>=' + fM + '.' + fm + '.0' - } else { - from = '>=' + from + if (meta.length !== 0) { + meta.push(`${figures.pointerSmall}`); + return meta.map(item => grey(item)); + } + + return meta; } - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = '<' + (+tM + 1) + '.0.0' - } else if (isX(tp)) { - to = '<' + tM + '.' + (+tm + 1) + '.0' - } else if (tpr) { - to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr - } else { - to = '<=' + to + _hasAdditional({suffix, prefix}, args) { + return (suffix || prefix) ? '' : this._formatMessage(args); } - return (from + ' ' + to).trim() -} + _buildSignale(type, ...args) { + let [msg, additional] = [{}, {}]; -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } + if (args.length === 1 && typeof (args[0]) === 'object' && args[0] !== null) { + if (args[0] instanceof Error) { + [msg] = args; + } else { + const [{prefix, message, suffix}] = args; + additional = Object.assign({}, {suffix, prefix}); + msg = message ? this._formatMessage(message) : this._hasAdditional(additional, args); + } + } else { + msg = this._formatMessage(args); + } - if (typeof version === 'string') { - version = new SemVer(version, this.options) - } + const signale = this._meta(); - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true + if (additional.prefix) { + if (this._config.underlinePrefix) { + signale.push(underline(additional.prefix)); + } else { + signale.push(additional.prefix); + } + } + + if (this._config.displayBadge && type.badge) { + signale.push(chalk[type.color](this._padEnd(type.badge, type.badge.length + 1))); } - } - return false -} -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false + if (this._config.displayLabel && type.label) { + const label = this._config.uppercaseLabel ? type.label.toUpperCase() : type.label; + if (this._config.underlineLabel) { + signale.push(chalk[type.color](this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); + } else { + signale.push(chalk[type.color](this._padEnd(label, this._longestLabel.length + 1))); + } } - } - 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 (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue + if (msg instanceof Error && msg.stack) { + const [name, ...rest] = msg.stack.split('\n'); + if (this._config.underlineMessage) { + signale.push(underline(name)); + } else { + signale.push(name); } - if (set[i].semver.prerelease.length > 0) { - var allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } + signale.push(grey(rest.map(l => l.replace(/^/, '\n')).join(''))); + return signale.join(' '); + } + + if (this._config.underlineMessage) { + signale.push(underline(msg)); + } else { + signale.push(msg); + } + + if (additional.suffix) { + if (this._config.underlineSuffix) { + signale.push(underline(additional.suffix)); + } else { + signale.push(additional.suffix); } } - // Version has a -pre, but it's not one of the ones we like. - return false + return signale.join(' '); } - return true -} + _write(stream, message) { + if (this._interactive && stream.isTTY && isPreviousLogInteractive) { + readline.moveCursor(stream, 0, -1); + readline.clearLine(stream); + readline.cursorTo(stream, 0); + } -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false + stream.write(message + '\n'); + isPreviousLogInteractive = this._interactive; } - return range.test(version) -} -exports.maxSatisfying = maxSatisfying -function maxSatisfying (versions, range, options) { - var max = null - var maxSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (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) - } + _log(message, streams = this._stream, logLevel) { + if (this.isEnabled() && this._logLevels[logLevel] >= this._logLevels[this._generalLogLevel]) { + this._formatStream(streams).forEach(stream => { + this._write(stream, message); + }); } - }) - return max -} + } -exports.minSatisfying = minSatisfying -function minSatisfying (versions, range, options) { - var min = null - var minSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null + _logger(type, ...messageObj) { + const {stream, logLevel} = this._types[type]; + const message = this._buildSignale(this._types[type], ...messageObj); + this._log(this._filterSecrets(message), stream, this._validateLogLevel(logLevel)); } - versions.forEach(function (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 -} -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) + _padEnd(str, targetLength) { + str = String(str); + targetLength = parseInt(targetLength, 10) || 0; - var minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } + if (str.length >= targetLength) { + return str; + } - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver + if (String.prototype.padEnd) { + return str.padEnd(targetLength); + } + + targetLength -= str.length; + return str + ' '.repeat(targetLength); } - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] + addSecrets(secrets) { + if (!Array.isArray(secrets)) { + throw new TypeError('Argument must be an array.'); + } - comparators.forEach(function (comparator) { - // Clone to avoid manipulating the comparator's semver object. - var 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 (!minver || gt(minver, compver)) { - minver = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error('Unexpected operation: ' + comparator.operator) - } - }) + this._secrets.push(...secrets); } - if (minver && range.test(minver)) { - return minver + clearSecrets() { + this._secrets = []; } - return null -} + config(configObj) { + this.configuration = configObj; + } -exports.validRange = validRange -function 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 + disable() { + this._disabled = true; } -} -// Determine if version is less than all the versions possible in the range -exports.ltr = ltr -function ltr (version, range, options) { - return outside(version, range, '<', options) -} + enable() { + this._disabled = false; + } -// Determine if version is greater than all the versions possible in the range. -exports.gtr = gtr -function gtr (version, range, options) { - return outside(version, range, '>', options) -} + isEnabled() { + return !this._disabled; + } -exports.outside = outside -function outside (version, range, hilo, options) { - version = new SemVer(version, options) - range = new Range(range, options) + scope(...name) { + if (name.length === 0) { + throw new Error('No scope name was defined.'); + } - var gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') + return new Signale(Object.assign(this.currentOptions, {scope: name})); } - // If it satisifes the range it is not outside - if (satisfies(version, range, options)) { - return false + unscope() { + this._scopeName = ''; } - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. - - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] + time(label) { + if (!label) { + label = `timer_${this._timers.size}`; + } - var high = null - var low = null + this._timers.set(label, this._now); - comparators.forEach(function (comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) + const message = this._meta(); + message.push(green(this._padEnd(this._types.start.badge, 2))); - // 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 (this._config.underlineLabel) { + message.push(green(this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); + } else { + message.push(green(this._padEnd(label, this._longestLabel.length + 1))); } - // 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 - } + message.push('Initialized timer...'); + this._log(message.join(' '), this._stream, 'timer'); + + return label; } - return true -} -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} + timeEnd(label) { + if (!label && this._timers.size) { + const is = x => x.includes('timer_'); + label = [...this._timers.keys()].reduceRight((x, y) => { + return is(x) ? x : (is(y) ? y : null); + }); + } -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} + if (this._timers.has(label)) { + const span = this._timeSpan(this._timers.get(label)); + this._timers.delete(label); -exports.coerce = coerce -function coerce (version) { - if (version instanceof SemVer) { - return version - } + const message = this._meta(); + message.push(red(this._padEnd(this._types.pause.badge, 2))); - if (typeof version !== 'string') { - return null - } + if (this._config.underlineLabel) { + message.push(red(this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); + } else { + message.push(red(this._padEnd(label, this._longestLabel.length + 1))); + } - var match = version.match(re[COERCE]) + message.push('Timer run for:'); + message.push(yellow(span < 1000 ? span + 'ms' : (span / 1000).toFixed(2) + 's')); + this._log(message.join(' '), this._stream, 'timer'); - if (match == null) { - return null + return {label, span}; + } } - - return parse(match[1] + - '.' + (match[2] || '0') + - '.' + (match[3] || '0')) } +module.exports = Signale; + /***/ }), -/***/ 7032: +/***/ 9881: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var shebangRegex = __nccwpck_require__(2638); - -module.exports = function (str) { - var match = str.match(shebangRegex); - - if (!match) { - return null; - } - - var arr = match[0].replace(/#! ?/, '').split(' '); - var bin = arr[0].split('/').pop(); - var arg = arr[1]; +const figures = __nccwpck_require__(7099); - return (bin === 'env' ? - arg : - bin + (arg ? ' ' + arg : '') - ); +module.exports = { + error: { + badge: figures.cross, + color: 'red', + label: 'error', + logLevel: 'error' + }, + fatal: { + badge: figures.cross, + color: 'red', + label: 'fatal', + logLevel: 'error' + }, + fav: { + badge: figures('❤'), + color: 'magenta', + label: 'favorite', + logLevel: 'info' + }, + info: { + badge: figures.info, + color: 'blue', + label: 'info', + logLevel: 'info' + }, + star: { + badge: figures.star, + color: 'yellow', + label: 'star', + logLevel: 'info' + }, + success: { + badge: figures.tick, + color: 'green', + label: 'success', + logLevel: 'info' + }, + wait: { + badge: figures.ellipsis, + color: 'blue', + label: 'waiting', + logLevel: 'info' + }, + warn: { + badge: figures.warning, + color: 'yellow', + label: 'warning', + logLevel: 'warn' + }, + complete: { + badge: figures.checkboxOn, + color: 'cyan', + label: 'complete', + logLevel: 'info' + }, + pending: { + badge: figures.checkboxOff, + color: 'magenta', + label: 'pending', + logLevel: 'info' + }, + note: { + badge: figures.bullet, + color: 'blue', + label: 'note', + logLevel: 'info' + }, + start: { + badge: figures.play, + color: 'green', + label: 'start', + logLevel: 'info' + }, + pause: { + badge: figures.squareSmallFilled, + color: 'yellow', + label: 'pause', + logLevel: 'info' + }, + debug: { + badge: figures('⬤'), + color: 'red', + label: 'debug', + logLevel: 'debug' + }, + await: { + badge: figures.ellipsis, + color: 'blue', + label: 'awaiting', + logLevel: 'info' + }, + watch: { + badge: figures.ellipsis, + color: 'yellow', + label: 'watching', + logLevel: 'info' + }, + log: { + badge: '', + color: '', + label: '', + logLevel: 'info' + } }; /***/ }), -/***/ 2638: +/***/ 8551: /***/ ((module) => { "use strict"; -module.exports = /^#!.*/; +module.exports = x => { + if (typeof x !== 'string') { + throw new TypeError('Expected a string, got ' + typeof x); + } + + // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string + // conversion translates it to FEFF (UTF-16 BOM) + if (x.charCodeAt(0) === 0xFEFF) { + return x.slice(1); + } + + return x; +}; /***/ }), -/***/ 4931: -/***/ ((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) +/***/ 5515: +/***/ ((module) => { -var EE = __nccwpck_require__(8614) -/* istanbul ignore if */ -if (typeof EE !== 'function') { - EE = EE.EventEmitter -} +"use strict"; -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 = {} -} +module.exports = function (x) { + var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); + var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); -// 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 -} + if (x[x.length - 1] === lf) { + x = x.slice(0, x.length - 1); + } -module.exports = function (cb, opts) { - assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') + if (x[x.length - 1] === cr) { + x = x.slice(0, x.length - 1); + } - if (loaded === false) { - load() - } + return x; +}; - var ev = 'exit' - if (opts && opts.alwaysLast) { - ev = 'afterexit' - } - var remove = function () { - emitter.removeListener(ev, cb) - if (emitter.listeners('exit').length === 0 && - emitter.listeners('afterexit').length === 0) { - unload() - } - } - emitter.on(ev, cb) +/***/ }), - return remove -} +/***/ 9318: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports.unload = unload -function unload () { - if (!loaded) { - return - } - loaded = false +"use strict"; - signals.forEach(function (sig) { - try { - process.removeListener(sig, sigListeners[sig]) - } catch (er) {} - }) - process.emit = originalProcessEmit - process.reallyExit = originalProcessReallyExit - emitter.count -= 1 -} +const os = __nccwpck_require__(2087); +const hasFlag = __nccwpck_require__(1621); -function emit (event, code, signal) { - if (emitter.emitted[event]) { - return - } - emitter.emitted[event] = true - emitter.emit(event, code, signal) +const env = process.env; + +let forceColor; +if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false')) { + forceColor = false; +} else if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + forceColor = true; +} +if ('FORCE_COLOR' in env) { + forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; } -// { : , ... } -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 translateLevel(level) { + if (level === 0) { + return false; + } -module.exports.signals = function () { - return signals + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; } -module.exports.load = load +function supportsColor(stream) { + if (forceColor === false) { + return 0; + } -var loaded = false + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } -function load () { - if (loaded) { - return - } - loaded = true + if (hasFlag('color=256')) { + return 2; + } - // 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 (stream && !stream.isTTY && forceColor !== true) { + return 0; + } - signals = signals.filter(function (sig) { - try { - process.on(sig, sigListeners[sig]) - return true - } catch (er) { - return false - } - }) + const min = forceColor ? 1 : 0; - process.emit = processEmit - process.reallyExit = processReallyExit -} + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows + // release that supports 256 colors. Windows 10 build 14931 is the first release + // that supports 16m/TrueColor. + const osRelease = os.release().split('.'); + if ( + Number(process.versions.node.split('.')[0]) >= 8 && + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } -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) -} + return 1; + } -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) - } -} + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } + return min; + } -/***/ }), + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } -/***/ 3710: -/***/ ((module) => { + if (env.COLORTERM === 'truecolor') { + return 3; + } -// 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' -] + if ('TERM_PROGRAM' in env) { + const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); -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' - ) -} + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } -if (process.platform === 'linux') { - module.exports.push( - 'SIGIO', - 'SIGPOLL', - 'SIGPWR', - 'SIGSTKFLT', - 'SIGUNUSED' - ) -} + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } -/***/ }), + if ('COLORTERM' in env) { + return 1; + } -/***/ 528: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (env.TERM === 'dumb') { + return min; + } -"use strict"; + return min; +} -const Signale = __nccwpck_require__(5132); +function getSupportLevel(stream) { + const level = supportsColor(stream); + return translateLevel(level); +} -module.exports = Object.assign(new Signale(), {Signale}); +module.exports = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr) +}; /***/ }), -/***/ 5132: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 5030: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -const util = __nccwpck_require__(1669); -const path = __nccwpck_require__(5622); -const readline = __nccwpck_require__(1058); -const chalk = __nccwpck_require__(8707); -const figures = __nccwpck_require__(7099); -const pkgConf = __nccwpck_require__(1235); -const pkg = __nccwpck_require__(2728); -const defaultTypes = __nccwpck_require__(9881); -const {green, grey, red, underline, yellow} = chalk; +Object.defineProperty(exports, "__esModule", ({ value: true })); -let isPreviousLogInteractive = false; -const defaults = pkg.options.default; -const namespace = pkg.name; +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -class Signale { - constructor(options = {}) { - this._interactive = options.interactive || false; - this._config = Object.assign(this.packageConfiguration, options.config); - this._customTypes = Object.assign({}, options.types); - this._disabled = options.disabled || false; - this._scopeName = options.scope || ''; - this._timers = options.timers || new Map(); - this._types = this._mergeTypes(defaultTypes, this._customTypes); - this._stream = options.stream || process.stdout; - this._longestLabel = this._getLongestLabel(); - this._secrets = options.secrets || []; - this._generalLogLevel = this._validateLogLevel(options.logLevel); +var osName = _interopDefault(__nccwpck_require__(4824)); - Object.keys(this._types).forEach(type => { - this[type] = this._logger.bind(this, type); - }); - } +function getUserAgent() { + try { + return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`; + } catch (error) { + if (/wmic os get Caption/.test(error.message)) { + return "Windows "; + } - get _now() { - return Date.now(); + return ""; } +} - get scopeName() { - return this._scopeName; - } +exports.getUserAgent = getUserAgent; +//# sourceMappingURL=index.js.map - get currentOptions() { - return Object.assign({}, { - config: this._config, - disabled: this._disabled, - types: this._customTypes, - interactive: this._interactive, - timers: this._timers, - stream: this._stream, - secrets: this._secrets, - logLevel: this._generalLogLevel - }); - } - get date() { - return new Date().toLocaleDateString(); - } +/***/ }), - get timestamp() { - return new Date().toLocaleTimeString(); - } +/***/ 4207: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - get filename() { - const _ = Error.prepareStackTrace; - Error.prepareStackTrace = (error, stack) => stack; - const {stack} = new Error(); - Error.prepareStackTrace = _; +module.exports = which +which.sync = whichSync - const callers = stack.map(x => x.getFileName()); +var isWindows = process.platform === 'win32' || + process.env.OSTYPE === 'cygwin' || + process.env.OSTYPE === 'msys' - const firstExternalFilePath = callers.find(x => { - return x !== callers[0]; - }); +var path = __nccwpck_require__(5622) +var COLON = isWindows ? ';' : ':' +var isexe = __nccwpck_require__(7126) - return firstExternalFilePath ? path.basename(firstExternalFilePath) : 'anonymous'; - } +function getNotFoundError (cmd) { + var er = new Error('not found: ' + cmd) + er.code = 'ENOENT' - get packageConfiguration() { - return pkgConf.sync(namespace, {defaults}); - } + return er +} - get _longestUnderlinedLabel() { - return underline(this._longestLabel); - } +function getPathInfo (cmd, opt) { + var colon = opt.colon || COLON + var pathEnv = opt.path || process.env.PATH || '' + var pathExt = [''] - get _logLevels() { - return { - info: 0, - timer: 1, - debug: 2, - warn: 3, - error: 4 - }; - } + pathEnv = pathEnv.split(colon) - set configuration(configObj) { - this._config = Object.assign(this.packageConfiguration, configObj); - } + var pathExtExe = '' + if (isWindows) { + pathEnv.unshift(process.cwd()) + pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') + pathExt = pathExtExe.split(colon) - _arrayify(x) { - return Array.isArray(x) ? x : [x]; - } - _timeSpan(then) { - return (this._now - then); + // Always test the cmd itself first. isexe will check to make sure + // it's found in the pathExt set. + if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') + pathExt.unshift('') } - _getLongestLabel() { - const {_types} = this; - const labels = Object.keys(_types).map(x => _types[x].label); - return labels.reduce((x, y) => x.length > y.length ? x : y); - } + // If it has a slash, then we don't bother searching the pathenv. + // just check the file itself, and that's it. + if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) + pathEnv = [''] - _validateLogLevel(level) { - return Object.keys(this._logLevels).includes(level) ? level : 'info'; + return { + env: pathEnv, + ext: pathExt, + extExe: pathExtExe } +} - _mergeTypes(standard, custom) { - const types = Object.assign({}, standard); +function which (cmd, opt, cb) { + if (typeof opt === 'function') { + cb = opt + opt = {} + } - Object.keys(custom).forEach(type => { - types[type] = Object.assign({}, types[type], custom[type]); - }); + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] - return types; - } + ;(function F (i, l) { + if (i === l) { + if (opt.all && found.length) + return cb(null, found) + else + return cb(getNotFoundError(cmd)) + } - _filterSecrets(message) { - const {_secrets} = this; + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) - if (_secrets.length === 0) { - return message; + var p = path.join(pathPart, cmd) + if (!pathPart && (/^\.[\\\/]/).test(cmd)) { + p = cmd.slice(0, 2) + p } + ;(function E (ii, ll) { + if (ii === ll) return F(i + 1, l) + var ext = pathExt[ii] + isexe(p + ext, { pathExt: pathExtExe }, function (er, is) { + if (!er && is) { + if (opt.all) + found.push(p + ext) + else + return cb(null, p + ext) + } + return E(ii + 1, ll) + }) + })(0, pathExt.length) + })(0, pathEnv.length) +} - let safeMessage = message; +function whichSync (cmd, opt) { + opt = opt || {} - _secrets.forEach(secret => { - safeMessage = safeMessage.replace(new RegExp(secret, 'g'), '[secure]'); - }); + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] + + for (var i = 0, l = pathEnv.length; i < l; i ++) { + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) - return safeMessage; + var p = path.join(pathPart, cmd) + if (!pathPart && /^\.[\\\/]/.test(cmd)) { + p = cmd.slice(0, 2) + p + } + for (var j = 0, ll = pathExt.length; j < ll; j ++) { + var cur = p + pathExt[j] + var is + try { + is = isexe.sync(cur, { pathExt: pathExtExe }) + if (is) { + if (opt.all) + found.push(cur) + else + return cur + } + } catch (ex) {} + } } - _formatStream(stream) { - return this._arrayify(stream); - } + if (opt.all && found.length) + return found - _formatDate() { - return `[${this.date}]`; - } + if (opt.nothrow) + return null - _formatFilename() { - return `[${this.filename}]`; - } + throw getNotFoundError(cmd) +} - _formatScopeName() { - if (Array.isArray(this._scopeName)) { - const scopes = this._scopeName.filter(x => x.length !== 0); - return `${scopes.map(x => `[${x.trim()}]`).join(' ')}`; - } - return `[${this._scopeName}]`; - } +/***/ }), - _formatTimestamp() { - return `[${this.timestamp}]`; - } +/***/ 3515: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - _formatMessage(str) { - return util.format(...this._arrayify(str)); - } +"use strict"; - _meta() { - const meta = []; +const os = __nccwpck_require__(2087); +const execa = __nccwpck_require__(5447); - if (this._config.displayDate) { - meta.push(this._formatDate()); - } +// Reference: https://www.gaijin.at/en/lstwinver.php +const names = new Map([ + ['10.0', '10'], + ['6.3', '8.1'], + ['6.2', '8'], + ['6.1', '7'], + ['6.0', 'Vista'], + ['5.2', 'Server 2003'], + ['5.1', 'XP'], + ['5.0', '2000'], + ['4.9', 'ME'], + ['4.1', '98'], + ['4.0', '95'] +]); - if (this._config.displayTimestamp) { - meta.push(this._formatTimestamp()); - } +const windowsRelease = release => { + const version = /\d+\.\d/.exec(release || os.release()); - if (this._config.displayFilename) { - meta.push(this._formatFilename()); - } + if (release && !version) { + throw new Error('`release` argument doesn\'t match `n.n`'); + } - if (this._scopeName.length !== 0 && this._config.displayScope) { - meta.push(this._formatScopeName()); - } + const ver = (version || [])[0]; - if (meta.length !== 0) { - meta.push(`${figures.pointerSmall}`); - return meta.map(item => grey(item)); - } + // Server 2008, 2012, 2016, and 2019 versions are ambiguous with desktop versions and must be detected at runtime. + // If `release` is omitted or we're on a Windows system, and the version number is an ambiguous version + // then use `wmic` to get the OS caption: https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx + // If `wmic` is obsoloete (later versions of Windows 10), use PowerShell instead. + // If the resulting caption contains the year 2008, 2012, 2016 or 2019, it is a server version, so return a server OS name. + if ((!release || release === os.release()) && ['6.1', '6.2', '6.3', '10.0'].includes(ver)) { + let stdout; + try { + stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; + } catch (_) { + stdout = execa.sync('powershell', ['(Get-CimInstance -ClassName Win32_OperatingSystem).caption']).stdout || ''; + } - return meta; - } + const year = (stdout.match(/2008|2012|2016|2019/) || [])[0]; - _hasAdditional({suffix, prefix}, args) { - return (suffix || prefix) ? '' : this._formatMessage(args); - } + if (year) { + return `Server ${year}`; + } + } - _buildSignale(type, ...args) { - let [msg, additional] = [{}, {}]; + return names.get(ver); +}; - if (args.length === 1 && typeof (args[0]) === 'object' && args[0] !== null) { - if (args[0] instanceof Error) { - [msg] = args; - } else { - const [{prefix, message, suffix}] = args; - additional = Object.assign({}, {suffix, prefix}); - msg = message ? this._formatMessage(message) : this._hasAdditional(additional, args); - } - } else { - msg = this._formatMessage(args); - } +module.exports = windowsRelease; - const signale = this._meta(); - if (additional.prefix) { - if (this._config.underlinePrefix) { - signale.push(underline(additional.prefix)); - } else { - signale.push(additional.prefix); - } - } +/***/ }), - if (this._config.displayBadge && type.badge) { - signale.push(chalk[type.color](this._padEnd(type.badge, type.badge.length + 1))); - } +/***/ 2940: +/***/ ((module) => { - if (this._config.displayLabel && type.label) { - const label = this._config.uppercaseLabel ? type.label.toUpperCase() : type.label; - if (this._config.underlineLabel) { - signale.push(chalk[type.color](this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); - } else { - signale.push(chalk[type.color](this._padEnd(label, this._longestLabel.length + 1))); - } - } +// Returns a wrapper function that returns a wrapped callback +// The wrapper function should do some stuff, and return a +// presumably different callback function. +// This makes sure that own properties are retained, so that +// decorations and such are not lost along the way. +module.exports = wrappy +function wrappy (fn, cb) { + if (fn && cb) return wrappy(fn)(cb) - if (msg instanceof Error && msg.stack) { - const [name, ...rest] = msg.stack.split('\n'); - if (this._config.underlineMessage) { - signale.push(underline(name)); - } else { - signale.push(name); - } + if (typeof fn !== 'function') + throw new TypeError('need wrapper function') - signale.push(grey(rest.map(l => l.replace(/^/, '\n')).join(''))); - return signale.join(' '); - } + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k] + }) - if (this._config.underlineMessage) { - signale.push(underline(msg)); - } else { - signale.push(msg); - } + return wrapper - if (additional.suffix) { - if (this._config.underlineSuffix) { - signale.push(underline(additional.suffix)); - } else { - signale.push(additional.suffix); - } + function wrapper() { + var args = new Array(arguments.length) + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] } - - return signale.join(' '); + var ret = fn.apply(this, args) + var cb = args[args.length-1] + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k] + }) + } + return ret } +} - _write(stream, message) { - if (this._interactive && stream.isTTY && isPreviousLogInteractive) { - readline.moveCursor(stream, 0, -1); - readline.clearLine(stream); - readline.cursorTo(stream, 0); - } - stream.write(message + '\n'); - isPreviousLogInteractive = this._interactive; - } +/***/ }), - _log(message, streams = this._stream, logLevel) { - if (this.isEnabled() && this._logLevels[logLevel] >= this._logLevels[this._generalLogLevel]) { - this._formatStream(streams).forEach(stream => { - this._write(stream, message); - }); - } - } +/***/ 4570: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - _logger(type, ...messageObj) { - const {stream, logLevel} = this._types[type]; - const message = this._buildSignale(this._types[type], ...messageObj); - this._log(this._filterSecrets(message), stream, this._validateLogLevel(logLevel)); - } +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ - _padEnd(str, targetLength) { - str = String(str); - targetLength = parseInt(targetLength, 10) || 0; +const core = __nccwpck_require__(2186); - if (str.length >= targetLength) { - return str; - } +const parseYaml = __nccwpck_require__(928); + +const defaultVals = { + username: core.getInput("GH_USERNAME"), + commit_msg: "⚡ Update README with the recent activity", + max_lines: 5, + readme_file: "./README.md", + disabled_events: ["comments"], + url_text: "{REPO}{ID}", + date: { + timezone: "0", + text: "Last Updated: {DATE}", + format: "dddd, mmmm dS, yyyy, h:MM:ss TT", + }, + comments: "💬 Commented on {ID} in {REPO}", + issue_opened: "❗️ Opened issue {ID} in {REPO}", + issue_closed: "✔️ Closed issue {ID} in {REPO}", + pr_opened: "💪 Opened PR {ID} in {REPO}", + pr_closed: "❌ Closed PR {ID} in {REPO}", + pr_merged: "🎉 Merged PR {ID} in {REPO}", + create_repo: "📔 Created new repository {REPO}", + fork_repo: "🔱 Forked {FORK} from {REPO}", + wiki_create: "📖 Created new wiki page {WIKI} in {REPO}", + added_member: "🤝 Became collaborator on {REPO}", + changes_approved: "👍 Approved {ID} in {REPO}", + changes_requested: "🔴 Requested changes in {ID} in {REPO}", + new_release: "✌️ Released {ID} in {REPO}", + new_star: "⭐ Starred {REPO}", +}; - if (String.prototype.padEnd) { - return str.padEnd(targetLength); - } +const userVals = parseYaml(core.getInput("CONFIG_FILE")); - targetLength -= str.length; - return str + ' '.repeat(targetLength); - } +if (userVals.settings) { + userVals.settings.date = { ...defaultVals.date, ...userVals.settings.date }; +} - addSecrets(secrets) { - if (!Array.isArray(secrets)) { - throw new TypeError('Argument must be an array.'); - } +let conf = { + ...defaultVals, + ...userVals.settings, + ...userVals.messages, +}; - this._secrets.push(...secrets); - } +let disabled = []; +conf.disabled_events.forEach((event) => { + disabled.push(event.trim().toLowerCase()); +}); - clearSecrets() { - this._secrets = []; - } +conf.disabled_events = disabled; - config(configObj) { - this.configuration = configObj; - } +const urlPrefix = "https://github.com"; - disable() { - this._disabled = true; - } +module.exports = { + ...conf, + urlPrefix, +}; - enable() { - this._disabled = false; - } - isEnabled() { - return !this._disabled; - } +/***/ }), - scope(...name) { - if (name.length === 0) { - throw new Error('No scope name was defined.'); - } +/***/ 4694: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return new Signale(Object.assign(this.currentOptions, {scope: name})); - } +const { comments } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - unscope() { - this._scopeName = ''; +const CommitCommentEvent = (item) => { + if (item.payload.action === "created") { + return comments + .replace(/{ID}/g, toUrlFormat(item, "commit_comment")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "commit_comment")) + .replace(/{URL}/g, makeCustomUrl(item, "commit_comment")); + } else { + return ""; } +}; - time(label) { - if (!label) { - label = `timer_${this._timers.size}`; - } +module.exports = CommitCommentEvent; - this._timers.set(label, this._now); - const message = this._meta(); - message.push(green(this._padEnd(this._types.start.badge, 2))); +/***/ }), - if (this._config.underlineLabel) { - message.push(green(this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); - } else { - message.push(green(this._padEnd(label, this._longestLabel.length + 1))); - } +/***/ 4865: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - message.push('Initialized timer...'); - this._log(message.join(' '), this._stream, 'timer'); +const { create_repo } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - return label; +const CreateEvent = (item) => { + if (item.payload.ref_type === "repository") { + return create_repo + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "create_repo")) + .replace(/{URL}/g, makeCustomUrl(item, "create_repo")); + } else { + return ""; } +}; - timeEnd(label) { - if (!label && this._timers.size) { - const is = x => x.includes('timer_'); - label = [...this._timers.keys()].reduceRight((x, y) => { - return is(x) ? x : (is(y) ? y : null); - }); - } +module.exports = CreateEvent; - if (this._timers.has(label)) { - const span = this._timeSpan(this._timers.get(label)); - this._timers.delete(label); - const message = this._meta(); - message.push(red(this._padEnd(this._types.pause.badge, 2))); +/***/ }), - if (this._config.underlineLabel) { - message.push(red(this._padEnd(underline(label), this._longestUnderlinedLabel.length + 1))); - } else { - message.push(red(this._padEnd(label, this._longestLabel.length + 1))); - } +/***/ 8075: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - message.push('Timer run for:'); - message.push(yellow(span < 1000 ? span + 'ms' : (span / 1000).toFixed(2) + 's')); - this._log(message.join(' '), this._stream, 'timer'); +const { fork_repo } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - return {label, span}; - } - } -} +const ForkEvent = (item) => { + return fork_repo + .replace(/{FORK}/g, toUrlFormat(item, "fork")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "fork")) + .replace(/{URL}/g, makeCustomUrl(item, "fork")); +}; -module.exports = Signale; +module.exports = ForkEvent; /***/ }), -/***/ 9881: +/***/ 5620: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +const { wiki_create } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); -const figures = __nccwpck_require__(7099); +const GollumEvent = (item) => { + let finalArray = []; + item.payload.pages.forEach((page) => { + if (page.action === "created") { + page.repo_name = item.repo.name; + finalArray.push( + wiki_create + .replace(/{WIKI}/g, toUrlFormat(page, "wiki")) + .replace(/{REPO}/g, toUrlFormat(page.repo_name, "wiki")) + .replace(/{URL}/g, makeCustomUrl(page, "wiki")) + ); + } + }); -module.exports = { - error: { - badge: figures.cross, - color: 'red', - label: 'error', - logLevel: 'error' - }, - fatal: { - badge: figures.cross, - color: 'red', - label: 'fatal', - logLevel: 'error' - }, - fav: { - badge: figures('❤'), - color: 'magenta', - label: 'favorite', - logLevel: 'info' - }, - info: { - badge: figures.info, - color: 'blue', - label: 'info', - logLevel: 'info' - }, - star: { - badge: figures.star, - color: 'yellow', - label: 'star', - logLevel: 'info' - }, - success: { - badge: figures.tick, - color: 'green', - label: 'success', - logLevel: 'info' - }, - wait: { - badge: figures.ellipsis, - color: 'blue', - label: 'waiting', - logLevel: 'info' - }, - warn: { - badge: figures.warning, - color: 'yellow', - label: 'warning', - logLevel: 'warn' - }, - complete: { - badge: figures.checkboxOn, - color: 'cyan', - label: 'complete', - logLevel: 'info' - }, - pending: { - badge: figures.checkboxOff, - color: 'magenta', - label: 'pending', - logLevel: 'info' - }, - note: { - badge: figures.bullet, - color: 'blue', - label: 'note', - logLevel: 'info' - }, - start: { - badge: figures.play, - color: 'green', - label: 'start', - logLevel: 'info' - }, - pause: { - badge: figures.squareSmallFilled, - color: 'yellow', - label: 'pause', - logLevel: 'info' - }, - debug: { - badge: figures('⬤'), - color: 'red', - label: 'debug', - logLevel: 'debug' - }, - await: { - badge: figures.ellipsis, - color: 'blue', - label: 'awaiting', - logLevel: 'info' - }, - watch: { - badge: figures.ellipsis, - color: 'yellow', - label: 'watching', - logLevel: 'info' - }, - log: { - badge: '', - color: '', - label: '', - logLevel: 'info' + if (finalArray.length == 0) { + return ""; + } else { + return finalArray; } }; +module.exports = GollumEvent; -/***/ }), - -/***/ 8551: -/***/ ((module) => { -"use strict"; +/***/ }), -module.exports = x => { - if (typeof x !== 'string') { - throw new TypeError('Expected a string, got ' + typeof x); - } +/***/ 6338: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string - // conversion translates it to FEFF (UTF-16 BOM) - if (x.charCodeAt(0) === 0xFEFF) { - return x.slice(1); - } +const { comments } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - return x; +const IssueCommentEvent = (item) => { + if (item.payload.action === "created") { + return comments + .replace(/{ID}/g, toUrlFormat(item, "issue_comment")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_comment")) + .replace(/{URL}/g, makeCustomUrl(item, "issue_comment")); + } else { + return ""; + } }; +module.exports = IssueCommentEvent; + /***/ }), -/***/ 5515: -/***/ ((module) => { +/***/ 9211: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +const { issue_opened, issue_closed } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); -module.exports = function (x) { - var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt(); - var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt(); +const IssuesEvent = (item) => { + if (item.payload.action === "opened") { + return issue_opened + .replace(/{ID}/g, toUrlFormat(item, "issue_open")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_open")) + .replace(/{URL}/g, makeCustomUrl(item, "issue_open")); + } else if (item.payload.action === "closed") { + return issue_closed + .replace(/{ID}/g, toUrlFormat(item, "issue_close")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "issue_close")) + .replace(/{URL}/g, makeCustomUrl(item, "issue_close")); + } else { + return ""; + } +}; - if (x[x.length - 1] === lf) { - x = x.slice(0, x.length - 1); - } +module.exports = IssuesEvent; - if (x[x.length - 1] === cr) { - x = x.slice(0, x.length - 1); - } - return x; +/***/ }), + +/***/ 5392: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const { added_member } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); + +const MemberEvent = (item) => { + if (item.payload.action === "added") { + return added_member + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "member")) + .replace(/{URL}/g, makeCustomUrl(item, "member")); + } else { + return ""; + } }; +module.exports = MemberEvent; + /***/ }), -/***/ 9318: +/***/ 2199: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +const { pr_opened, pr_merged, pr_closed } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); -const os = __nccwpck_require__(2087); -const hasFlag = __nccwpck_require__(1621); +const PullRequestEvent = (item) => { + if (item.payload.action === "opened") { + return pr_opened + .replace(/{ID}/g, toUrlFormat(item, "pr_open")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_open")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_open")); + } else if (item.payload.pull_request.merged) { + return pr_merged + .replace(/{ID}/g, toUrlFormat(item, "pr_merge")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_merge")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_merge")); + } else if ( + item.payload.action === "closed" && + !item.payload.pull_request.merged + ) { + return pr_closed + .replace(/{ID}/g, toUrlFormat(item, "pr_close")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_close")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_close")); + } else { + return ""; + } +}; -const env = process.env; +module.exports = PullRequestEvent; -let forceColor; -if (hasFlag('no-color') || - hasFlag('no-colors') || - hasFlag('color=false')) { - forceColor = false; -} else if (hasFlag('color') || - hasFlag('colors') || - hasFlag('color=true') || - hasFlag('color=always')) { - forceColor = true; -} -if ('FORCE_COLOR' in env) { - forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; -} -function translateLevel(level) { - if (level === 0) { - return false; - } +/***/ }), - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -} +/***/ 232: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -function supportsColor(stream) { - if (forceColor === false) { - return 0; - } +const { comments } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - if (hasFlag('color=16m') || - hasFlag('color=full') || - hasFlag('color=truecolor')) { - return 3; - } +const PullRequestReviewCommentEvent = (item) => { + if (item.payload.action === "created") { + return comments + .replace(/{ID}/g, toUrlFormat(item, "pr_review_comment")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review_comment")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_review_comment")); + } else { + return ""; + } +}; - if (hasFlag('color=256')) { - return 2; - } +module.exports = PullRequestReviewCommentEvent; - if (stream && !stream.isTTY && forceColor !== true) { - return 0; - } - const min = forceColor ? 1 : 0; +/***/ }), - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows - // release that supports 256 colors. Windows 10 build 14931 is the first release - // that supports 16m/TrueColor. - const osRelease = os.release().split('.'); - if ( - Number(process.versions.node.split('.')[0]) >= 8 && - Number(osRelease[0]) >= 10 && - Number(osRelease[2]) >= 10586 - ) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } +/***/ 8454: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return 1; - } +const { changes_approved, changes_requested } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { - return 1; - } +const PullRequestReviewEvent = (item) => { + if ( + item.payload.action === "created" && + item.payload.review.state == "approved" + ) { + return changes_approved + .replace(/{ID}/g, toUrlFormat(item, "pr_review")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_review")); + } else if ( + item.payload.action === "created" && + item.payload.review.state == "changes_requested" + ) { + return changes_requested + .replace(/{ID}/g, toUrlFormat(item, "pr_review")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "pr_review")) + .replace(/{URL}/g, makeCustomUrl(item, "pr_review")); + } else { + return ""; + } +}; - return min; - } +module.exports = PullRequestReviewEvent; - if ('TEAMCITY_VERSION' in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } - if (env.COLORTERM === 'truecolor') { - return 3; - } +/***/ }), - if ('TERM_PROGRAM' in env) { - const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); +/***/ 4633: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - switch (env.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Apple_Terminal': - return 2; - // No default - } - } +const { new_release } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } +const ReleaseEvent = (item) => { + if (item.payload.action === "published") { + return new_release + .replace(/{ID}/g, toUrlFormat(item, "release")) + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "release")) + .replace(/{URL}/g, makeCustomUrl(item, "release")); + } else { + return ""; + } +}; - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } +module.exports = ReleaseEvent; - if ('COLORTERM' in env) { - return 1; - } - if (env.TERM === 'dumb') { - return min; - } +/***/ }), + +/***/ 9875: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const { new_star } = __nccwpck_require__(4570); +const makeCustomUrl = __nccwpck_require__(434); +const toUrlFormat = __nccwpck_require__(5879); + +const WatchEvent = (item) => { + if (item.payload.action === "started") { + return new_star + .replace(/{REPO}/g, toUrlFormat(item.repo.name, "star")) + .replace(/{URL}/g, makeCustomUrl(item, "star")); + } else { + return ""; + } +}; + +module.exports = WatchEvent; - return min; -} -function getSupportLevel(stream) { - const level = supportsColor(stream); - return translateLevel(level); -} +/***/ }), -module.exports = { - supportsColor: getSupportLevel, - stdout: getSupportLevel(process.stdout), - stderr: getSupportLevel(process.stderr) -}; +/***/ 3927: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/** + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ -/***/ }), +const dateFormat = __nccwpck_require__(1512); -/***/ 5030: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +const { date } = __nccwpck_require__(4570); -"use strict"; +const appendDate = (fullContent) => { + let dateStartIdx = fullContent.findIndex( + (content) => content.trim() === "" + ); + if (dateStartIdx !== -1) { + let dateEndIdx = fullContent.findIndex( + (content, index) => + content.trim() === "" && + index > dateStartIdx + ); -Object.defineProperty(exports, "__esModule", ({ value: true })); + let offset; + let finalDate; -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + if (date.timezone.split("/").length === 2) { + process.env.TZ = date.timezone; + finalDate = new Date(); + } else { + let tz = date.timezone.replace("GMT", "").split(":"); + let tz_hours = parseInt(tz[0].trim()); -var osName = _interopDefault(__nccwpck_require__(4824)); + if (tz.length > 1) { + offset = tz_hours * 60 + parseInt(tz[1].trim()); + } else { + if (tz_hours > 99) { + offset = Math.floor(tz_hours / 100) * 60 + (tz_hours % 100); + } else { + offset = tz_hours * 60; + } + } -function getUserAgent() { - try { - return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`; - } catch (error) { - if (/wmic os get Caption/.test(error.message)) { - return "Windows "; + const utc = new Date().getTime() + new Date().getTimezoneOffset() * 60000; + finalDate = new Date(utc + offset * 60000); } - return ""; + finalDateString = date.text.replace( + "{DATE}", + dateFormat(finalDate, date.format) + ); + + if (dateEndIdx === -1) { + fullContent.splice( + dateStartIdx + 1, + 0, + finalDateString, + "" + ); + } else { + fullContent.splice( + dateStartIdx + 1, + dateEndIdx - dateStartIdx - 1, + finalDateString + ); + } } -} + return fullContent; +}; -exports.getUserAgent = getUserAgent; -//# sourceMappingURL=index.js.map +module.exports = appendDate; /***/ }), -/***/ 4207: +/***/ 6652: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = which -which.sync = whichSync +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ -var isWindows = process.platform === 'win32' || - process.env.OSTYPE === 'cygwin' || - process.env.OSTYPE === 'msys' +const { readme_file, commit_msg } = __nccwpck_require__(4570); -var path = __nccwpck_require__(5622) -var COLON = isWindows ? ';' : ':' -var isexe = __nccwpck_require__(7126) +const exec = __nccwpck_require__(9694); -function getNotFoundError (cmd) { - var er = new Error('not found: ' + cmd) - er.code = 'ENOENT' +/** + * Make a commit + * + * @returns {Promise} + */ - return er -} +const commitFile = async () => { + await exec("git", [ + "config", + "--global", + "user.email", + "41898282+github-actions[bot]@users.noreply.github.com", + ]); + await exec("git", ["config", "--global", "user.name", "readme-bot"]); + await exec("git", ["add", readme_file]); + await exec("git", ["commit", "-m", commit_msg]); + await exec("git", ["push"]); +}; -function getPathInfo (cmd, opt) { - var colon = opt.colon || COLON - var pathEnv = opt.path || process.env.PATH || '' - var pathExt = [''] +module.exports = commitFile; - pathEnv = pathEnv.split(colon) - var pathExtExe = '' - if (isWindows) { - pathEnv.unshift(process.cwd()) - pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') - pathExt = pathExtExe.split(colon) +/***/ }), +/***/ 9694: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - // Always test the cmd itself first. isexe will check to make sure - // it's found in the pathExt set. - if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') - pathExt.unshift('') - } +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ - // If it has a slash, then we don't bother searching the pathenv. - // just check the file itself, and that's it. - if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) - pathEnv = [''] +const { spawn } = __nccwpck_require__(3129); - return { - env: pathEnv, - ext: pathExt, - extExe: pathExtExe - } -} +/** + * Execute shell command + * @param {String} cmd - root command + * @param {String[]} args - args to be passed along with + * + * @returns {Promise} + */ -function which (cmd, opt, cb) { - if (typeof opt === 'function') { - cb = opt - opt = {} - } +const exec = (cmd, args = []) => + new Promise((resolve, reject) => { + const app = spawn(cmd, args, { stdio: "pipe" }); + let stdout = ""; + app.stdout.on("data", (data) => { + stdout = data; + }); + app.on("close", (code) => { + if (code !== 0 && !stdout.includes("nothing to commit")) { + err = new Error(`Invalid status code: ${code}`); + err.code = code; + return reject(err); + } + return resolve(code); + }); + app.on("error", reject); + }); - var info = getPathInfo(cmd, opt) - var pathEnv = info.env - var pathExt = info.ext - var pathExtExe = info.extExe - var found = [] +module.exports = exec; - ;(function F (i, l) { - if (i === l) { - if (opt.all && found.length) - return cb(null, found) - else - return cb(getNotFoundError(cmd)) - } - var pathPart = pathEnv[i] - if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') - pathPart = pathPart.slice(1, -1) +/***/ }), - var p = path.join(pathPart, cmd) - if (!pathPart && (/^\.[\\\/]/).test(cmd)) { - p = cmd.slice(0, 2) + p - } - ;(function E (ii, ll) { - if (ii === ll) return F(i + 1, l) - var ext = pathExt[ii] - isexe(p + ext, { pathExt: pathExtExe }, function (er, is) { - if (!er && is) { - if (opt.all) - found.push(p + ext) - else - return cb(null, p + ext) - } - return E(ii + 1, ll) - }) - })(0, pathExt.length) - })(0, pathEnv.length) -} +/***/ 6292: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -function whichSync (cmd, opt) { - opt = opt || {} +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ - var info = getPathInfo(cmd, opt) - var pathEnv = info.env - var pathExt = info.ext - var pathExtExe = info.extExe - var found = [] +const serializers = __nccwpck_require__(3169); +const { max_lines } = __nccwpck_require__(4570); - for (var i = 0, l = pathEnv.length; i < l; i ++) { - var pathPart = pathEnv[i] - if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') - pathPart = pathPart.slice(1, -1) +const filterContent = (eventData) => { + let temp_content = []; - var p = path.join(pathPart, cmd) - if (!pathPart && /^\.[\\\/]/.test(cmd)) { - p = cmd.slice(0, 2) + p - } - for (var j = 0, ll = pathExt.length; j < ll; j ++) { - var cur = p + pathExt[j] - var is - try { - is = isexe.sync(cur, { pathExt: pathExtExe }) - if (is) { - if (opt.all) - found.push(cur) - else - return cur - } - } catch (ex) {} + for (i = 0; i < eventData.length; i++) { + let event_string = serializers[eventData[i].type](eventData[i]); + + if (event_string !== "") { + temp_content.push(event_string); + } + if (temp_content.length == max_lines) { + break; } } - if (opt.all && found.length) - return found + temp_content = temp_content.flat(); + temp_content.length = max_lines; - if (opt.nothrow) - return null + console.log(temp_content); - throw getNotFoundError(cmd) -} + return temp_content; +}; + +module.exports = filterContent; /***/ }), -/***/ 3515: +/***/ 434: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ -const os = __nccwpck_require__(2087); -const execa = __nccwpck_require__(5447); +const { url_text, urlPrefix } = __nccwpck_require__(4570); -// Reference: https://www.gaijin.at/en/lstwinver.php -const names = new Map([ - ['10.0', '10'], - ['6.3', '8.1'], - ['6.2', '8'], - ['6.1', '7'], - ['6.0', 'Vista'], - ['5.2', 'Server 2003'], - ['5.1', 'XP'], - ['5.0', '2000'], - ['4.9', 'ME'], - ['4.1', '98'], - ['4.0', '95'] -]); +const makeCustomUrl = (item, type) => { + let url; + switch (type.toLowerCase()) { + case "issue_open": + case "issue_close": + url = + `[` + + url_text + .replace(/{ID}/g, `#${item.payload.issue.number}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.issue.html_url})`; + break; + case "issue_comment": + url = + `[` + + url_text + .replace(/{ID}/g, `#${item.payload.issue.number}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.comment.html_url})`; + break; + case "commit_comment": + url = + `[` + + url_text + .replace(/{ID}/g, `#commit`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.comment.html_url})`; + break; + case "pr_review_comment": + url = + `[` + + url_text + .replace(/{ID}/g, `#${item.payload.pull_request.number}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.comment.html_url})`; + break; + case "pr_open": + case "pr_close": + case "pr_merge": + url = + `[` + + url_text + .replace(/{ID}/g, `#${item.payload.pull_request.number}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.pull_request.html_url})`; + break; + case "pr_review": + url = + `[` + + url_text + .replace(/{ID}/g, `#${item.payload.pull_request.number}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.review.html_url})`; + break; + case "create_repo": + case "member": + case "star": + url = + `[` + + url_text.replace(/{REPO}/g, item.repo.name) + + `](${urlPrefix}/${item.repo.name})`; + break; + case "fork": + url = + `[` + + url_text + .replace(/{ID}/g, `${item.payload.forkee.full_name}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.forkee.html_url})`; + break; + case "wiki": + url = + `[` + + url_text + .replace(/{ID}/g, `${item.page_name}`) + .replace(/{REPO}/g, item.repo_name) + + `](${item.html_url})`; + break; + case "release": + url = + `[` + + url_text + .replace(/{ID}/g, `${item.payload.release.name}`) + .replace(/{REPO}/g, item.repo.name) + + `](${item.payload.release.html_url})`; + break; + default: + tools.exit.failure("Failed while creating the url string."); + break; + } + return url; +}; -const windowsRelease = release => { - const version = /\d+\.\d/.exec(release || os.release()); +module.exports = makeCustomUrl; - if (release && !version) { - throw new Error('`release` argument doesn\'t match `n.n`'); - } - const ver = (version || [])[0]; +/***/ }), - // Server 2008, 2012, 2016, and 2019 versions are ambiguous with desktop versions and must be detected at runtime. - // If `release` is omitted or we're on a Windows system, and the version number is an ambiguous version - // then use `wmic` to get the OS caption: https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx - // If `wmic` is obsoloete (later versions of Windows 10), use PowerShell instead. - // If the resulting caption contains the year 2008, 2012, 2016 or 2019, it is a server version, so return a server OS name. - if ((!release || release === os.release()) && ['6.1', '6.2', '6.3', '10.0'].includes(ver)) { - let stdout; - try { - stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; - } catch (_) { - stdout = execa.sync('powershell', ['(Get-CimInstance -ClassName Win32_OperatingSystem).caption']).stdout || ''; - } +/***/ 928: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - const year = (stdout.match(/2008|2012|2016|2019/) || [])[0]; +/** + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ - if (year) { - return `Server ${year}`; - } - } +const yaml = __nccwpck_require__(1917); +const fs = __nccwpck_require__(5747); - return names.get(ver); +//const { config_file } = require("../config"); + +const parseYaml = (file) => { + try { + return yaml.load(fs.readFileSync(file, "utf8")); + } catch (error) { + console.error(error); + return {}; + } }; -module.exports = windowsRelease; +module.exports = parseYaml; /***/ }), -/***/ 2940: -/***/ ((module) => { - -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -module.exports = wrappy -function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') +/***/ 5879: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k] - }) +/** + * Copyright (c) 2020 James George + * Copyright (c) 2021 The Readme-Workflows organisation and Contributors + */ - return wrapper +const { urlPrefix } = __nccwpck_require__(4570); - function wrapper() { - var args = new Array(arguments.length) - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - var ret = fn.apply(this, args) - var cb = args[args.length-1] - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k] - }) +const toUrlFormat = (item, type) => { + let url; + if (typeof item === "object") { + switch (type.toLowerCase()) { + case "issue_open": + case "issue_close": + url = `[#${item.payload.issue.number}](${item.payload.issue.html_url})`; + break; + case "issue_comment": + url = `[#${item.payload.issue.number}](${item.payload.comment.html_url})`; + break; + case "commit_comment": + url = `[commit](${item.payload.comment.html_url})`; + break; + case "pr_review_comment": + url = `[#${item.payload.pull_request.number}](${item.payload.comment.html_url})`; + break; + case "pr_open": + case "pr_close": + case "pr_merge": + url = `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`; + break; + case "pr_review": + url = `[#${item.payload.pull_request.number}](${item.payload.review.html_url})`; + break; + case "fork": + url = `[${item.payload.forkee.full_name}](${item.payload.forkee.html_url})`; + break; + case "wiki": + url = `[${item.page_name}](${item.html_url})`; + break; + case "release": + url = `[${item.payload.release.name}](${item.payload.release.html_url})`; + break; + default: + tools.exit.failure("Failed while creating the url format."); + break; } - return ret + return url; } -} + return `[${item}](${urlPrefix}/${item})`; +}; + +module.exports = toUrlFormat; /***/ }), -/***/ 102: +/***/ 3169: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /** @@ -20185,21 +20185,21 @@ function wrappy (fn, cb) { * Copyright (c) 2021 The Readme-Workflows organisation and Contributors */ -const { disabled_events } = __nccwpck_require__(5532); +const { disabled_events } = __nccwpck_require__(4570); // Events -const IssueCommentEvent = __nccwpck_require__(454); -const CommitCommentEvent = __nccwpck_require__(6986); -const PullRequestReviewCommentEvent = __nccwpck_require__(1552); -const IssuesEvent = __nccwpck_require__(1183); -const PullRequestEvent = __nccwpck_require__(8089); -const CreateEvent = __nccwpck_require__(7744); -const ForkEvent = __nccwpck_require__(9634); -const GollumEvent = __nccwpck_require__(7021); -const MemberEvent = __nccwpck_require__(466); -const PullRequestReviewEvent = __nccwpck_require__(2185); -const ReleaseEvent = __nccwpck_require__(2348); -const WatchEvent = __nccwpck_require__(7137); +const IssueCommentEvent = __nccwpck_require__(6338); +const CommitCommentEvent = __nccwpck_require__(4694); +const PullRequestReviewCommentEvent = __nccwpck_require__(232); +const IssuesEvent = __nccwpck_require__(9211); +const PullRequestEvent = __nccwpck_require__(2199); +const CreateEvent = __nccwpck_require__(4865); +const ForkEvent = __nccwpck_require__(8075); +const GollumEvent = __nccwpck_require__(5620); +const MemberEvent = __nccwpck_require__(5392); +const PullRequestReviewEvent = __nccwpck_require__(8454); +const ReleaseEvent = __nccwpck_require__(4633); +const WatchEvent = __nccwpck_require__(9875); const serializers = {}; @@ -20438,15 +20438,15 @@ const fs = __nccwpck_require__(5747); const { Toolkit } = __nccwpck_require__(7045); // configuration -const { username, readme_file, max_lines } = __nccwpck_require__(5532); +const { username, readme_file, max_lines } = __nccwpck_require__(4570); // functions -const appendDate = __nccwpck_require__(2310); -const commitFile = __nccwpck_require__(3803); -const filterContent = __nccwpck_require__(9347); +const appendDate = __nccwpck_require__(3927); +const commitFile = __nccwpck_require__(6652); +const filterContent = __nccwpck_require__(6292); // accepted events -const serializers = __nccwpck_require__(102); +const serializers = __nccwpck_require__(3169); Toolkit.run( async (tools) => { diff --git a/package-lock.json b/package-lock.json index 130c5ebc03..ef3b53c7df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -123,9 +123,6 @@ "integrity": "sha512-46lptzM9lTeSmIBt/sVP/FLSTPGx6DCzAdSX3PfeJ3mTf4h9sGC26WpaQzMEq/Z44cOcmx8VsOhO+uEgE3cjYg==", "dependencies": { "@octokit/types": "^6.11.0" - }, - "peerDependencies": { - "@octokit/core": ">=2" } }, "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": { @@ -139,10 +136,7 @@ "node_modules/@octokit/plugin-request-log": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz", - "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==", - "peerDependencies": { - "@octokit/core": ">=3" - } + "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==" }, "node_modules/@octokit/plugin-rest-endpoint-methods": { "version": "3.17.0", @@ -530,9 +524,6 @@ "integrity": "sha512-H/QHeBIN1fIGJX517pvK8IEK53yQOW7YcEI55oYtgjDdoCQQz7eJS94qt5kNrscReEyuD/JcdFCm2XBEcGOITg==", "engines": { "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/minimist": { @@ -791,9 +782,6 @@ }, "engines": { "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/wrappy": { @@ -928,8 +916,7 @@ "@octokit/plugin-request-log": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz", - "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==", - "requires": {} + "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==" }, "@octokit/plugin-rest-endpoint-methods": { "version": "3.17.0", diff --git a/package.json b/package.json index 9ea5243f52..cfd2d9a786 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "activity-readme", "version": "1.4.0", "description": "Updates README with the recent GitHub activity of a user. This project is a fork of https://github.com/jamesgeorge007/github-activity-readme", - "main": "index.js", + "main": "src/index.js", "keywords": [ "github-profile", "activity" @@ -10,9 +10,9 @@ "author": "James George, The Readme-Workflows organisation", "license": "MIT", "scripts": { - "format:check": "prettier --check **/*.js", - "format": "prettier --write **/*.js", - "build": "ncc build index.js --license LICENSE" + "format:check": "prettier --check src/**/*.js", + "format": "prettier --write src/**/*.js", + "build": "ncc build src/index.js --license LICENSE" }, "dependencies": { "@actions/core": "^1.3.0", diff --git a/config.js b/src/config.js similarity index 98% rename from config.js rename to src/config.js index c425bcbd29..273bd6992a 100644 --- a/config.js +++ b/src/config.js @@ -12,7 +12,7 @@ const defaultVals = { commit_msg: "⚡ Update README with the recent activity", max_lines: 5, readme_file: "./README.md", - disabled_events: [], + disabled_events: ["comments"], url_text: "{REPO}{ID}", date: { timezone: "0", diff --git a/events/CommitCommentEvent.js b/src/events/CommitCommentEvent.js similarity index 100% rename from events/CommitCommentEvent.js rename to src/events/CommitCommentEvent.js diff --git a/events/CreateEvent.js b/src/events/CreateEvent.js similarity index 100% rename from events/CreateEvent.js rename to src/events/CreateEvent.js diff --git a/events/ForkEvent.js b/src/events/ForkEvent.js similarity index 100% rename from events/ForkEvent.js rename to src/events/ForkEvent.js diff --git a/events/GollumEvent.js b/src/events/GollumEvent.js similarity index 100% rename from events/GollumEvent.js rename to src/events/GollumEvent.js diff --git a/events/IssueCommentEvent.js b/src/events/IssueCommentEvent.js similarity index 100% rename from events/IssueCommentEvent.js rename to src/events/IssueCommentEvent.js diff --git a/events/IssuesEvent.js b/src/events/IssuesEvent.js similarity index 100% rename from events/IssuesEvent.js rename to src/events/IssuesEvent.js diff --git a/events/MemberEvent.js b/src/events/MemberEvent.js similarity index 100% rename from events/MemberEvent.js rename to src/events/MemberEvent.js diff --git a/events/PullRequestEvent.js b/src/events/PullRequestEvent.js similarity index 100% rename from events/PullRequestEvent.js rename to src/events/PullRequestEvent.js diff --git a/events/PullRequestReviewCommentEvent.js b/src/events/PullRequestReviewCommentEvent.js similarity index 100% rename from events/PullRequestReviewCommentEvent.js rename to src/events/PullRequestReviewCommentEvent.js diff --git a/events/PullRequestReviewEvent.js b/src/events/PullRequestReviewEvent.js similarity index 100% rename from events/PullRequestReviewEvent.js rename to src/events/PullRequestReviewEvent.js diff --git a/events/ReleaseEvent.js b/src/events/ReleaseEvent.js similarity index 100% rename from events/ReleaseEvent.js rename to src/events/ReleaseEvent.js diff --git a/events/WatchEvent.js b/src/events/WatchEvent.js similarity index 100% rename from events/WatchEvent.js rename to src/events/WatchEvent.js diff --git a/functions/appendDate.js b/src/functions/appendDate.js similarity index 100% rename from functions/appendDate.js rename to src/functions/appendDate.js diff --git a/functions/commitFile.js b/src/functions/commitFile.js similarity index 100% rename from functions/commitFile.js rename to src/functions/commitFile.js diff --git a/functions/execute.js b/src/functions/execute.js similarity index 100% rename from functions/execute.js rename to src/functions/execute.js diff --git a/functions/filterContent.js b/src/functions/filterContent.js similarity index 100% rename from functions/filterContent.js rename to src/functions/filterContent.js diff --git a/functions/makeCustomUrl.js b/src/functions/makeCustomUrl.js similarity index 100% rename from functions/makeCustomUrl.js rename to src/functions/makeCustomUrl.js diff --git a/functions/parseYaml.js b/src/functions/parseYaml.js similarity index 100% rename from functions/parseYaml.js rename to src/functions/parseYaml.js diff --git a/functions/toUrlFormat.js b/src/functions/toUrlFormat.js similarity index 100% rename from functions/toUrlFormat.js rename to src/functions/toUrlFormat.js diff --git a/index.js b/src/index.js similarity index 100% rename from index.js rename to src/index.js diff --git a/serializers.js b/src/serializers.js similarity index 100% rename from serializers.js rename to src/serializers.js