Initialise API client

This commit is contained in:
Michael B. Gale
2026-03-13 18:49:50 +00:00
parent 9813849e61
commit 9481177f3d
3 changed files with 55 additions and 30 deletions

View File

@@ -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<void> {
const { values: options } = parseArgs({
options: {
@@ -37,6 +51,9 @@ async function main(): Promise<void> {
`Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`,
);
// Initialise the API client.
const client = getApiClient(options.token);
process.exit(0);
}