Skip to content

Commit

Permalink
Chore: Update Octokit types and version
Browse files Browse the repository at this point in the history
There was a mismatch between types and package that was preventing
the project from compiling without a `package-lock.json`.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fix #32
Close #36
  • Loading branch information
Jesus David García Gomez committed Jun 29, 2020
1 parent 55d1096 commit 718ebea
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 88 deletions.
3 changes: 2 additions & 1 deletion packages/utils/package.json
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@destinationstransfers/ntp": "^2.0.0",
"@octokit/rest": "^16.34.0",
"@octokit/rest": "^18.0.0",
"applicationinsights": "^1.5.0",
"azure-sb": "^0.11.1",
"debug": "^4.1.1",
Expand All @@ -21,6 +21,7 @@
},
"devDependencies": {
"@hint/utils": "^6.1.0",
"@octokit/types": "^5.0.1",
"@types/azure": "^0.9.20",
"@types/azure-sb": "^0.0.36",
"@types/debug": "^4.1.5",
Expand Down
31 changes: 23 additions & 8 deletions packages/utils/src/github/issuereporter.ts
@@ -1,4 +1,5 @@
import * as Octokit from '@octokit/rest';
import { Octokit } from '@octokit/rest';
import * as OctokitTypes from '@octokit/types';

import { IssueData } from '../types/issuedata';

Expand All @@ -11,6 +12,20 @@ type GithubData = {
repo: string;
}

/*
* Octokit/types doesn't define a name for some of the types.
* In these cases, they have a way to get the type indicating
* the endpoint and what type you want ('parameters', 'response', 'request')
* There are a couple of issues open to tack if they export the types in an easy way:
* - https://github.com/octokit/types.ts/issues/119
* - https://github.com/octokit/types.ts/issues/120
*/
/* eslint-disable camelcase */
type SearchItem = OctokitTypes.Endpoints['GET /search/issues']['response']['data']['items'][0];

type IssuesUpdateEndpoint = OctokitTypes.Endpoints['PATCH /repos/:owner/:repo/issues/:issue_number']['parameters'];
/* eslint-enable camelcase */

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

export class IssueReporter {
Expand Down Expand Up @@ -48,7 +63,7 @@ export class IssueReporter {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

private addIssueComment(issue: Octokit.SearchIssuesResponseItemsItem, issueData: IssueData) {
private addIssueComment(issue: SearchItem, issueData: IssueData) {
return this.octokit.issues.createComment({
body: this.getErrorMessage(issueData),
issue_number: issue.number, // eslint-disable-line camelcase
Expand All @@ -58,19 +73,19 @@ export class IssueReporter {

}

private async closeIssue(issue: Octokit.SearchIssuesResponseItemsItem) {
private async closeIssue(issue: SearchItem) {
await this.editIssue({
issue_number: issue.number, // eslint-disable-line camelcase
state: 'closed'
});
}

private editIssue(configs: Partial<Octokit.IssuesUpdateParams>) {
private editIssue(configs: Partial<IssuesUpdateEndpoint>) {
return this.octokit.issues.update((Object.assign(
{},
this.GITHUB_DATA,
configs
) as Octokit.IssuesUpdateParams));
) as IssuesUpdateEndpoint));
}

private getErrorMessage(issueData: IssueData) {
Expand Down Expand Up @@ -162,8 +177,8 @@ ${issueData.log}
));
}

private async searchIssues(q: string) {
const result = await this.octokit.search.issues({ q });
private async searchIssues(q: string): Promise<SearchItem[]> {
const result = await this.octokit.search.issuesAndPullRequests({ q });

return result.data.items;
}
Expand Down Expand Up @@ -222,7 +237,7 @@ ${issueData.log}
await this.openIssue(issueData);
}

private async updateIssueLabels(issue: Octokit.SearchIssuesResponseItemsItem, labels: string[]) {
private async updateIssueLabels(issue: SearchItem, labels: string[]) {
await this.editIssue({
issue_number: issue.number, // eslint-disable-line camelcase
labels
Expand Down
174 changes: 95 additions & 79 deletions yarn.lock
Expand Up @@ -1079,67 +1079,108 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@octokit/endpoint@^5.5.0":
version "5.5.0"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.0.tgz#d7e7960ffe39096cb67062f07efa84db52b20edb"
integrity sha512-TXYS6zXeBImNB9BVj+LneMDqXX+H0exkOpyXobvp92O3B1348QsKnNioISFKgOMsb3ibZvQGwCdpiwQd3KAjIA==
"@octokit/auth-token@^2.4.0":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a"
integrity sha512-jE/lE/IKIz2v1+/P0u4fJqv0kYwXOTujKemJMFr6FeopsxlIK3+wKDCJGnysg81XID5TgZQbIfuJ5J0lnTiuyQ==
dependencies:
"@octokit/types" "^1.0.0"
"@octokit/types" "^5.0.0"

"@octokit/core@^3.0.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.0.tgz#9c3c9b23f7504668cfa057f143ccbf0c645a0ac9"
integrity sha512-yPyQSmxIXLieEIRikk2w8AEtWkFdfG/LXcw1KvEtK3iP0ENZLW/WYQmdzOKqfSaLhooz4CJ9D+WY79C8ZliACw==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/graphql" "^4.3.1"
"@octokit/request" "^5.4.0"
"@octokit/types" "^5.0.0"
before-after-hook "^2.1.0"
universal-user-agent "^5.0.0"

"@octokit/endpoint@^6.0.1":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.3.tgz#dd09b599662d7e1b66374a177ab620d8cdf73487"
integrity sha512-Y900+r0gIz+cWp6ytnkibbD95ucEzDSKzlEnaWS52hbCDNcCJYO5mRmWW7HRAnDc7am+N/5Lnd8MppSaTYx1Yg==
dependencies:
"@octokit/types" "^5.0.0"
is-plain-object "^3.0.0"
universal-user-agent "^4.0.0"
universal-user-agent "^5.0.0"

"@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.0.4.tgz#15e1dc22123ba4a9a4391914d80ec1e5303a23be"
integrity sha512-L4JaJDXn8SGT+5G0uX79rZLv0MNJmfGa4vb4vy1NnpjSnWDLJRy6m90udGwvMmavwsStgbv2QNkPzzTCMmL+ig==
"@octokit/graphql@^4.3.1":
version "4.5.1"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.1.tgz#162aed1490320b88ce34775b3f6b8de945529fa9"
integrity sha512-qgMsROG9K2KxDs12CO3bySJaYoUu2aic90qpFrv7A8sEBzZ7UFGvdgPKiLw5gOPYEYbS0Xf8Tvf84tJutHPulQ==
dependencies:
"@octokit/request" "^5.3.0"
"@octokit/types" "^5.0.0"
universal-user-agent "^5.0.0"

"@octokit/plugin-paginate-rest@^2.2.0":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.2.3.tgz#a6ad4377e7e7832fb4bdd9d421e600cb7640ac27"
integrity sha512-eKTs91wXnJH8Yicwa30jz6DF50kAh7vkcqCQ9D7/tvBAP5KKkg6I2nNof8Mp/65G0Arjsb4QcOJcIEQY+rK1Rg==
dependencies:
"@octokit/types" "^5.0.0"

"@octokit/plugin-request-log@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e"
integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==

"@octokit/plugin-rest-endpoint-methods@4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.0.0.tgz#b02a2006dda8e908c3f8ab381dd5475ef5a810a8"
integrity sha512-emS6gysz4E9BNi9IrCl7Pm4kR+Az3MmVB0/DoDCmF4U48NbYG3weKyDlgkrz6Jbl4Mu4nDx8YWZwC4HjoTdcCA==
dependencies:
"@octokit/types" "^5.0.0"
deprecation "^2.3.1"

"@octokit/request-error@^2.0.0":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0"
integrity sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw==
dependencies:
"@octokit/types" "^5.0.1"
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.2.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.0.tgz#ce49c9d05519054499b5bb729d4ecb4735cee78a"
integrity sha512-mMIeNrtYyNEIYNsKivDyUAukBkw0M5ckyJX56xoFRXSasDPCloIXaQOnaKNopzQ8dIOvpdq1ma8gmrS+h6O2OQ==
"@octokit/request@^5.3.0", "@octokit/request@^5.4.0":
version "5.4.5"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.5.tgz#8df65bd812047521f7e9db6ff118c06ba84ac10b"
integrity sha512-atAs5GAGbZedvJXXdjtKljin+e2SltEs48B3naJjqWupYl2IUBbB/CJisyjbNHcKpHzb3E+OYEZ46G8eakXgQg==
dependencies:
"@octokit/endpoint" "^5.5.0"
"@octokit/request-error" "^1.0.1"
"@octokit/types" "^1.0.0"
"@octokit/endpoint" "^6.0.1"
"@octokit/request-error" "^2.0.0"
"@octokit/types" "^5.0.0"
deprecation "^2.0.0"
is-plain-object "^3.0.0"
node-fetch "^2.3.0"
once "^1.4.0"
universal-user-agent "^4.0.0"

"@octokit/rest@^16.34.0":
version "16.34.0"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.34.0.tgz#8703e46d7e9f6aec24a7e591b073f325ca13f6e2"
integrity sha512-EBe5qMQQOZRuezahWCXCnSe0J6tAqrW2hrEH9U8esXzKor1+HUDf8jgImaZf5lkTyWCQA296x9kAH5c0pxEgVQ==
dependencies:
"@octokit/request" "^5.2.0"
"@octokit/request-error" "^1.0.2"
atob-lite "^2.0.0"
before-after-hook "^2.0.0"
btoa-lite "^1.0.0"
deprecation "^2.0.0"
lodash.get "^4.4.2"
lodash.set "^4.3.2"
lodash.uniq "^4.5.0"
octokit-pagination-methods "^1.1.0"
once "^1.4.0"
universal-user-agent "^4.0.0"
universal-user-agent "^5.0.0"

"@octokit/types@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-1.1.0.tgz#6c9b286f9766f8cc6c5bab9fd3eb6a7aa019c586"
integrity sha512-t4ZD74UnNVMq6kZBDZceflRKK3q4o5PoCKMAGht0RK84W57tqonqKL3vCxJHtbGExdan9RwV8r7VJBZxIM1O7Q==
"@octokit/rest@^18.0.0":
version "18.0.0"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.0.0.tgz#7f401d9ce13530ad743dfd519ae62ce49bcc0358"
integrity sha512-4G/a42lry9NFGuuECnua1R1eoKkdBYJap97jYbWDNYBOUboWcM75GJ1VIcfvwDV/pW0lMPs7CEmhHoVrSV5shg==
dependencies:
"@octokit/core" "^3.0.0"
"@octokit/plugin-paginate-rest" "^2.2.0"
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "4.0.0"

"@octokit/types@^5.0.0", "@octokit/types@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.0.1.tgz#5459e9a5e9df8565dcc62c17a34491904d71971e"
integrity sha512-GorvORVwp244fGKEt3cgt/P+M0MGy4xEDbckw+K5ojEezxyMDgCaYPKVct+/eWQfZXOT7uq0xRpmrl/+hliabA==
dependencies:
"@types/node" "^12.11.1"
"@types/node" ">= 8"

"@online-service/utils@file:packages/utils":
version "1.0.0"
dependencies:
"@destinationstransfers/ntp" "^2.0.0"
"@octokit/rest" "^16.34.0"
"@octokit/rest" "^18.0.0"
applicationinsights "^1.5.0"
azure-sb "^0.11.1"
debug "^4.1.1"
Expand Down Expand Up @@ -1284,11 +1325,16 @@
"@types/mongodb" "*"
"@types/node" "*"

"@types/node@*", "@types/node@^12.11.1", "@types/node@^12.11.7", "@types/node@^12.12.3":
"@types/node@*", "@types/node@^12.11.7", "@types/node@^12.12.3":
version "12.12.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.3.tgz#ebfe83507ac506bc3486314a8aa395be66af8d23"
integrity sha512-opgSsy+cEF9N8MgaVPnWVtdJ3o4mV2aMHvDq7thkQUFt0EuOHJon4rQpJfhjmNHB+ikl0Cd6WhWIErOyQ+f7tw==

"@types/node@>= 8":
version "14.0.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.14.tgz#24a0b5959f16ac141aeb0c5b3cd7a15b7c64cbce"
integrity sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down Expand Up @@ -1744,11 +1790,6 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

atob-lite@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696"
integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=

ava@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/ava/-/ava-2.4.0.tgz#a3bd8b0e01d8826004c91de375eb2313ba5237c3"
Expand Down Expand Up @@ -1916,7 +1957,7 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

before-after-hook@^2.0.0:
before-after-hook@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"
integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==
Expand Down Expand Up @@ -2033,11 +2074,6 @@ bson@^1.1.1, bson@~1.1.1:
resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.1.tgz#4330f5e99104c4e751e7351859e2d408279f2f13"
integrity sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==

btoa-lite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"
integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc=

buffer-crc32@^0.2.1, buffer-crc32@^0.2.13:
version "0.2.13"
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
Expand Down Expand Up @@ -2897,7 +2933,7 @@ depd@~1.1.2:
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=

deprecation@^2.0.0:
deprecation@^2.0.0, deprecation@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==
Expand Down Expand Up @@ -4853,11 +4889,6 @@ lodash.flattendeep@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=

lodash.islength@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.islength/-/lodash.islength-4.0.1.tgz#4e9868d452575d750affd358c979543dc20ed577"
Expand All @@ -4873,11 +4904,6 @@ lodash.merge@^4.6.1:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=

lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
Expand All @@ -4893,11 +4919,6 @@ lodash.union@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88"
integrity sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=

lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
Expand Down Expand Up @@ -5714,11 +5735,6 @@ observable-to-promise@^1.0.0:
is-observable "^2.0.0"
symbol-observable "^1.0.4"

octokit-pagination-methods@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4"
integrity sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==

once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand Down Expand Up @@ -7747,10 +7763,10 @@ unist-util-visit@^1.1.0:
dependencies:
unist-util-visit-parents "^2.0.0"

universal-user-agent@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16"
integrity sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==
universal-user-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-5.0.0.tgz#a3182aa758069bf0e79952570ca757de3579c1d9"
integrity sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==
dependencies:
os-name "^3.1.0"

Expand Down

0 comments on commit 718ebea

Please sign in to comment.