File tree Expand file tree Collapse file tree 2 files changed +23
-8
lines changed
Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change 1+ import { ParseArgsConfig } from "node:util" ;
2+
13import * as githubUtils from "@actions/github/lib/utils" ;
24import { type Octokit } from "@octokit/core" ;
35import { type PaginateInterface } from "@octokit/plugin-paginate-rest" ;
@@ -11,3 +13,16 @@ export function getApiClient(token: string): ApiClient {
1113 const opts = githubUtils . getOctokitOptions ( token ) ;
1214 return new githubUtils . GitHub ( opts ) ;
1315}
16+
17+ export interface TokenOption {
18+ /** The token to use to authenticate to the GitHub API. */
19+ token ?: string ;
20+ }
21+
22+ /** Command-line argument parser settings for the token parameter. */
23+ export const TOKEN_OPTION_CONFIG = {
24+ // The token to use to authenticate to the API.
25+ token : {
26+ type : "string" ,
27+ } ,
28+ } satisfies ParseArgsConfig [ "options" ] ;
Original file line number Diff line number Diff line change @@ -7,16 +7,19 @@ import { parseArgs } from "node:util";
77
88import * as yaml from "yaml" ;
99
10- import { type ApiClient , getApiClient } from "./api-client" ;
10+ import {
11+ type ApiClient ,
12+ getApiClient ,
13+ TOKEN_OPTION_CONFIG ,
14+ TokenOption ,
15+ } from "./api-client" ;
1116import {
1217 OLDEST_SUPPORTED_MAJOR_VERSION ,
1318 PR_CHECK_EXCLUDED_FILE ,
1419} from "./config" ;
1520
1621/** Represents the command-line options. */
17- export interface Options {
18- /** The token to use to authenticate to the GitHub API. */
19- token ?: string ;
22+ export interface Options extends TokenOption {
2023 /** The git ref to use the checks for. */
2124 ref ?: string ;
2225 /** Whether to actually apply the changes or not. */
@@ -205,10 +208,7 @@ async function updateBranch(
205208async function main ( ) : Promise < void > {
206209 const { values : options } = parseArgs ( {
207210 options : {
208- // The token to use to authenticate to the API.
209- token : {
210- type : "string" ,
211- } ,
211+ ...TOKEN_OPTION_CONFIG ,
212212 // The git ref for which to retrieve the check runs.
213213 ref : {
214214 type : "string" ,
You can’t perform that action at this time.
0 commit comments