From 3b7f5051491ca59f60ccedb27e52fc15a51cc8b4 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Wed, 2 Aug 2023 06:13:14 +0200 Subject: [PATCH 1/4] General refactoring --- src/api/get-changed-files.ts | 24 +++ src/api/get-changed-pull-requests.ts | 38 ++++ src/api/get-content.ts | 16 ++ src/api/get-label-globs.ts | 70 +++++++ src/api/index.ts | 6 + src/api/set-labels.ts | 15 ++ src/api/types.ts | 2 + src/get-inputs/get-inputs.ts | 10 + src/get-inputs/get-pr-numbers.ts | 28 +++ src/get-inputs/index.ts | 1 + src/labeler.ts | 277 ++++++--------------------- src/utils/index.ts | 2 + src/utils/is-list-equal.ts | 3 + src/utils/print-pattern.ts | 5 + 14 files changed, 282 insertions(+), 215 deletions(-) create mode 100644 src/api/get-changed-files.ts create mode 100644 src/api/get-changed-pull-requests.ts create mode 100644 src/api/get-content.ts create mode 100644 src/api/get-label-globs.ts create mode 100644 src/api/index.ts create mode 100644 src/api/set-labels.ts create mode 100644 src/api/types.ts create mode 100644 src/get-inputs/get-inputs.ts create mode 100644 src/get-inputs/get-pr-numbers.ts create mode 100644 src/get-inputs/index.ts create mode 100644 src/utils/index.ts create mode 100644 src/utils/is-list-equal.ts create mode 100644 src/utils/print-pattern.ts diff --git a/src/api/get-changed-files.ts b/src/api/get-changed-files.ts new file mode 100644 index 000000000..6454f4db0 --- /dev/null +++ b/src/api/get-changed-files.ts @@ -0,0 +1,24 @@ +import * as core from '@actions/core'; +import * as github from '@actions/github'; +import {ClientType} from './types'; + +export const getChangedFiles = async ( + client: ClientType, + prNumber: number +): Promise => { + const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + pull_number: prNumber + }); + + const listFilesResponse = await client.paginate(listFilesOptions); + const changedFiles = listFilesResponse.map((f: any) => f.filename); + + core.debug('found changed files:'); + for (const file of changedFiles) { + core.debug(' ' + file); + } + + return changedFiles; +}; diff --git a/src/api/get-changed-pull-requests.ts b/src/api/get-changed-pull-requests.ts new file mode 100644 index 000000000..0dd3eec14 --- /dev/null +++ b/src/api/get-changed-pull-requests.ts @@ -0,0 +1,38 @@ +import * as core from '@actions/core'; +import * as github from '@actions/github'; +import {getChangedFiles} from './get-changed-files'; +import {ClientType} from './types'; + +export async function* getChangedPullRequests( + client: ClientType, + prNumbers: number[] +) { + for (const prNumber of prNumbers) { + core.debug(`looking for pr #${prNumber}`); + let prData: any; + try { + const result = await client.rest.pulls.get({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + pull_number: prNumber + }); + prData = result.data; + } catch (error: any) { + core.warning(`Could not find pull request #${prNumber}, skipping`); + continue; + } + + core.debug(`fetching changed files for pr #${prNumber}`); + const changedFiles: string[] = await getChangedFiles(client, prNumber); + if (!changedFiles.length) { + core.warning(`Pull request #${prNumber} has no changed files, skipping`); + continue; + } + + yield { + data: prData, + number: prNumber, + changedFiles + }; + } +} diff --git a/src/api/get-content.ts b/src/api/get-content.ts new file mode 100644 index 000000000..6743a90a2 --- /dev/null +++ b/src/api/get-content.ts @@ -0,0 +1,16 @@ +import * as github from '@actions/github'; +import {ClientType} from './types'; + +export const getContent = async ( + client: ClientType, + repoPath: string +): Promise => { + const response: any = await client.rest.repos.getContent({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + path: repoPath, + ref: github.context.sha + }); + + return Buffer.from(response.data.content, response.data.encoding).toString(); +}; diff --git a/src/api/get-label-globs.ts b/src/api/get-label-globs.ts new file mode 100644 index 000000000..aafc46a73 --- /dev/null +++ b/src/api/get-label-globs.ts @@ -0,0 +1,70 @@ +import * as core from '@actions/core'; +import * as yaml from 'js-yaml'; +import fs from 'fs'; +import {ClientType} from './types'; +import {getContent} from './get-content'; + +export interface MatchConfig { + all?: string[]; + any?: string[]; +} + +export type StringOrMatchConfig = string | MatchConfig; + +export const getLabelGlobs = ( + client: ClientType, + configurationPath: string +): Promise> => + Promise.resolve() + .then(() => { + if (!fs.existsSync(configurationPath)) { + core.info( + `The configuration file (path: ${configurationPath}) isn't not found locally, fetching via the api` + ); + + return getContent(client, configurationPath); + } + + core.info( + `The configuration file (path: ${configurationPath}) is found locally, reading from the file` + ); + + return fs.readFileSync(configurationPath, { + encoding: 'utf8' + }); + }) + .catch(error => { + if (error.name == 'HttpError' || error.name == 'NotFound') { + core.warning( + `The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.` + ); + } + return Promise.reject(error); + }) + .then(configuration => { + // loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`: + const configObject: any = yaml.load(configuration); + + // transform `any` => `Map` or throw if yaml is malformed: + return getLabelGlobMapFromObject(configObject); + }); + +function getLabelGlobMapFromObject( + configObject: any +): Map { + const labelGlobs: Map = new Map(); + + for (const label in configObject) { + if (typeof configObject[label] === 'string') { + labelGlobs.set(label, [configObject[label]]); + } else if (configObject[label] instanceof Array) { + labelGlobs.set(label, configObject[label]); + } else { + throw Error( + `found unexpected type for label ${label} (should be string or array of globs)` + ); + } + } + + return labelGlobs; +} diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 000000000..ebfda9ffa --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,6 @@ +export * from './get-changed-files'; +export * from './get-changed-pull-requests'; +export * from './get-content'; +export * from './get-label-globs'; +export * from './set-labels'; +export * from './types'; diff --git a/src/api/set-labels.ts b/src/api/set-labels.ts new file mode 100644 index 000000000..6d598535d --- /dev/null +++ b/src/api/set-labels.ts @@ -0,0 +1,15 @@ +import * as github from '@actions/github'; +import {ClientType} from './types'; + +export const setLabels = async ( + client: ClientType, + prNumber: number, + labels: string[] +) => { + await client.rest.issues.setLabels({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + issue_number: prNumber, + labels: labels + }); +}; diff --git a/src/api/types.ts b/src/api/types.ts new file mode 100644 index 000000000..03af2dfe9 --- /dev/null +++ b/src/api/types.ts @@ -0,0 +1,2 @@ +import * as github from '@actions/github'; +export type ClientType = ReturnType; diff --git a/src/get-inputs/get-inputs.ts b/src/get-inputs/get-inputs.ts new file mode 100644 index 000000000..482124981 --- /dev/null +++ b/src/get-inputs/get-inputs.ts @@ -0,0 +1,10 @@ +import * as core from '@actions/core'; +import {getPrNumbers} from './get-pr-numbers'; + +export const getInputs = () => ({ + token: core.getInput('repo-token'), + configPath: core.getInput('configuration-path', {required: true}), + syncLabels: !!core.getInput('sync-labels'), + dot: core.getBooleanInput('dot'), + prNumbers: getPrNumbers() +}); diff --git a/src/get-inputs/get-pr-numbers.ts b/src/get-inputs/get-pr-numbers.ts new file mode 100644 index 000000000..35324ce5b --- /dev/null +++ b/src/get-inputs/get-pr-numbers.ts @@ -0,0 +1,28 @@ +import * as core from '@actions/core'; +import * as github from '@actions/github'; + +const getPrNumberFromContext = () => + github.context.payload.pull_request?.number; + +export const getPrNumbers = (): number[] => { + const prInput = core.getMultilineInput('pr-number'); + + if (!prInput?.length) { + return [getPrNumberFromContext()].filter(Boolean) as number[]; + } + + const result: number[] = []; + + for (const line of prInput) { + const prNumber = parseInt(line, 10); + + if (isNaN(prNumber) && prNumber <= 0) { + core.warning(`'${prNumber}' is not a valid pull request number`); + continue; + } + + result.push(prNumber); + } + + return result; +}; diff --git a/src/get-inputs/index.ts b/src/get-inputs/index.ts new file mode 100644 index 000000000..d1705bf14 --- /dev/null +++ b/src/get-inputs/index.ts @@ -0,0 +1 @@ +export * from './get-inputs'; diff --git a/src/labeler.ts b/src/labeler.ts index 995abaa35..4988ccf7f 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -1,9 +1,10 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; import * as pluginRetry from '@octokit/plugin-retry'; -import * as yaml from 'js-yaml'; -import fs from 'fs'; import {Minimatch} from 'minimatch'; +import * as api from './api'; +import {isListEqual, printPattern} from './utils'; +import {getInputs} from './get-inputs'; interface MatchConfig { all?: string[]; @@ -16,217 +17,84 @@ type ClientType = ReturnType; // GitHub Issues cannot have more than 100 labels const GITHUB_MAX_LABELS = 100; -export async function run() { - try { - const token = core.getInput('repo-token'); - const configPath = core.getInput('configuration-path', {required: true}); - const syncLabels = !!core.getInput('sync-labels'); - const dot = core.getBooleanInput('dot'); - - const prNumbers = getPrNumbers(); - if (!prNumbers.length) { - core.warning('Could not get pull request number(s), exiting'); - return; - } - - const client: ClientType = github.getOctokit(token, {}, pluginRetry.retry); - - for (const prNumber of prNumbers) { - core.debug(`looking for pr #${prNumber}`); - let pullRequest: any; - try { - const result = await client.rest.pulls.get({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - pull_number: prNumber - }); - pullRequest = result.data; - } catch (error: any) { - core.warning(`Could not find pull request #${prNumber}, skipping`); - continue; - } - - core.debug(`fetching changed files for pr #${prNumber}`); - const changedFiles: string[] = await getChangedFiles(client, prNumber); - if (!changedFiles.length) { - core.warning( - `Pull request #${prNumber} has no changed files, skipping` - ); - continue; - } - - const labelGlobs: Map = - await getLabelGlobs(client, configPath); - - const preexistingLabels = pullRequest.labels.map(l => l.name); - const allLabels: Set = new Set(preexistingLabels); - - for (const [label, globs] of labelGlobs.entries()) { - core.debug(`processing ${label}`); - if (checkGlobs(changedFiles, globs, dot)) { - allLabels.add(label); - } else if (syncLabels) { - allLabels.delete(label); - } - } - - const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS); - const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS); - - try { - let newLabels: string[] = []; - - if (!isListEqual(labelsToAdd, preexistingLabels)) { - await setLabels(client, prNumber, labelsToAdd); - newLabels = labelsToAdd.filter(l => !preexistingLabels.includes(l)); - } - - core.setOutput('new-labels', newLabels.join(',')); - core.setOutput('all-labels', labelsToAdd.join(',')); - - if (excessLabels.length) { - core.warning( - `Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join( - ', ' - )}`, - {title: 'Label limit for a PR exceeded'} - ); - } - } catch (error: any) { - if ( - error.name === 'HttpError' && - error.message === 'Resource not accessible by integration' - ) { - core.warning( - `The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions`, - { - title: `${process.env['GITHUB_ACTION_REPOSITORY']} running under '${github.context.eventName}' is misconfigured` - } - ); - core.setFailed(error.message); - } else { - throw error; - } - } - } - } catch (error: any) { +export const run = () => + labeler().catch(error => { core.error(error); core.setFailed(error.message); - } -} - -function getPrNumbers(): number[] { - const pullRequestNumbers = core.getMultilineInput('pr-number'); - if (pullRequestNumbers && pullRequestNumbers.length) { - const prNumbers: number[] = []; - - for (const prNumber of pullRequestNumbers) { - const prNumberInt = parseInt(prNumber, 10); - if (isNaN(prNumberInt) || prNumberInt <= 0) { - core.warning(`'${prNumber}' is not a valid pull request number`); - } else { - prNumbers.push(prNumberInt); - } - } + }); - return prNumbers; - } +async function labeler() { + const {token, configPath, syncLabels, dot, prNumbers} = getInputs(); - const pullRequest = github.context.payload.pull_request; - if (!pullRequest) { - return []; + if (!prNumbers.length) { + core.warning('Could not get pull request number(s), exiting'); + return; } - return [pullRequest.number]; -} - -async function getChangedFiles( - client: ClientType, - prNumber: number -): Promise { - const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - pull_number: prNumber - }); + const client: ClientType = github.getOctokit(token, {}, pluginRetry.retry); + + for await (const pullRequest of api.getChangedPullRequests( + client, + prNumbers + )) { + const labelGlobs: Map = + await api.getLabelGlobs(client, configPath); + const preexistingLabels = pullRequest.data.labels.map(l => l.name); + const allLabels: Set = new Set(preexistingLabels); + + for (const [label, globs] of labelGlobs.entries()) { + core.debug(`processing ${label}`); + if (checkGlobs(pullRequest.changedFiles, globs, dot)) { + allLabels.add(label); + } else if (syncLabels) { + allLabels.delete(label); + } + } - const listFilesResponse = await client.paginate(listFilesOptions); - const changedFiles = listFilesResponse.map((f: any) => f.filename); + const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS); + const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS); - core.debug('found changed files:'); - for (const file of changedFiles) { - core.debug(' ' + file); - } + let newLabels: string[] = []; - return changedFiles; -} + try { + if (!isListEqual(labelsToAdd, preexistingLabels)) { + await api.setLabels(client, pullRequest.number, labelsToAdd); + newLabels = labelsToAdd.filter( + label => !preexistingLabels.includes(label) + ); + } + } catch (error: any) { + if ( + error.name !== 'HttpError' || + error.message !== 'Resource not accessible by integration' + ) { + throw error; + } -async function getLabelGlobs( - client: ClientType, - configurationPath: string -): Promise> { - let configurationContent: string; - try { - if (!fs.existsSync(configurationPath)) { - core.info( - `The configuration file (path: ${configurationPath}) isn't not found locally, fetching via the api` - ); - configurationContent = await fetchContent(client, configurationPath); - } else { - core.info( - `The configuration file (path: ${configurationPath}) is found locally, reading from the file` - ); - configurationContent = fs.readFileSync(configurationPath, { - encoding: 'utf8' - }); - } - } catch (e: any) { - if (e.name == 'HttpError' || e.name == 'NotFound') { core.warning( - `The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.` + `The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions`, + { + title: `${process.env['GITHUB_ACTION_REPOSITORY']} running under '${github.context.eventName}' is misconfigured` + } ); - } - throw e; - } - // loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`: - const configObject: any = yaml.load(configurationContent); + core.setFailed(error.message); - // transform `any` => `Map` or throw if yaml is malformed: - return getLabelGlobMapFromObject(configObject); -} - -async function fetchContent( - client: ClientType, - repoPath: string -): Promise { - const response: any = await client.rest.repos.getContent({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - path: repoPath, - ref: github.context.sha - }); + return; + } - return Buffer.from(response.data.content, response.data.encoding).toString(); -} + core.setOutput('new-labels', newLabels.join(',')); + core.setOutput('all-labels', labelsToAdd.join(',')); -function getLabelGlobMapFromObject( - configObject: any -): Map { - const labelGlobs: Map = new Map(); - for (const label in configObject) { - if (typeof configObject[label] === 'string') { - labelGlobs.set(label, [configObject[label]]); - } else if (configObject[label] instanceof Array) { - labelGlobs.set(label, configObject[label]); - } else { - throw Error( - `found unexpected type for label ${label} (should be string or array of globs)` + if (excessLabels.length) { + core.warning( + `Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join( + ', ' + )}`, + {title: 'Label limit for a PR exceeded'} ); } } - - return labelGlobs; } function toMatchConfig(config: StringOrMatchConfig): MatchConfig { @@ -239,10 +107,6 @@ function toMatchConfig(config: StringOrMatchConfig): MatchConfig { return config; } -function printPattern(matcher: Minimatch): string { - return (matcher.negate ? '!' : '') + matcher.pattern; -} - export function checkGlobs( changedFiles: string[], globs: StringOrMatchConfig[], @@ -329,20 +193,3 @@ function checkMatch( return true; } - -function isListEqual(listA: string[], listB: string[]): boolean { - return listA.length === listB.length && listA.every(el => listB.includes(el)); -} - -async function setLabels( - client: ClientType, - prNumber: number, - labels: string[] -) { - await client.rest.issues.setLabels({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - issue_number: prNumber, - labels: labels - }); -} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 000000000..23b6eb7bc --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from './is-list-equal'; +export * from './print-pattern'; diff --git a/src/utils/is-list-equal.ts b/src/utils/is-list-equal.ts new file mode 100644 index 000000000..a5584d077 --- /dev/null +++ b/src/utils/is-list-equal.ts @@ -0,0 +1,3 @@ +export const isListEqual = (listA: string[], listB: string[]): boolean => { + return listA.length === listB.length && listA.every(el => listB.includes(el)); +}; diff --git a/src/utils/print-pattern.ts b/src/utils/print-pattern.ts new file mode 100644 index 000000000..ab4975302 --- /dev/null +++ b/src/utils/print-pattern.ts @@ -0,0 +1,5 @@ +import {Minimatch} from 'minimatch'; + +export const printPattern = (matcher: Minimatch): string => { + return (matcher.negate ? '!' : '') + matcher.pattern; +}; From c40a0983dcf80c9b54c315ec4a81e99e9eff207b Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Wed, 2 Aug 2023 06:53:28 +0200 Subject: [PATCH 2/4] Update bild --- dist/index.js | 781 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 609 insertions(+), 172 deletions(-) diff --git a/dist/index.js b/dist/index.js index c96d37a93..ca66e0661 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,7 +1,148 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 5272: +/***/ 8622: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getChangedFiles = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const github = __importStar(__nccwpck_require__(5438)); +const getChangedFiles = (client, prNumber) => __awaiter(void 0, void 0, void 0, function* () { + const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + pull_number: prNumber + }); + const listFilesResponse = yield client.paginate(listFilesOptions); + const changedFiles = listFilesResponse.map((f) => f.filename); + core.debug('found changed files:'); + for (const file of changedFiles) { + core.debug(' ' + file); + } + return changedFiles; +}); +exports.getChangedFiles = getChangedFiles; + + +/***/ }), + +/***/ 2084: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getChangedPullRequests = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const github = __importStar(__nccwpck_require__(5438)); +const get_changed_files_1 = __nccwpck_require__(8622); +function getChangedPullRequests(client, prNumbers) { + return __asyncGenerator(this, arguments, function* getChangedPullRequests_1() { + for (const prNumber of prNumbers) { + core.debug(`looking for pr #${prNumber}`); + let prData; + try { + const result = yield __await(client.rest.pulls.get({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + pull_number: prNumber + })); + prData = result.data; + } + catch (error) { + core.warning(`Could not find pull request #${prNumber}, skipping`); + continue; + } + core.debug(`fetching changed files for pr #${prNumber}`); + const changedFiles = yield __await((0, get_changed_files_1.getChangedFiles)(client, prNumber)); + if (!changedFiles.length) { + core.warning(`Pull request #${prNumber} has no changed files, skipping`); + continue; + } + yield yield __await({ + data: prData, + number: prNumber, + changedFiles + }); + } + }); +} +exports.getChangedPullRequests = getChangedPullRequests; + + +/***/ }), + +/***/ 4059: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -38,190 +179,446 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getContent = void 0; +const github = __importStar(__nccwpck_require__(5438)); +const getContent = (client, repoPath) => __awaiter(void 0, void 0, void 0, function* () { + const response = yield client.rest.repos.getContent({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + path: repoPath, + ref: github.context.sha + }); + return Buffer.from(response.data.content, response.data.encoding).toString(); +}); +exports.getContent = getContent; + + +/***/ }), + +/***/ 8976: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getLabelGlobs = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const yaml = __importStar(__nccwpck_require__(1917)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const get_content_1 = __nccwpck_require__(4059); +const getLabelGlobs = (client, configurationPath) => Promise.resolve() + .then(() => { + if (!fs_1.default.existsSync(configurationPath)) { + core.info(`The configuration file (path: ${configurationPath}) was not found locally, fetching via the api`); + return (0, get_content_1.getContent)(client, configurationPath); + } + core.info(`The configuration file (path: ${configurationPath}) was found locally, reading from the file`); + return fs_1.default.readFileSync(configurationPath, { + encoding: 'utf8' + }); +}) + .catch(error => { + if (error.name == 'HttpError' || error.name == 'NotFound') { + core.warning(`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`); + } + return Promise.reject(error); +}) + .then(configuration => { + // loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`: + const configObject = yaml.load(configuration); + // transform `any` => `Map` or throw if yaml is malformed: + return getLabelGlobMapFromObject(configObject); +}); +exports.getLabelGlobs = getLabelGlobs; +function getLabelGlobMapFromObject(configObject) { + const labelGlobs = new Map(); + for (const label in configObject) { + if (typeof configObject[label] === 'string') { + labelGlobs.set(label, [configObject[label]]); + } + else if (configObject[label] instanceof Array) { + labelGlobs.set(label, configObject[label]); + } + else { + throw Error(`found unexpected type for label ${label} (should be string or array of globs)`); + } + } + return labelGlobs; +} + + +/***/ }), + +/***/ 5614: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__nccwpck_require__(8622), exports); +__exportStar(__nccwpck_require__(2084), exports); +__exportStar(__nccwpck_require__(4059), exports); +__exportStar(__nccwpck_require__(8976), exports); +__exportStar(__nccwpck_require__(5389), exports); +__exportStar(__nccwpck_require__(3068), exports); + + +/***/ }), + +/***/ 5389: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.setLabels = void 0; +const github = __importStar(__nccwpck_require__(5438)); +const setLabels = (client, prNumber, labels) => __awaiter(void 0, void 0, void 0, function* () { + yield client.rest.issues.setLabels({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + issue_number: prNumber, + labels: labels + }); +}); +exports.setLabels = setLabels; + + +/***/ }), + +/***/ 3068: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); + + +/***/ }), + +/***/ 5607: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getInputs = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const get_pr_numbers_1 = __nccwpck_require__(1389); +const getInputs = () => ({ + token: core.getInput('repo-token'), + configPath: core.getInput('configuration-path', { required: true }), + syncLabels: !!core.getInput('sync-labels'), + dot: core.getBooleanInput('dot'), + prNumbers: (0, get_pr_numbers_1.getPrNumbers)() +}); +exports.getInputs = getInputs; + + +/***/ }), + +/***/ 1389: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getPrNumbers = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const github = __importStar(__nccwpck_require__(5438)); +const getPrNumberFromContext = () => { var _a; return (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number; }; +const getPrNumbers = () => { + const prInput = core.getMultilineInput('pr-number'); + if (!(prInput === null || prInput === void 0 ? void 0 : prInput.length)) { + return [getPrNumberFromContext()].filter(Boolean); + } + const result = []; + for (const line of prInput) { + const prNumber = parseInt(line, 10); + if (isNaN(prNumber) && prNumber <= 0) { + core.warning(`'${prNumber}' is not a valid pull request number`); + continue; + } + result.push(prNumber); + } + return result; +}; +exports.getPrNumbers = getPrNumbers; + + +/***/ }), + +/***/ 4288: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__nccwpck_require__(5607), exports); + + +/***/ }), + +/***/ 5272: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); exports.checkGlobs = exports.run = void 0; const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); const pluginRetry = __importStar(__nccwpck_require__(6298)); -const yaml = __importStar(__nccwpck_require__(1917)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); const minimatch_1 = __nccwpck_require__(1953); +const api = __importStar(__nccwpck_require__(5614)); +const utils_1 = __nccwpck_require__(1606); +const get_inputs_1 = __nccwpck_require__(4288); // GitHub Issues cannot have more than 100 labels const GITHUB_MAX_LABELS = 100; -function run() { +const run = () => labeler().catch(error => { + core.error(error); + core.setFailed(error.message); +}); +exports.run = run; +function labeler() { + var _a, e_1, _b, _c; return __awaiter(this, void 0, void 0, function* () { + const { token, configPath, syncLabels, dot, prNumbers } = (0, get_inputs_1.getInputs)(); + if (!prNumbers.length) { + core.warning('Could not get pull request number(s), exiting'); + return; + } + const client = github.getOctokit(token, {}, pluginRetry.retry); try { - const token = core.getInput('repo-token'); - const configPath = core.getInput('configuration-path', { required: true }); - const syncLabels = !!core.getInput('sync-labels'); - const dot = core.getBooleanInput('dot'); - const prNumbers = getPrNumbers(); - if (!prNumbers.length) { - core.warning('Could not get pull request number(s), exiting'); - return; - } - const client = github.getOctokit(token, {}, pluginRetry.retry); - for (const prNumber of prNumbers) { - core.debug(`looking for pr #${prNumber}`); - let pullRequest; + for (var _d = true, _e = __asyncValues(api.getChangedPullRequests(client, prNumbers)), _f; _f = yield _e.next(), _a = _f.done, !_a;) { + _c = _f.value; + _d = false; try { - const result = yield client.rest.pulls.get({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - pull_number: prNumber - }); - pullRequest = result.data; - } - catch (error) { - core.warning(`Could not find pull request #${prNumber}, skipping`); - continue; - } - core.debug(`fetching changed files for pr #${prNumber}`); - const changedFiles = yield getChangedFiles(client, prNumber); - if (!changedFiles.length) { - core.warning(`Pull request #${prNumber} has no changed files, skipping`); - continue; - } - const labelGlobs = yield getLabelGlobs(client, configPath); - const preexistingLabels = pullRequest.labels.map(l => l.name); - const allLabels = new Set(preexistingLabels); - for (const [label, globs] of labelGlobs.entries()) { - core.debug(`processing ${label}`); - if (checkGlobs(changedFiles, globs, dot)) { - allLabels.add(label); - } - else if (syncLabels) { - allLabels.delete(label); + const pullRequest = _c; + const labelGlobs = yield api.getLabelGlobs(client, configPath); + const preexistingLabels = pullRequest.data.labels.map(l => l.name); + const allLabels = new Set(preexistingLabels); + for (const [label, globs] of labelGlobs.entries()) { + core.debug(`processing ${label}`); + if (checkGlobs(pullRequest.changedFiles, globs, dot)) { + allLabels.add(label); + } + else if (syncLabels) { + allLabels.delete(label); + } } - } - const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS); - const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS); - try { + const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS); + const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS); let newLabels = []; - if (!isListEqual(labelsToAdd, preexistingLabels)) { - yield setLabels(client, prNumber, labelsToAdd); - newLabels = labelsToAdd.filter(l => !preexistingLabels.includes(l)); - } - core.setOutput('new-labels', newLabels.join(',')); - core.setOutput('all-labels', labelsToAdd.join(',')); - if (excessLabels.length) { - core.warning(`Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join(', ')}`, { title: 'Label limit for a PR exceeded' }); + try { + if (!(0, utils_1.isListEqual)(labelsToAdd, preexistingLabels)) { + yield api.setLabels(client, pullRequest.number, labelsToAdd); + newLabels = labelsToAdd.filter(label => !preexistingLabels.includes(label)); + } } - } - catch (error) { - if (error.name === 'HttpError' && - error.message === 'Resource not accessible by integration') { + catch (error) { + if (error.name !== 'HttpError' || + error.message !== 'Resource not accessible by integration') { + throw error; + } core.warning(`The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions`, { title: `${process.env['GITHUB_ACTION_REPOSITORY']} running under '${github.context.eventName}' is misconfigured` }); core.setFailed(error.message); + return; } - else { - throw error; + core.setOutput('new-labels', newLabels.join(',')); + core.setOutput('all-labels', labelsToAdd.join(',')); + if (excessLabels.length) { + core.warning(`Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join(', ')}`, { title: 'Label limit for a PR exceeded' }); } } + finally { + _d = true; + } } } - catch (error) { - core.error(error); - core.setFailed(error.message); - } - }); -} -exports.run = run; -function getPrNumbers() { - const pullRequestNumbers = core.getMultilineInput('pr-number'); - if (pullRequestNumbers && pullRequestNumbers.length) { - const prNumbers = []; - for (const prNumber of pullRequestNumbers) { - const prNumberInt = parseInt(prNumber, 10); - if (isNaN(prNumberInt) || prNumberInt <= 0) { - core.warning(`'${prNumber}' is not a valid pull request number`); - } - else { - prNumbers.push(prNumberInt); - } - } - return prNumbers; - } - const pullRequest = github.context.payload.pull_request; - if (!pullRequest) { - return []; - } - return [pullRequest.number]; -} -function getChangedFiles(client, prNumber) { - return __awaiter(this, void 0, void 0, function* () { - const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - pull_number: prNumber - }); - const listFilesResponse = yield client.paginate(listFilesOptions); - const changedFiles = listFilesResponse.map((f) => f.filename); - core.debug('found changed files:'); - for (const file of changedFiles) { - core.debug(' ' + file); - } - return changedFiles; - }); -} -function getLabelGlobs(client, configurationPath) { - return __awaiter(this, void 0, void 0, function* () { - let configurationContent; - try { - if (!fs_1.default.existsSync(configurationPath)) { - core.info(`The configuration file (path: ${configurationPath}) was not found locally, fetching via the api`); - configurationContent = yield fetchContent(client, configurationPath); - } - else { - core.info(`The configuration file (path: ${configurationPath}) was found locally, reading from the file`); - configurationContent = fs_1.default.readFileSync(configurationPath, { - encoding: 'utf8' - }); - } - } - catch (e) { - if (e.name == 'HttpError' || e.name == 'NotFound') { - core.warning(`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`); + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } - throw e; + finally { if (e_1) throw e_1.error; } } - // loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`: - const configObject = yaml.load(configurationContent); - // transform `any` => `Map` or throw if yaml is malformed: - return getLabelGlobMapFromObject(configObject); }); } -function fetchContent(client, repoPath) { - return __awaiter(this, void 0, void 0, function* () { - const response = yield client.rest.repos.getContent({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - path: repoPath, - ref: github.context.sha - }); - return Buffer.from(response.data.content, response.data.encoding).toString(); - }); -} -function getLabelGlobMapFromObject(configObject) { - const labelGlobs = new Map(); - for (const label in configObject) { - if (typeof configObject[label] === 'string') { - labelGlobs.set(label, [configObject[label]]); - } - else if (configObject[label] instanceof Array) { - labelGlobs.set(label, configObject[label]); - } - else { - throw Error(`found unexpected type for label ${label} (should be string or array of globs)`); - } - } - return labelGlobs; -} function toMatchConfig(config) { if (typeof config === 'string') { return { @@ -230,9 +627,6 @@ function toMatchConfig(config) { } return config; } -function printPattern(matcher) { - return (matcher.negate ? '!' : '') + matcher.pattern; -} function checkGlobs(changedFiles, globs, dot) { for (const glob of globs) { core.debug(` checking pattern ${JSON.stringify(glob)}`); @@ -247,9 +641,9 @@ exports.checkGlobs = checkGlobs; function isMatch(changedFile, matchers) { core.debug(` matching patterns against file ${changedFile}`); for (const matcher of matchers) { - core.debug(` - ${printPattern(matcher)}`); + core.debug(` - ${(0, utils_1.printPattern)(matcher)}`); if (!matcher.match(changedFile)) { - core.debug(` ${printPattern(matcher)} did not match`); + core.debug(` ${(0, utils_1.printPattern)(matcher)} did not match`); return false; } } @@ -295,19 +689,62 @@ function checkMatch(changedFiles, matchConfig, dot) { } return true; } -function isListEqual(listA, listB) { + + +/***/ }), + +/***/ 1606: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__nccwpck_require__(8725), exports); +__exportStar(__nccwpck_require__(2897), exports); + + +/***/ }), + +/***/ 8725: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isListEqual = void 0; +const isListEqual = (listA, listB) => { return listA.length === listB.length && listA.every(el => listB.includes(el)); -} -function setLabels(client, prNumber, labels) { - return __awaiter(this, void 0, void 0, function* () { - yield client.rest.issues.setLabels({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - issue_number: prNumber, - labels: labels - }); - }); -} +}; +exports.isListEqual = isListEqual; + + +/***/ }), + +/***/ 2897: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.printPattern = void 0; +const printPattern = (matcher) => { + return (matcher.negate ? '!' : '') + matcher.pattern; +}; +exports.printPattern = printPattern; /***/ }), From 27ee87f076c307587cc9553e9932b4411dbd52b6 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Mon, 25 Sep 2023 15:28:47 +0200 Subject: [PATCH 3/4] Update naming --- dist/index.js | 15 ++++++++------- src/api/get-changed-pull-requests.ts | 2 +- src/labeler.ts | 7 +++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index ca66e0661..f501b0378 100644 --- a/dist/index.js +++ b/dist/index.js @@ -102,12 +102,12 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getChangedPullRequests = void 0; +exports.getPullRequests = void 0; const core = __importStar(__nccwpck_require__(2186)); const github = __importStar(__nccwpck_require__(5438)); const get_changed_files_1 = __nccwpck_require__(8622); -function getChangedPullRequests(client, prNumbers) { - return __asyncGenerator(this, arguments, function* getChangedPullRequests_1() { +function getPullRequests(client, prNumbers) { + return __asyncGenerator(this, arguments, function* getPullRequests_1() { for (const prNumber of prNumbers) { core.debug(`looking for pr #${prNumber}`); let prData; @@ -137,7 +137,7 @@ function getChangedPullRequests(client, prNumbers) { } }); } -exports.getChangedPullRequests = getChangedPullRequests; +exports.getPullRequests = getPullRequests; /***/ }), @@ -561,9 +561,10 @@ function labeler() { return; } const client = github.getOctokit(token, {}, pluginRetry.retry); + const pullRequests = api.getPullRequests(client, prNumbers); try { - for (var _d = true, _e = __asyncValues(api.getChangedPullRequests(client, prNumbers)), _f; _f = yield _e.next(), _a = _f.done, !_a;) { - _c = _f.value; + for (var _d = true, pullRequests_1 = __asyncValues(pullRequests), pullRequests_1_1; pullRequests_1_1 = yield pullRequests_1.next(), _a = pullRequests_1_1.done, !_a;) { + _c = pullRequests_1_1.value; _d = false; try { const pullRequest = _c; @@ -613,7 +614,7 @@ function labeler() { catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); + if (!_d && !_a && (_b = pullRequests_1.return)) yield _b.call(pullRequests_1); } finally { if (e_1) throw e_1.error; } } diff --git a/src/api/get-changed-pull-requests.ts b/src/api/get-changed-pull-requests.ts index 0dd3eec14..f83838917 100644 --- a/src/api/get-changed-pull-requests.ts +++ b/src/api/get-changed-pull-requests.ts @@ -3,7 +3,7 @@ import * as github from '@actions/github'; import {getChangedFiles} from './get-changed-files'; import {ClientType} from './types'; -export async function* getChangedPullRequests( +export async function* getPullRequests( client: ClientType, prNumbers: number[] ) { diff --git a/src/labeler.ts b/src/labeler.ts index 4988ccf7f..46f87142f 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -33,10 +33,9 @@ async function labeler() { const client: ClientType = github.getOctokit(token, {}, pluginRetry.retry); - for await (const pullRequest of api.getChangedPullRequests( - client, - prNumbers - )) { + const pullRequests = api.getPullRequests(client, prNumbers); + + for await (const pullRequest of pullRequests) { const labelGlobs: Map = await api.getLabelGlobs(client, configPath); const preexistingLabels = pullRequest.data.labels.map(l => l.name); From df65a7144a8c69220e765e508d6e7c9df9dabff1 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Wed, 4 Oct 2023 11:23:34 +0200 Subject: [PATCH 4/4] Use lodash's isEqual --- .licenses/npm/lodash.isequal.dep.yml | 58 + dist/index.js | 2276 +++++++++++++++++++++++--- package-lock.json | 42 + package.json | 2 + src/labeler.ts | 5 +- src/utils/index.ts | 1 - src/utils/is-list-equal.ts | 3 - 7 files changed, 2171 insertions(+), 216 deletions(-) create mode 100644 .licenses/npm/lodash.isequal.dep.yml delete mode 100644 src/utils/is-list-equal.ts diff --git a/.licenses/npm/lodash.isequal.dep.yml b/.licenses/npm/lodash.isequal.dep.yml new file mode 100644 index 000000000..4bc8358e0 --- /dev/null +++ b/.licenses/npm/lodash.isequal.dep.yml @@ -0,0 +1,58 @@ +--- +name: lodash.isequal +version: 4.5.0 +type: npm +summary: The Lodash method `_.isEqual` exported as a module. +homepage: https://lodash.com/ +license: mit +licenses: +- sources: LICENSE + text: | + Copyright JS Foundation and other contributors + + Based on Underscore.js, copyright Jeremy Ashkenas, + DocumentCloud and Investigative Reporters & Editors + + This software consists of voluntary contributions made by many + individuals. For exact contribution history, see the revision history + available at https://github.com/lodash/lodash + + The following license applies to all parts of this software except as + documented below: + + ==== + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + ==== + + Copyright and related rights for sample code are waived via CC0. Sample + code is defined as all source code displayed within the prose of the + documentation. + + CC0: http://creativecommons.org/publicdomain/zero/1.0/ + + ==== + + Files located in the node_modules and vendor directories are externally + maintained libraries used by this software which have their own + licenses; we recommend you read them, as their terms may differ from the + terms above. +notices: [] diff --git a/dist/index.js b/dist/index.js index f501b0378..84bee126f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -536,6 +536,9 @@ var __asyncValues = (this && this.__asyncValues) || function (o) { function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.checkGlobs = exports.run = void 0; const core = __importStar(__nccwpck_require__(2186)); @@ -543,6 +546,7 @@ const github = __importStar(__nccwpck_require__(5438)); const pluginRetry = __importStar(__nccwpck_require__(6298)); const minimatch_1 = __nccwpck_require__(1953); const api = __importStar(__nccwpck_require__(5614)); +const lodash_isequal_1 = __importDefault(__nccwpck_require__(8309)); const utils_1 = __nccwpck_require__(1606); const get_inputs_1 = __nccwpck_require__(4288); // GitHub Issues cannot have more than 100 labels @@ -584,7 +588,7 @@ function labeler() { const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS); let newLabels = []; try { - if (!(0, utils_1.isListEqual)(labelsToAdd, preexistingLabels)) { + if (!(0, lodash_isequal_1.default)(labelsToAdd, preexistingLabels)) { yield api.setLabels(client, pullRequest.number, labelsToAdd); newLabels = labelsToAdd.filter(label => !preexistingLabels.includes(label)); } @@ -714,25 +718,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -__exportStar(__nccwpck_require__(8725), exports); __exportStar(__nccwpck_require__(2897), exports); -/***/ }), - -/***/ 8725: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isListEqual = void 0; -const isListEqual = (listA, listB) => { - return listA.length === listB.length && listA.every(el => listB.includes(el)); -}; -exports.isListEqual = isListEqual; - - /***/ }), /***/ 2897: @@ -11486,245 +11474,2101 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', { /***/ }), -/***/ 467: +/***/ 8309: /***/ ((module, exports, __nccwpck_require__) => { -"use strict"; +/* module decorator */ module = __nccwpck_require__.nmd(module); +/** + * Lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright JS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; -Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; -var Stream = _interopDefault(__nccwpck_require__(2781)); -var http = _interopDefault(__nccwpck_require__(3685)); -var Url = _interopDefault(__nccwpck_require__(7310)); -var whatwgUrl = _interopDefault(__nccwpck_require__(3323)); -var https = _interopDefault(__nccwpck_require__(5687)); -var zlib = _interopDefault(__nccwpck_require__(9796)); +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; -// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; -// fix for "Readable" isn't a named export issue -const Readable = Stream.Readable; +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; -const BUFFER = Symbol('buffer'); -const TYPE = Symbol('type'); +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; -class Blob { - constructor() { - this[TYPE] = ''; +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); - const blobParts = arguments[0]; - const options = arguments[1]; +/** Detect free variable `exports`. */ +var freeExports = true && exports && !exports.nodeType && exports; - const buffers = []; - let size = 0; +/** Detect free variable `module`. */ +var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; - 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); - } - } +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; - this[BUFFER] = Buffer.concat(buffers); +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; - 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; +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); - 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); +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; - } +/** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; } -Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } -}); +/** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; -Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: 'Blob', - writable: false, - enumerable: false, - configurable: true -}); + while (++index < length) { + array[offset + index] = values[index]; + } + return array; +} /** - * fetch-error.js + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. * - * FetchError interface for operational errors + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} /** - * Create FetchError instance + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. * - * @param String message Error message for human - * @param String type Error type for machine - * @param String systemError For Node.js system error - * @return FetchError + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. */ -function FetchError(message, type, systemError) { - Error.call(this, message); +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); - 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; + while (++index < n) { + result[index] = iteratee(index); } + return result; +} - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; } -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; +/** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} -let convert; -try { - convert = (__nccwpck_require__(2877).convert); -} catch (e) {} +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} -const INTERNALS = Symbol('Body internals'); +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream.PassThrough; + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} /** - * Body mixin + * Creates a unary function that invokes `func` with its argument transformed. * - * Ref: https://fetch.spec.whatwg.org/#body + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** + * Converts `set` to an array of its values. * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. */ -function Body(body) { - var _this = this; +function setToArray(set) { + var index = -1, + result = Array(set.size); - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; +/** Used for built-in method references. */ +var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; - 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; +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; - 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; - }); - } -} +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - get bodyUsed() { - return this[INTERNALS].disturbed; - }, +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); - /** - * Decode response as ArrayBuffer - * - * @return Promise +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined, + Symbol = root.Symbol, + Uint8Array = root.Uint8Array, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeKeys = overArg(Object.keys, Object); + +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'), + Map = getNative(root, 'Map'), + Promise = getNative(root, 'Promise'), + Set = getNative(root, 'Set'), + WeakMap = getNative(root, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; +} + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); +} + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; +} + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; + +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } +} + +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} + +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} + +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; +} + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; + this.size = 0; +} + +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; +} + +/** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; +} + +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; +} + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} + +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; +} + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; +} + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ +function isEqual(value, other) { + return baseIsEqual(value, other); +} + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +/** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ +function stubArray() { + return []; +} + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +module.exports = isEqual; + + +/***/ }), + +/***/ 467: +/***/ ((module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var Stream = _interopDefault(__nccwpck_require__(2781)); +var http = _interopDefault(__nccwpck_require__(3685)); +var Url = _interopDefault(__nccwpck_require__(7310)); +var whatwgUrl = _interopDefault(__nccwpck_require__(3323)); +var https = _interopDefault(__nccwpck_require__(5687)); +var zlib = _interopDefault(__nccwpck_require__(9796)); + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + 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); + } + } + + 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; + +/** + * 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; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + 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; + + 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; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise */ arrayBuffer() { return consumeBody.call(this).then(function (buf) { @@ -18398,8 +20242,8 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed +/******/ id: moduleId, +/******/ loaded: false, /******/ exports: {} /******/ }; /******/ @@ -18412,11 +20256,23 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ if(threw) delete __webpack_module_cache__[moduleId]; /******/ } /******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/node module decorator */ +/******/ (() => { +/******/ __nccwpck_require__.nmd = (module) => { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; diff --git a/package-lock.json b/package-lock.json index 394c49700..e2685daec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,11 +13,13 @@ "@actions/github": "^5.1.1", "@octokit/plugin-retry": "^5.0.5", "js-yaml": "^4.1.0", + "lodash.isequal": "^4.5.0", "minimatch": "^9.0.3" }, "devDependencies": { "@types/jest": "^27.4.1", "@types/js-yaml": "^4.0.5", + "@types/lodash.isequal": "^4.5.6", "@types/minimatch": "^5.1.2", "@types/node": "^16.11.7", "@typescript-eslint/eslint-plugin": "^6.1.0", @@ -1429,6 +1431,21 @@ "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.199", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.199.tgz", + "integrity": "sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==", + "dev": true + }, + "node_modules/@types/lodash.isequal": { + "version": "4.5.6", + "resolved": "https://registry.npmjs.org/@types/lodash.isequal/-/lodash.isequal-4.5.6.tgz", + "integrity": "sha512-Ww4UGSe3DmtvLLJm2F16hDwEQSv7U0Rr8SujLUA2wHI2D2dm8kPu6Et+/y303LfjTIwSBKXB/YTUcAKpem/XEg==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -4830,6 +4847,11 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -7410,6 +7432,21 @@ "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, + "@types/lodash": { + "version": "4.14.199", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.199.tgz", + "integrity": "sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==", + "dev": true + }, + "@types/lodash.isequal": { + "version": "4.5.6", + "resolved": "https://registry.npmjs.org/@types/lodash.isequal/-/lodash.isequal-4.5.6.tgz", + "integrity": "sha512-Ww4UGSe3DmtvLLJm2F16hDwEQSv7U0Rr8SujLUA2wHI2D2dm8kPu6Et+/y303LfjTIwSBKXB/YTUcAKpem/XEg==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -9890,6 +9927,11 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", diff --git a/package.json b/package.json index df2ac575e..f928b48ce 100644 --- a/package.json +++ b/package.json @@ -28,11 +28,13 @@ "@actions/github": "^5.1.1", "@octokit/plugin-retry": "^5.0.5", "js-yaml": "^4.1.0", + "lodash.isequal": "^4.5.0", "minimatch": "^9.0.3" }, "devDependencies": { "@types/jest": "^27.4.1", "@types/js-yaml": "^4.0.5", + "@types/lodash.isequal": "^4.5.6", "@types/minimatch": "^5.1.2", "@types/node": "^16.11.7", "@typescript-eslint/eslint-plugin": "^6.1.0", diff --git a/src/labeler.ts b/src/labeler.ts index 46f87142f..8b88d1970 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -3,7 +3,8 @@ import * as github from '@actions/github'; import * as pluginRetry from '@octokit/plugin-retry'; import {Minimatch} from 'minimatch'; import * as api from './api'; -import {isListEqual, printPattern} from './utils'; +import isEqual from 'lodash.isequal'; +import {printPattern} from './utils'; import {getInputs} from './get-inputs'; interface MatchConfig { @@ -56,7 +57,7 @@ async function labeler() { let newLabels: string[] = []; try { - if (!isListEqual(labelsToAdd, preexistingLabels)) { + if (!isEqual(labelsToAdd, preexistingLabels)) { await api.setLabels(client, pullRequest.number, labelsToAdd); newLabels = labelsToAdd.filter( label => !preexistingLabels.includes(label) diff --git a/src/utils/index.ts b/src/utils/index.ts index 23b6eb7bc..e60b76ad9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,2 +1 @@ -export * from './is-list-equal'; export * from './print-pattern'; diff --git a/src/utils/is-list-equal.ts b/src/utils/is-list-equal.ts deleted file mode 100644 index a5584d077..000000000 --- a/src/utils/is-list-equal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const isListEqual = (listA: string[], listB: string[]): boolean => { - return listA.length === listB.length && listA.every(el => listB.includes(el)); -};