From 5fdab2aaf2fc3a63dc73bc3ac91fc6afa14d41de Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Fri, 6 Dec 2019 07:52:04 -0500 Subject: [PATCH] Update octokit graphql type dependencies (#228) * Update GraphQL support in base API --- packages/github/RELEASES.md | 4 + packages/github/package-lock.json | 84 ++++++++++++------- packages/github/package.json | 6 +- .../github/src/@types/@octokit/index.d.ts | 36 -------- packages/github/src/context.ts | 7 +- packages/github/src/github.ts | 16 ++-- 6 files changed, 72 insertions(+), 81 deletions(-) delete mode 100644 packages/github/src/@types/@octokit/index.d.ts diff --git a/packages/github/RELEASES.md b/packages/github/RELEASES.md index e8a78027..ef90e1c7 100644 --- a/packages/github/RELEASES.md +++ b/packages/github/RELEASES.md @@ -1,5 +1,9 @@ # @actions/github Releases +### 2.0.0 + +- Upgrade Octokit version to 4.x to include typescript types [#228](https://github.com/actions/toolkit/pull/228) + ### 1.1.0 - Accept Octokit.Options in the GitHub constructor [#113](https://github.com/actions/toolkit/pull/113) diff --git a/packages/github/package-lock.json b/packages/github/package-lock.json index 1fb680e4..4e43a2e4 100644 --- a/packages/github/package-lock.json +++ b/packages/github/package-lock.json @@ -384,64 +384,76 @@ } }, "@octokit/endpoint": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.3.1.tgz", - "integrity": "sha512-4mKqSQfeTRFpQMUGIUG1ewdQT64b2YpvjG2dE1x7nhQupdI/AjdgdcIsmPtRFEXlih/uLQLRWJL4FrivpQdC7A==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.5.1.tgz", + "integrity": "sha512-nBFhRUb5YzVTCX/iAK1MgQ4uWo89Gu0TH00qQHoYRCsE12dWcG1OiLd7v2EIo2+tpUKPMOQ62QFy9hy9Vg2ULg==", "requires": { - "deepmerge": "4.0.0", + "@octokit/types": "^2.0.0", "is-plain-object": "^3.0.0", - "universal-user-agent": "^3.0.0", - "url-template": "^2.0.8" + "universal-user-agent": "^4.0.0" }, "dependencies": { "universal-user-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-3.0.0.tgz", - "integrity": "sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz", + "integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==", "requires": { - "os-name": "^3.0.0" + "os-name": "^3.1.0" } } } }, "@octokit/graphql": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz", - "integrity": "sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.3.1.tgz", + "integrity": "sha512-hCdTjfvrK+ilU2keAdqNBWOk+gm1kai1ZcdjRfB30oA3/T6n53UVJb7w0L5cR3/rhU91xT3HSqCd+qbvH06yxA==", "requires": { - "@octokit/request": "^5.0.0", - "universal-user-agent": "^2.0.3" + "@octokit/request": "^5.3.0", + "@octokit/types": "^2.0.0", + "universal-user-agent": "^4.0.0" + }, + "dependencies": { + "universal-user-agent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz", + "integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==", + "requires": { + "os-name": "^3.1.0" + } + } } }, "@octokit/request": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.0.1.tgz", - "integrity": "sha512-SHOk/APYpfrzV1RNf7Ux8SZi+vZXhMIB2dBr4TQR6ExMX8R4jcy/0gHw26HLe1dWV7Wxe9WzYyDSEC0XwnoCSQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.3.1.tgz", + "integrity": "sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg==", "requires": { - "@octokit/endpoint": "^5.1.0", + "@octokit/endpoint": "^5.5.0", "@octokit/request-error": "^1.0.1", + "@octokit/types": "^2.0.0", "deprecation": "^2.0.0", "is-plain-object": "^3.0.0", "node-fetch": "^2.3.0", "once": "^1.4.0", - "universal-user-agent": "^3.0.0" + "universal-user-agent": "^4.0.0" }, "dependencies": { "universal-user-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-3.0.0.tgz", - "integrity": "sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz", + "integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==", "requires": { - "os-name": "^3.0.0" + "os-name": "^3.1.0" } } } }, "@octokit/request-error": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.0.4.tgz", - "integrity": "sha512-L4JaJDXn8SGT+5G0uX79rZLv0MNJmfGa4vb4vy1NnpjSnWDLJRy6m90udGwvMmavwsStgbv2QNkPzzTCMmL+ig==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.2.0.tgz", + "integrity": "sha512-DNBhROBYjjV/I9n7A8kVkmQNkqFAMem90dSxqvPq57e2hBr7mNTX98y3R2zDpqMQHVRpBDjsvsfIGgBzy+4PAg==", "requires": { + "@octokit/types": "^2.0.0", "deprecation": "^2.0.0", "once": "^1.4.0" } @@ -504,6 +516,14 @@ } } }, + "@octokit/types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.0.2.tgz", + "integrity": "sha512-StASIL2lgT3TRjxv17z9pAqbnI7HGu9DrJlg3sEBFfCLaMEqp+O3IQPUF6EZtQ4xkAu2ml6kMBBCtGxjvmtmuQ==", + "requires": { + "@types/node": ">= 8" + } + }, "@types/babel__core": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.2.tgz", @@ -570,6 +590,11 @@ "@types/istanbul-lib-report": "*" } }, + "@types/node": { + "version": "12.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz", + "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==" + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -1262,11 +1287,6 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "deepmerge": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.0.0.tgz", - "integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww==" - }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", diff --git a/packages/github/package.json b/packages/github/package.json index 2ee3660b..36aeea4a 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -1,6 +1,6 @@ { "name": "@actions/github", - "version": "1.1.0", + "version": "2.0.0", "description": "Actions github lib", "keywords": [ "github", @@ -27,13 +27,15 @@ "scripts": { "test": "jest", "build": "tsc", + "format": "prettier --write **/*.ts", + "format-check": "prettier --check **/*.ts", "tsc": "tsc" }, "bugs": { "url": "https://github.com/actions/toolkit/issues" }, "dependencies": { - "@octokit/graphql": "^2.0.1", + "@octokit/graphql": "^4.3.1", "@octokit/rest": "^16.15.0" }, "devDependencies": { diff --git a/packages/github/src/@types/@octokit/index.d.ts b/packages/github/src/@types/@octokit/index.d.ts deleted file mode 100644 index f4e3c175..00000000 --- a/packages/github/src/@types/@octokit/index.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -declare module '@octokit/graphql' { - export interface GraphQlQueryResponse { - data: {[key: string]: any} | null - errors?: [ - { - message: string - path: [string] - extensions: {[key: string]: any} - locations: [ - { - line: number - column: number - } - ] - } - ] - } - - export interface GraphQLError { - message: string - locations?: {line: number; column: number}[] - path?: (string | number)[] - extensions?: { - [key: string]: any - } - } - - export interface Variables { - [key: string]: any - } - - export function defaults( - options: any - ): (query: string, variables?: Variables) => Promise -} diff --git a/packages/github/src/context.ts b/packages/github/src/context.ts index a06a8e0a..f2aafde1 100644 --- a/packages/github/src/context.ts +++ b/packages/github/src/context.ts @@ -27,11 +27,8 @@ export class Context { readFileSync(process.env.GITHUB_EVENT_PATH, {encoding: 'utf8'}) ) } else { - process.stdout.write( - `GITHUB_EVENT_PATH ${ - process.env.GITHUB_EVENT_PATH - } does not exist${EOL}` - ) + const path = process.env.GITHUB_EVENT_PATH + process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${EOL}`) } } this.eventName = process.env.GITHUB_EVENT_NAME as string diff --git a/packages/github/src/github.ts b/packages/github/src/github.ts index 35b5f624..fdf19f1c 100644 --- a/packages/github/src/github.ts +++ b/packages/github/src/github.ts @@ -1,5 +1,11 @@ // Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts -import {GraphQlQueryResponse, Variables, defaults} from '@octokit/graphql' +import {graphql} from '@octokit/graphql' + +// we need this type to set up a property on the GitHub object +// that has token authorization +// (it is not exported from octokit by default) +import {graphql as GraphQL} from '@octokit/graphql/dist-types/types' + import Octokit from '@octokit/rest' import * as Context from './context' @@ -9,14 +15,12 @@ Octokit.prototype = new Octokit() export const context = new Context.Context() export class GitHub extends Octokit { - graphql: ( - query: string, - variables?: Variables - ) => Promise + graphql: GraphQL constructor(token: string, opts: Omit = {}) { super({...opts, auth: `token ${token}`}) - this.graphql = defaults({ + + this.graphql = graphql.defaults({ headers: {authorization: `token ${token}`} }) }