From b1981a5480849eb5e897dd696650471fd8124662 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 27 Mar 2026 18:13:48 +0000 Subject: [PATCH] Move `getApiClient` out of `sync-checks.ts` --- pr-checks/api-client.ts | 13 +++++++++++++ pr-checks/sync-checks.ts | 14 +------------- 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 pr-checks/api-client.ts diff --git a/pr-checks/api-client.ts b/pr-checks/api-client.ts new file mode 100644 index 000000000..93675dba7 --- /dev/null +++ b/pr-checks/api-client.ts @@ -0,0 +1,13 @@ +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"; + +/** The type of the Octokit client. */ +export type ApiClient = Octokit & Api & { paginate: PaginateInterface }; + +/** Constructs an `ApiClient` using `token` for authentication. */ +export function getApiClient(token: string): ApiClient { + const opts = githubUtils.getOctokitOptions(token); + return new githubUtils.GitHub(opts); +} diff --git a/pr-checks/sync-checks.ts b/pr-checks/sync-checks.ts index 5b5b0bd26..ef0753110 100755 --- a/pr-checks/sync-checks.ts +++ b/pr-checks/sync-checks.ts @@ -5,12 +5,9 @@ import * as fs from "fs"; 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 * as yaml from "yaml"; +import { type ApiClient, getApiClient } from "./api-client"; import { OLDEST_SUPPORTED_MAJOR_VERSION, PR_CHECK_EXCLUDED_FILE, @@ -49,15 +46,6 @@ function loadExclusions(): Exclusions { ) as Exclusions; } -/** 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); -} - /** * Represents information about a check run. We track the `app_id` that generated the check, * because the API will require it in addition to the name in the future.