Skip to content

Commit b1981a5

Browse files
committed
Move getApiClient out of sync-checks.ts
1 parent 4ed3c0e commit b1981a5

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

pr-checks/api-client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as githubUtils from "@actions/github/lib/utils";
2+
import { type Octokit } from "@octokit/core";
3+
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
4+
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
5+
6+
/** The type of the Octokit client. */
7+
export type ApiClient = Octokit & Api & { paginate: PaginateInterface };
8+
9+
/** Constructs an `ApiClient` using `token` for authentication. */
10+
export function getApiClient(token: string): ApiClient {
11+
const opts = githubUtils.getOctokitOptions(token);
12+
return new githubUtils.GitHub(opts);
13+
}

pr-checks/sync-checks.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
import * as fs from "fs";
66
import { parseArgs } from "node:util";
77

8-
import * as githubUtils from "@actions/github/lib/utils";
9-
import { type Octokit } from "@octokit/core";
10-
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
11-
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
128
import * as yaml from "yaml";
139

10+
import { type ApiClient, getApiClient } from "./api-client";
1411
import {
1512
OLDEST_SUPPORTED_MAJOR_VERSION,
1613
PR_CHECK_EXCLUDED_FILE,
@@ -49,15 +46,6 @@ function loadExclusions(): Exclusions {
4946
) as Exclusions;
5047
}
5148

52-
/** The type of the Octokit client. */
53-
type ApiClient = Octokit & Api & { paginate: PaginateInterface };
54-
55-
/** Constructs an `ApiClient` using `token` for authentication. */
56-
function getApiClient(token: string): ApiClient {
57-
const opts = githubUtils.getOctokitOptions(token);
58-
return new githubUtils.GitHub(opts);
59-
}
60-
6149
/**
6250
* Represents information about a check run. We track the `app_id` that generated the check,
6351
* because the API will require it in addition to the name in the future.

0 commit comments

Comments
 (0)