diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b5707a..9df165f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,6 +122,15 @@ jobs: - if: steps.fc7.outputs.comment-id != 771260630 run: exit 1 + - name: Find comment by body-regex + uses: ./ + id: fc8 + with: + issue-number: 1 + body-regex: '^.*search string 1.*$' + - if: steps.fc8.outputs.comment-id != 620947762 + run: exit 1 + package: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: [test] diff --git a/README.md b/README.md index 9f21ef8..9a89572 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,17 @@ The action will output the comment ID of the comment matching the search criteri body-includes: search string 1 ``` +### Find the first comment matching the specified regular expression + +```yml + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: 1 + body-regex: '^.*search string 1.*$' +``` + ### Find the last comment containing the specified string ```yml @@ -63,6 +74,7 @@ The action will output the comment ID of the comment matching the search criteri | `issue-number` | The number of the issue or pull request in which to search. | | | `comment-author` | The GitHub user name of the comment author. | | | `body-includes` | A string to search for in the body of comments. | | +| `body-regex` | A regular expression to search for in the body of comments. | | | `direction` | Search direction, specified as `first` or `last` | `first` | #### Outputs diff --git a/__test__/find.unit.test.ts b/__test__/find.unit.test.ts new file mode 100644 index 0000000..803ce94 --- /dev/null +++ b/__test__/find.unit.test.ts @@ -0,0 +1,262 @@ +import {findCommentPredicate} from '../lib/find' + +describe('find comment tests', () => { + test('find by bodyIncludes', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: '', + bodyIncludes: 'Kansas', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: '', + bodyIncludes: 'not-exist', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + }) + + test('find by bodyRegex', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: '', + bodyIncludes: '', + bodyRegex: '^.*Kansas.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: '', + bodyIncludes: '', + bodyRegex: '^.*not-exist.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + }) + + test('find by author', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: '', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'toto', + bodyIncludes: '', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + }) + + test('find by bodyIncludes and author', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: 'Kansas', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: 'not-exist', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'toto', + bodyIncludes: 'Kansas', + bodyRegex: '', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + }) + + test('find by bodyRegex and author', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: '', + bodyRegex: '^.*Kansas.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: '', + bodyRegex: '^.*not-exist.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'toto', + bodyIncludes: '', + bodyRegex: '^.*Kansas.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(false) + }) + + test('find by bodyIncludes, bodyRegex and author', async () => { + expect( + findCommentPredicate( + { + token: 'token', + repository: 'repository', + issueNumber: 1, + commentAuthor: 'dorothy', + bodyIncludes: 'feeling', + bodyRegex: '^.*Kansas.*$', + direction: 'direction' + }, + { + id: 1, + body: `Toto, I've a feeling we're not in Kansas anymore.`, + user: {login: 'dorothy'} + } + ) + ).toEqual(true) + }) +}) diff --git a/action.yml b/action.yml index 8990640..5b0811b 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,8 @@ inputs: description: 'The GitHub user name of the comment author.' body-includes: description: 'A string to search for in the body of comments.' + body-regex: + description: 'A regular expression to search for in the body of comments.' direction: description: 'Search direction, specified as `first` or `last`' default: first @@ -27,5 +29,5 @@ runs: using: 'node16' main: 'dist/index.js' branding: - icon: 'search' + icon: 'search' color: 'gray-dark' diff --git a/dist/index.js b/dist/index.js index 11b0695..3b9bbcf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,7 +1,7 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 3109: +/***/ 548: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -42,17 +42,20 @@ var __asyncValues = (this && this.__asyncValues) || function (o) { function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; Object.defineProperty(exports, "__esModule", ({ value: true })); -const core = __importStar(__nccwpck_require__(2186)); +exports.findComment = exports.findCommentPredicate = void 0; const github = __importStar(__nccwpck_require__(5438)); -const util_1 = __nccwpck_require__(3837); function findCommentPredicate(inputs, comment) { return ((inputs.commentAuthor && comment.user ? comment.user.login === inputs.commentAuthor : true) && (inputs.bodyIncludes && comment.body ? comment.body.includes(inputs.bodyIncludes) + : true) && + (inputs.bodyRegex && comment.body + ? comment.body.match(inputs.bodyRegex) !== null : true)); } +exports.findCommentPredicate = findCommentPredicate; function findComment(inputs) { var e_1, _a; return __awaiter(this, void 0, void 0, function* () { @@ -92,6 +95,48 @@ function findComment(inputs) { return undefined; }); } +exports.findComment = findComment; + + +/***/ }), + +/***/ 3109: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.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 })); +const core = __importStar(__nccwpck_require__(2186)); +const find_1 = __nccwpck_require__(548); +const util_1 = __nccwpck_require__(3837); function getErrorMessage(error) { if (error instanceof Error) return error.message; @@ -106,10 +151,11 @@ function run() { issueNumber: Number(core.getInput('issue-number')), commentAuthor: core.getInput('comment-author'), bodyIncludes: core.getInput('body-includes'), + bodyRegex: core.getInput('body-regex'), direction: core.getInput('direction') }; core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`); - const comment = yield findComment(inputs); + const comment = yield (0, find_1.findComment)(inputs); if (comment) { core.setOutput('comment-id', comment.id.toString()); core.setOutput('comment-body', comment.body); diff --git a/package-lock.json b/package-lock.json index 65e2ad1..b833ab0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "devDependencies": { "@types/jest": "^27.0.3", "@types/node": "^16.11.11", + "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.5.0", "@vercel/ncc": "^0.32.0", "eslint": "^8.3.0", @@ -1361,6 +1362,12 @@ "integrity": "sha512-ekoj4qOQYp7CvjX8ZDBgN86w3MqQhLE1hczEJbEIjgFEumDy+na/4AJAbLXfgEWFNB2pKadM5rPFtuSGMWK7xA==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.3.13", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", + "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "dev": true + }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -1383,18 +1390,19 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.5.0.tgz", - "integrity": "sha512-4bV6fulqbuaO9UMXU0Ia0o6z6if+kmMRW8rMRyfqXj/eGrZZRGedS4n0adeGNnjr8LKAM495hrQ7Tea52UWmQA==", + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.42.1.tgz", + "integrity": "sha512-LyR6x784JCiJ1j6sH5Y0K6cdExqCCm8DJUTcwG5ThNXJj/G8o5E56u5EdG4SLy+bZAwZBswC+GYn3eGdttBVCg==", "dev": true, "dependencies": { - "@typescript-eslint/experimental-utils": "5.5.0", - "@typescript-eslint/scope-manager": "5.5.0", - "debug": "^4.3.2", - "functional-red-black-tree": "^1.0.1", - "ignore": "^5.1.8", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/type-utils": "5.42.1", + "@typescript-eslint/utils": "5.42.1", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", "regexpp": "^3.2.0", - "semver": "^7.3.5", + "semver": "^7.3.7", "tsutils": "^3.21.0" }, "engines": { @@ -1414,6 +1422,53 @@ } } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.42.1.tgz", + "integrity": "sha512-QAZY/CBP1Emx4rzxurgqj3rUinfsh/6mvuKbLNMfJMMKYLRBfweus8brgXF8f64ABkIZ3zdj2/rYYtF8eiuksQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/experimental-utils": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.5.0.tgz", @@ -1504,6 +1559,90 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.42.1.tgz", + "integrity": "sha512-WWiMChneex5w4xPIX56SSnQQo0tEOy5ZV2dqmj8Z371LJ0E+aymWD25JQ/l4FOuuX+Q49A7pzh/CGIQflxMVXg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/utils": "5.42.1", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.42.1.tgz", + "integrity": "sha512-qElc0bDOuO0B8wDhhW4mYVgi/LZL+igPwXtV87n69/kYC/7NG3MES0jHxJNCr4EP7kY1XVsRy8C/u3DYeTKQmw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/types": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.5.0.tgz", @@ -1544,6 +1683,128 @@ } } }, + "node_modules/@typescript-eslint/utils": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.42.1.tgz", + "integrity": "sha512-Gxvf12xSp3iYZd/fLqiQRD4uKZjDNR01bQ+j8zvhPjpsZ4HmvEFL/tC4amGNyxN9Rq+iqvpHLhlqx6KTxz9ZyQ==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/typescript-estree": "5.42.1", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0", + "semver": "^7.3.7" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.42.1.tgz", + "integrity": "sha512-QAZY/CBP1Emx4rzxurgqj3rUinfsh/6mvuKbLNMfJMMKYLRBfweus8brgXF8f64ABkIZ3zdj2/rYYtF8eiuksQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.42.1.tgz", + "integrity": "sha512-qElc0bDOuO0B8wDhhW4mYVgi/LZL+igPwXtV87n69/kYC/7NG3MES0jHxJNCr4EP7kY1XVsRy8C/u3DYeTKQmw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/@typescript-eslint/visitor-keys": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.5.0.tgz", @@ -2198,9 +2459,9 @@ } }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -2869,9 +3130,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz", - "integrity": "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3041,9 +3302,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz", - "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -3053,7 +3314,7 @@ "micromatch": "^4.0.4" }, "engines": { - "node": ">=8" + "node": ">=8.6.0" } }, "node_modules/fast-json-stable-stringify": { @@ -3304,16 +3565,16 @@ } }, "node_modules/globby": { - "version": "11.0.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", - "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", - "fast-glob": "^3.1.1", - "ignore": "^5.1.4", - "merge2": "^1.3.0", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", "slash": "^3.0.0" }, "engines": { @@ -3453,9 +3714,9 @@ } }, "node_modules/ignore": { - "version": "5.1.9", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.9.tgz", - "integrity": "sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true, "engines": { "node": ">= 4" @@ -4894,6 +5155,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -5477,9 +5744,9 @@ } }, "node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -7344,6 +7611,12 @@ "integrity": "sha512-ekoj4qOQYp7CvjX8ZDBgN86w3MqQhLE1hczEJbEIjgFEumDy+na/4AJAbLXfgEWFNB2pKadM5rPFtuSGMWK7xA==", "dev": true }, + "@types/semver": { + "version": "7.3.13", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", + "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "dev": true + }, "@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -7366,19 +7639,48 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.5.0.tgz", - "integrity": "sha512-4bV6fulqbuaO9UMXU0Ia0o6z6if+kmMRW8rMRyfqXj/eGrZZRGedS4n0adeGNnjr8LKAM495hrQ7Tea52UWmQA==", + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.42.1.tgz", + "integrity": "sha512-LyR6x784JCiJ1j6sH5Y0K6cdExqCCm8DJUTcwG5ThNXJj/G8o5E56u5EdG4SLy+bZAwZBswC+GYn3eGdttBVCg==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "5.5.0", - "@typescript-eslint/scope-manager": "5.5.0", - "debug": "^4.3.2", - "functional-red-black-tree": "^1.0.1", - "ignore": "^5.1.8", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/type-utils": "5.42.1", + "@typescript-eslint/utils": "5.42.1", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", "regexpp": "^3.2.0", - "semver": "^7.3.5", + "semver": "^7.3.7", "tsutils": "^3.21.0" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.42.1.tgz", + "integrity": "sha512-QAZY/CBP1Emx4rzxurgqj3rUinfsh/6mvuKbLNMfJMMKYLRBfweus8brgXF8f64ABkIZ3zdj2/rYYtF8eiuksQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1" + } + }, + "@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true + }, + "@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + } + } } }, "@typescript-eslint/experimental-utils": { @@ -7435,6 +7737,51 @@ "@typescript-eslint/visitor-keys": "5.5.0" } }, + "@typescript-eslint/type-utils": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.42.1.tgz", + "integrity": "sha512-WWiMChneex5w4xPIX56SSnQQo0tEOy5ZV2dqmj8Z371LJ0E+aymWD25JQ/l4FOuuX+Q49A7pzh/CGIQflxMVXg==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/utils": "5.42.1", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.42.1.tgz", + "integrity": "sha512-qElc0bDOuO0B8wDhhW4mYVgi/LZL+igPwXtV87n69/kYC/7NG3MES0jHxJNCr4EP7kY1XVsRy8C/u3DYeTKQmw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + } + } + } + }, "@typescript-eslint/types": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.5.0.tgz", @@ -7456,6 +7803,81 @@ "tsutils": "^3.21.0" } }, + "@typescript-eslint/utils": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.42.1.tgz", + "integrity": "sha512-Gxvf12xSp3iYZd/fLqiQRD4uKZjDNR01bQ+j8zvhPjpsZ4HmvEFL/tC4amGNyxN9Rq+iqvpHLhlqx6KTxz9ZyQ==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/typescript-estree": "5.42.1", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0", + "semver": "^7.3.7" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.42.1.tgz", + "integrity": "sha512-QAZY/CBP1Emx4rzxurgqj3rUinfsh/6mvuKbLNMfJMMKYLRBfweus8brgXF8f64ABkIZ3zdj2/rYYtF8eiuksQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1" + } + }, + "@typescript-eslint/types": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.42.1.tgz", + "integrity": "sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.42.1.tgz", + "integrity": "sha512-qElc0bDOuO0B8wDhhW4mYVgi/LZL+igPwXtV87n69/kYC/7NG3MES0jHxJNCr4EP7kY1XVsRy8C/u3DYeTKQmw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.42.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz", + "integrity": "sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.42.1", + "eslint-visitor-keys": "^3.3.0" + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + } + } + }, "@typescript-eslint/visitor-keys": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.5.0.tgz", @@ -7958,9 +8380,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -8474,9 +8896,9 @@ } }, "eslint-visitor-keys": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz", - "integrity": "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, "espree": { @@ -8584,9 +9006,9 @@ "dev": true }, "fast-glob": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz", - "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -8783,16 +9205,16 @@ } }, "globby": { - "version": "11.0.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", - "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, "requires": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", - "fast-glob": "^3.1.1", - "ignore": "^5.1.4", - "merge2": "^1.3.0", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", "slash": "^3.0.0" } }, @@ -8890,9 +9312,9 @@ } }, "ignore": { - "version": "5.1.9", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.9.tgz", - "integrity": "sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true }, "import-fresh": { @@ -9994,6 +10416,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -10405,9 +10833,9 @@ } }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dev": true, "requires": { "lru-cache": "^6.0.0" diff --git a/package.json b/package.json index 7a16f89..8a56ca1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "format": "prettier --write '**/*.ts'", "format-check": "prettier --check '**/*.ts'", "lint": "eslint src/**/*.ts", - "test": "jest --passWithNoTests" + "test": "jest" }, "repository": { "type": "git", @@ -33,6 +33,7 @@ "devDependencies": { "@types/jest": "^27.0.3", "@types/node": "^16.11.11", + "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.5.0", "@vercel/ncc": "^0.32.0", "eslint": "^8.3.0", diff --git a/src/find.ts b/src/find.ts new file mode 100644 index 0000000..62bf472 --- /dev/null +++ b/src/find.ts @@ -0,0 +1,74 @@ +import * as github from '@actions/github' + +export interface Inputs { + token: string + repository: string + issueNumber: number + commentAuthor: string + bodyIncludes: string + bodyRegex: string + direction: string +} + +export interface Comment { + id: number + body?: string + user: { + login: string + } | null +} + +export function findCommentPredicate( + inputs: Inputs, + comment: Comment +): boolean { + return ( + (inputs.commentAuthor && comment.user + ? comment.user.login === inputs.commentAuthor + : true) && + (inputs.bodyIncludes && comment.body + ? comment.body.includes(inputs.bodyIncludes) + : true) && + (inputs.bodyRegex && comment.body + ? comment.body.match(inputs.bodyRegex) !== null + : true) + ) +} + +export async function findComment( + inputs: Inputs +): Promise { + const octokit = github.getOctokit(inputs.token) + const [owner, repo] = inputs.repository.split('/') + + const parameters = { + owner: owner, + repo: repo, + issue_number: inputs.issueNumber + } + + if (inputs.direction == 'first') { + for await (const {data: comments} of octokit.paginate.iterator( + octokit.rest.issues.listComments, + parameters + )) { + // Search each page for the comment + const comment = comments.find(comment => + findCommentPredicate(inputs, comment) + ) + if (comment) return comment + } + } else { + // direction == 'last' + const comments = await octokit.paginate( + octokit.rest.issues.listComments, + parameters + ) + comments.reverse() + const comment = comments.find(comment => + findCommentPredicate(inputs, comment) + ) + if (comment) return comment + } + return undefined +} diff --git a/src/main.ts b/src/main.ts index e8e6c4c..d0be045 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,71 +1,7 @@ import * as core from '@actions/core' -import * as github from '@actions/github' +import {Inputs, findComment} from './find' import {inspect} from 'util' -interface Inputs { - token: string - repository: string - issueNumber: number - commentAuthor: string - bodyIncludes: string - direction: string -} - -interface Comment { - id: number - body?: string - user: { - login: string - } | null -} - -function findCommentPredicate(inputs: Inputs, comment: Comment): boolean { - return ( - (inputs.commentAuthor && comment.user - ? comment.user.login === inputs.commentAuthor - : true) && - (inputs.bodyIncludes && comment.body - ? comment.body.includes(inputs.bodyIncludes) - : true) - ) -} - -async function findComment(inputs: Inputs): Promise { - const octokit = github.getOctokit(inputs.token) - const [owner, repo] = inputs.repository.split('/') - - const parameters = { - owner: owner, - repo: repo, - issue_number: inputs.issueNumber - } - - if (inputs.direction == 'first') { - for await (const {data: comments} of octokit.paginate.iterator( - octokit.rest.issues.listComments, - parameters - )) { - // Search each page for the comment - const comment = comments.find(comment => - findCommentPredicate(inputs, comment) - ) - if (comment) return comment - } - } else { - // direction == 'last' - const comments = await octokit.paginate( - octokit.rest.issues.listComments, - parameters - ) - comments.reverse() - const comment = comments.find(comment => - findCommentPredicate(inputs, comment) - ) - if (comment) return comment - } - return undefined -} - function getErrorMessage(error: unknown) { if (error instanceof Error) return error.message return String(error) @@ -79,6 +15,7 @@ async function run(): Promise { issueNumber: Number(core.getInput('issue-number')), commentAuthor: core.getInput('comment-author'), bodyIncludes: core.getInput('body-includes'), + bodyRegex: core.getInput('body-regex'), direction: core.getInput('direction') } core.debug(`Inputs: ${inspect(inputs)}`)