From 9481177f3ded6eaac91e6bb74e30ed0fa45db604 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 13 Mar 2026 18:49:50 +0000 Subject: [PATCH] Initialise API client --- package-lock.json | 64 +++++++++++++++++++++------------------- pr-checks/package.json | 4 +++ pr-checks/sync-checks.ts | 17 +++++++++++ 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0ee6909b..4c0800f0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -411,36 +411,6 @@ "undici": "^6.23.0" } }, - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", - "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", - "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, "node_modules/@actions/github/node_modules/undici": { "version": "6.23.0", "resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz", @@ -2138,6 +2108,21 @@ "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", "license": "MIT" }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", + "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@octokit/plugin-request-log": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", @@ -2147,6 +2132,21 @@ "@octokit/core": ">=3" } }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@octokit/plugin-retry": { "version": "8.0.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.0.3.tgz", @@ -9921,6 +9921,10 @@ }, "devDependencies": { "@actions/core": "*", + "@actions/github": "*", + "@octokit/core": "*", + "@octokit/plugin-paginate-rest": "*", + "@octokit/plugin-rest-endpoint-methods": "*", "@types/node": "^20.19.9", "tsx": "^4.21.0", "typescript": "^5.9.3" diff --git a/pr-checks/package.json b/pr-checks/package.json index 7ec2fdc0f..48bcf6ba3 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -6,6 +6,10 @@ }, "devDependencies": { "@actions/core": "*", + "@actions/github": "*", + "@octokit/core": "*", + "@octokit/plugin-paginate-rest": "*", + "@octokit/plugin-rest-endpoint-methods": "*", "@types/node": "^20.19.9", "tsx": "^4.21.0", "typescript": "^5.9.3" diff --git a/pr-checks/sync-checks.ts b/pr-checks/sync-checks.ts index f447ace02..f618cdcfa 100755 --- a/pr-checks/sync-checks.ts +++ b/pr-checks/sync-checks.ts @@ -4,8 +4,22 @@ import { parseArgs } from "node:util"; +import * as githubUtils from "@actions/github/lib/utils"; +import { type Octokit } from "@octokit/core"; +import { type PaginateInterface } from "@octokit/plugin-paginate-rest"; +import { type Api } from "@octokit/plugin-rest-endpoint-methods"; + import { OLDEST_SUPPORTED_MAJOR_VERSION } from "./config"; +/** The type of the Octokit client. */ +type ApiClient = Octokit & Api & { paginate: PaginateInterface }; + +/** Constructs an `ApiClient` using `token` for authentication. */ +function getApiClient(token: string): ApiClient { + const opts = githubUtils.getOctokitOptions(token); + return new githubUtils.GitHub(opts); +} + async function main(): Promise { const { values: options } = parseArgs({ options: { @@ -37,6 +51,9 @@ async function main(): Promise { `Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`, ); + // Initialise the API client. + const client = getApiClient(options.token); + process.exit(0); }