@theholocron/holocron-plugin-github 5.0.0-alpha.58 → 5.0.0-alpha.581
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -8
- package/dist/index.d.mts +369 -76
- package/dist/index.mjs +4039 -123
- package/package.json +30 -26
package/dist/index.d.mts
CHANGED
|
@@ -1,47 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `@theholocron/holocron-plugin-github` — entrypoint.
|
|
3
|
+
*
|
|
4
|
+
* Holocron loads a plugin by resolving its package and reading the
|
|
5
|
+
* default export, which is a `Plugin` object declaring which
|
|
6
|
+
* capabilities it implements. The factory for each capability
|
|
7
|
+
* receives plugin-level options from `holocron.config.json` and
|
|
8
|
+
* returns the bound implementation.
|
|
9
|
+
*/
|
|
10
|
+
import { AddedItem, Auth, AuthError, BoardItem, BoardItemInput, BoardState, BoardSummary, BoardTemplate, Ci, CiRun, CiRunFilter, EnsureRelaySourceInput, EnsureRelaySourceResult, EnsureReport, Environment, Environments, ExportInfo, ImportOptions, ImportResult, InspectRelaySourceInput, Issue, IssueCreateInput, IssuePatch, IssueRecord, IssueSearchFilter, IssueSelector, IssueTypeDeclaration, IssueTypeInfo, IssueUpdateResult, Issues, LabelDef, LifecycleResult, LifecycleSlot, MoveReport, PagesConfig, PluginToken, Projects, PullRequest, PullRequestChecks, PullRequestInput, PullRequestPatch, PullRequestResult, RelaySourceState, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretAccess, SecretScope, Secrets, Source, SourceBranch, SourceCheckRun, SourceCheckRunWrite, SourceCommitStatus, SourceFile, SourceRepoInfo, SourceRequiredChecks, SourceRulesetDetail, SourceSecurity, SourceTeamMember, SyncResult, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TeamPermission as TeamPermission$1, TrackerDoctorReport, TrackerUser, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, createFeatureResolver } from "@theholocron/cli";
|
|
11
|
+
import { GitHubClient, GitHubClientOptions, GraphQLClient, createGitHubClient } from "@theholocron/github-client";
|
|
12
|
+
/** Resolves the token for read-only GitHub access (`HOLOCRON_READ_TOKEN`, keyring key `github.read`). */
|
|
13
|
+
export declare const resolveReadToken: import("@theholocron/cli").FeatureResolver;
|
|
14
|
+
/** Resolves the token for issue operations (`HOLOCRON_ISSUES_TOKEN`, keyring key `github.issues`). */
|
|
15
|
+
export declare const resolveIssuesToken: import("@theholocron/cli").FeatureResolver;
|
|
16
|
+
/** Resolves the token for syncing repo files and settings (`HOLOCRON_SYNC_TOKEN`, keyring key `github.sync`). */
|
|
17
|
+
export declare const resolveSyncToken: import("@theholocron/cli").FeatureResolver;
|
|
18
|
+
/** Resolves the token for release operations (`HOLOCRON_RELEASE_TOKEN`, keyring key `github.release`). */
|
|
19
|
+
export declare const resolveReleaseToken: import("@theholocron/cli").FeatureResolver;
|
|
20
|
+
/** Resolves the repo-scoped admin token (`HOLOCRON_ADMIN_TOKEN`, keyring key `github.admin`). */
|
|
21
|
+
export declare const resolveAdminToken: import("@theholocron/cli").FeatureResolver;
|
|
22
|
+
/** Resolves the org-level secrets token (`HOLOCRON_SECRETS_TOKEN`, keyring key `github.secrets`). */
|
|
23
|
+
export declare const resolveSecretsToken: import("@theholocron/cli").FeatureResolver;
|
|
24
|
+
/** Resolves the token for deployment operations (`HOLOCRON_DEPLOY_TOKEN`, keyring key `github.deploy`). */
|
|
25
|
+
export declare const resolveDeployToken: import("@theholocron/cli").FeatureResolver;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the token for the user-sync files in the org's private config repo (`HOLOCRON_USER_SYNC_TOKEN`, keyring
|
|
28
|
+
* key `github.user-sync`).
|
|
29
|
+
*/
|
|
30
|
+
export declare const resolveUserSyncToken: import("@theholocron/cli").FeatureResolver;
|
|
31
|
+
/** Resolves the org-level token (`HOLOCRON_ORG_TOKEN`, keyring key `github.org`). */
|
|
32
|
+
export declare const resolveOrgToken: import("@theholocron/cli").FeatureResolver;
|
|
33
|
+
/** `repo.labels`, which the loader hands the plugin: the area map, the kind tables and the repositories. */
|
|
34
|
+
interface LabelsConfig {
|
|
35
|
+
areas?: Record<string, string[]>;
|
|
36
|
+
scopes?: Record<string, string>;
|
|
37
|
+
/** Main kind label to Type (default `bug` Bug, `enhancement` Feature, `chore` Task). */
|
|
38
|
+
kinds?: Record<string, string>;
|
|
39
|
+
/** Kind labels used only when none of `kinds` is on the issue (default the six of #2494, each Task). */
|
|
40
|
+
fallbackKinds?: Record<string, string>;
|
|
41
|
+
/** The repositories to run on when `--repo` is not given. */
|
|
42
|
+
repos?: string[];
|
|
43
|
+
}
|
|
13
44
|
interface CiOptions {
|
|
14
45
|
repo: string;
|
|
15
46
|
}
|
|
16
|
-
|
|
47
|
+
/** The GitHub implementation of the `ci` capability, backed by GitHub Actions workflow runs. */
|
|
48
|
+
export declare class GitHubCi implements Ci {
|
|
17
49
|
private readonly client;
|
|
18
50
|
private readonly opts;
|
|
51
|
+
/** Capability key, always `"ci"`. */
|
|
19
52
|
readonly key: "ci";
|
|
53
|
+
/** Provider name, always `"github"`. */
|
|
20
54
|
readonly providerName = "github";
|
|
21
55
|
constructor(client: GitHubClient, opts: CiOptions);
|
|
56
|
+
/** Lists workflow runs for the repo, optionally filtered by branch, status and limit. */
|
|
22
57
|
listRuns(filter?: CiRunFilter): Promise<CiRun[]>;
|
|
58
|
+
/** Fetches one workflow run by id. */
|
|
23
59
|
getRun(id: string | number): Promise<CiRun>;
|
|
24
60
|
private mapRun;
|
|
25
61
|
private mapConclusion;
|
|
26
62
|
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/capabilities/environments.d.ts
|
|
29
63
|
interface EnvironmentsOptions {
|
|
30
64
|
repo: string;
|
|
31
65
|
}
|
|
32
|
-
|
|
66
|
+
/** The GitHub implementation of the `environments` capability, managing a repo's deployment environments. */
|
|
67
|
+
export declare class GitHubEnvironments implements Environments {
|
|
33
68
|
private readonly client;
|
|
34
69
|
private readonly opts;
|
|
70
|
+
/** Capability key, always `"environments"`. */
|
|
35
71
|
readonly key: "environments";
|
|
72
|
+
/** Provider name, always `"github"`. */
|
|
36
73
|
readonly providerName = "github";
|
|
37
74
|
constructor(client: GitHubClient, opts: EnvironmentsOptions);
|
|
75
|
+
/** Lists the repo's environments with their wait timer, self-review rule and required reviewers. */
|
|
38
76
|
listEnvironments(): Promise<Environment[]>;
|
|
77
|
+
/** Creates or updates an environment, sending only the settings the given environment defines. */
|
|
39
78
|
upsertEnvironment(env: Environment): Promise<void>;
|
|
79
|
+
/** Deletes the named environment. */
|
|
40
80
|
deleteEnvironment(name: string): Promise<void>;
|
|
41
81
|
private flattenReviewers;
|
|
42
82
|
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/capabilities/issues.d.ts
|
|
45
83
|
interface IssuesOptions {
|
|
46
84
|
repo: string;
|
|
47
85
|
/**
|
|
@@ -54,39 +92,87 @@ interface IssuesOptions {
|
|
|
54
92
|
inProgress: string;
|
|
55
93
|
inReview: string;
|
|
56
94
|
};
|
|
95
|
+
/** The organization's issue Types (`issueTypes`), which `--type` and a record's kind are written as. */
|
|
96
|
+
issueTypes?: ReadonlyArray<{
|
|
97
|
+
name: string;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* A client with the organization token (`HOLOCRON_ORG_TOKEN`, Issue types read and write), for the Type methods
|
|
101
|
+
* only; `undefined` when none is configured. The shared issues token never writes the organization's vocabulary.
|
|
102
|
+
*/
|
|
103
|
+
orgClient?: () => GitHubClient | undefined;
|
|
57
104
|
}
|
|
58
|
-
|
|
105
|
+
/** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
|
|
106
|
+
export declare class GitHubIssues implements Issues {
|
|
59
107
|
private readonly client;
|
|
108
|
+
/** Capability key, always `"issues"`. */
|
|
60
109
|
readonly key: "issues";
|
|
110
|
+
/** Provider name, always `"github"`. */
|
|
61
111
|
readonly providerName = "github";
|
|
62
112
|
private readonly owner;
|
|
63
113
|
private readonly repoName;
|
|
64
114
|
private readonly repo;
|
|
65
115
|
private readonly labels;
|
|
116
|
+
private readonly kinds;
|
|
117
|
+
private readonly orgClient;
|
|
66
118
|
constructor(client: GitHubClient, opts: IssuesOptions);
|
|
67
119
|
getMyself(): Promise<TrackerUser>;
|
|
120
|
+
/**
|
|
121
|
+
* Searches the repo's issues, newest update first, leaving out pull requests.
|
|
122
|
+
*
|
|
123
|
+
* With `filter.text`, the issues are paged (newest update first, 100 a page, at most 20 pages) and compared
|
|
124
|
+
* client-side, without regard to case, until `limit` matches are found or the issues run out. GitHub's issue
|
|
125
|
+
* search (`GET /search/issues`) is deliberately not used: it indexes the words of a body, so punctuation and an
|
|
126
|
+
* HTML comment such as `<!-- holocron:idea notes/a.md -->` cannot be relied on to match, it is limited to 30
|
|
127
|
+
* requests a minute and it is eventually consistent (an issue made a moment ago may be missing). Paging has none
|
|
128
|
+
* of those limits, at the cost of reading up to 20 pages of a very large repository.
|
|
129
|
+
*/
|
|
68
130
|
search(filter: IssueSearchFilter): Promise<Issue[]>;
|
|
131
|
+
private searchText;
|
|
132
|
+
/** Fetches one issue by its key. */
|
|
69
133
|
get(key: string): Promise<Issue>;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Creates an issue and returns its key as `#<number>`; the milestone is resolved from its title. Type, Priority,
|
|
136
|
+
* Effort, the dates, the parent and the blockers are set after the issue exists; what GitHub refuses of them comes
|
|
137
|
+
* back in `dropped`, never as a failure, because the issue is made by then and its key must not be lost.
|
|
138
|
+
*/
|
|
139
|
+
create(input: IssueCreateInput): Promise<{
|
|
76
140
|
key: string;
|
|
141
|
+
dropped?: string[];
|
|
77
142
|
}>;
|
|
143
|
+
/** Changes an issue; see {@link updateGitHubIssue}. */
|
|
144
|
+
update(key: string, patch: IssuePatch): Promise<IssueUpdateResult>;
|
|
78
145
|
transition(key: string, slot: LifecycleSlot): Promise<LifecycleResult>;
|
|
146
|
+
/** Adds a comment to the issue with the given key. */
|
|
79
147
|
comment(key: string, body: string): Promise<void>;
|
|
148
|
+
/** Checks the authenticated user, the repo and the label-backed lifecycle slots, and reports what resolves. */
|
|
80
149
|
doctor(): Promise<TrackerDoctorReport>;
|
|
150
|
+
/** Reads issues with their comments, priority label, parent and blockers, for `holocron migrate`. */
|
|
151
|
+
export(selector: IssueSelector, info?: ExportInfo): Promise<IssueRecord[]>;
|
|
152
|
+
/** Makes the records as issues; one already made by an earlier run is skipped. */
|
|
153
|
+
import(records: IssueRecord[], options?: ImportOptions): Promise<ImportResult[]>;
|
|
154
|
+
/** Like `import`, and it also updates what an earlier import or sync made, for `holocron sync issues`. */
|
|
155
|
+
sync(records: IssueRecord[], options?: ImportOptions): Promise<SyncResult[]>;
|
|
156
|
+
listTypes(): Promise<IssueTypeInfo[] | undefined>;
|
|
157
|
+
createType(type: IssueTypeDeclaration): Promise<IssueTypeInfo>;
|
|
158
|
+
updateType(id: IssueTypeInfo["id"], patch: {
|
|
159
|
+
description?: string;
|
|
160
|
+
color?: string;
|
|
161
|
+
}): Promise<void>;
|
|
162
|
+
private fieldSetter;
|
|
163
|
+
/** What the field writers need; the setter is shared so the organization's field list is read once. */
|
|
164
|
+
private fieldContext;
|
|
81
165
|
private resolveMilestone;
|
|
82
166
|
private removeStatusLabels;
|
|
83
167
|
private mapIssue;
|
|
84
168
|
}
|
|
85
|
-
|
|
86
|
-
//#region src/capabilities/labels.d.ts
|
|
169
|
+
/** A label the repo is expected to have. */
|
|
87
170
|
interface CanonicalLabel {
|
|
171
|
+
/** The label's name. */
|
|
88
172
|
readonly name: string;
|
|
173
|
+
/** The label's color, as a hex string. */
|
|
89
174
|
readonly color: string;
|
|
175
|
+
/** The label's description. */
|
|
90
176
|
readonly description: string;
|
|
91
177
|
}
|
|
92
178
|
/**
|
|
@@ -97,36 +183,152 @@ interface CanonicalLabel {
|
|
|
97
183
|
* - DELETEs labels listed in `stale`.
|
|
98
184
|
* - Leaves unrecognised labels that aren't in `stale` untouched.
|
|
99
185
|
*/
|
|
100
|
-
declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
|
|
101
|
-
|
|
102
|
-
|
|
186
|
+
export declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
|
|
187
|
+
/** What the board reads on one pull request's head commit to decide its required checks. */
|
|
188
|
+
interface CommitChecks {
|
|
189
|
+
/** Every check run on the commit. */
|
|
190
|
+
checkRuns: SourceCheckRun[];
|
|
191
|
+
/** The commit's statuses; empty unless they were asked for. */
|
|
192
|
+
commitStatuses: SourceCommitStatus[];
|
|
193
|
+
}
|
|
194
|
+
/** Reads one commit's checks; `withStatuses` is true only when a required context may be a commit status. */
|
|
195
|
+
type CommitChecksReader = (repo: string, sha: string, withStatuses: boolean) => Promise<CommitChecks>;
|
|
196
|
+
/** Options of the GitHub `projects` capability. */
|
|
197
|
+
interface ProjectsOptions {
|
|
198
|
+
/** The repository the provider is configured for, as `owner/name`; its items get the short key `#N`. */
|
|
199
|
+
repo: string;
|
|
200
|
+
}
|
|
201
|
+
/** The GitHub implementation of the `projects` capability, backed by Projects v2. */
|
|
202
|
+
export declare class GitHubProjects implements Projects {
|
|
203
|
+
private readonly graphql;
|
|
204
|
+
private readonly readCommitChecks?;
|
|
205
|
+
/** Capability key, always `"projects"`. */
|
|
206
|
+
readonly key: "projects";
|
|
207
|
+
/** Provider name, always `"github"`. */
|
|
208
|
+
readonly providerName = "github";
|
|
209
|
+
private readonly repo;
|
|
210
|
+
constructor(graphql: GraphQLClient, opts: ProjectsOptions, readCommitChecks?: CommitChecksReader | undefined);
|
|
211
|
+
/** Every board of the organization, open and closed. */
|
|
212
|
+
list(owner: string): Promise<BoardSummary[]>;
|
|
213
|
+
/** The open board with exactly this name. */
|
|
214
|
+
find(owner: string, name: string): Promise<BoardSummary | undefined>;
|
|
215
|
+
/**
|
|
216
|
+
* Makes a board. With `template.source` naming an open board it is copied (fields, options, views and automation
|
|
217
|
+
* rules, no items); otherwise the board is created and brought in line with the template.
|
|
218
|
+
*/
|
|
219
|
+
create(owner: string, name: string, template: BoardTemplate): Promise<BoardSummary>;
|
|
220
|
+
/** Closes the board; `updateProjectV2` with `closed: true` is the only way, and reversible. */
|
|
221
|
+
close(_owner: string, board: BoardSummary): Promise<void>;
|
|
222
|
+
/** The live board: statuses, other fields, views and automation rules. */
|
|
223
|
+
read(_owner: string, board: BoardSummary): Promise<BoardState>;
|
|
224
|
+
/**
|
|
225
|
+
* Brings the board in line with the template. Never deletes a field, option or view, and never sends an option
|
|
226
|
+
* list without ids. Stops (throws) when the status field cannot be read.
|
|
227
|
+
*/
|
|
228
|
+
ensure(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<EnsureReport>;
|
|
229
|
+
/**
|
|
230
|
+
* Makes a single select field hold the wanted options in order, every existing one sent with its id. Options the
|
|
231
|
+
* template does not mention stay, after the wanted ones. Returns what changed (`Blocked added`, `order set`).
|
|
232
|
+
*/
|
|
233
|
+
private ensureOptions;
|
|
234
|
+
private createField;
|
|
235
|
+
private createView;
|
|
236
|
+
private updateView;
|
|
237
|
+
/**
|
|
238
|
+
* The board's issues and pull requests with their status, whether they are open and their open blockers. A second step
|
|
239
|
+
* then reads, one small query per issue, the pull requests that close each open issue a rule could still move (it has a
|
|
240
|
+
* status that is not `done` or `blocked` and no open blocker), each with the aggregate `ci / Required checks` state of
|
|
241
|
+
* its head commit. An issue whose read fails keeps no `pullRequests` and carries `pullRequestsProblem` instead.
|
|
242
|
+
*
|
|
243
|
+
* With `required` (a repo with no aggregate) each open pull request's `checks` is the verdict of those required
|
|
244
|
+
* checks on its head commit, read with one check-runs list per pull request (and its statuses only when a required
|
|
245
|
+
* context may be one); without it the read is the aggregate's, exactly as before.
|
|
246
|
+
*/
|
|
247
|
+
items(_owner: string, board: BoardSummary, template: BoardTemplate, required?: SourceRequiredChecks): Promise<BoardItem[]>;
|
|
248
|
+
/** Puts an item in a status; `transitioned` is false when it already is there. */
|
|
249
|
+
setStatus(_owner: string, board: BoardSummary, key: string, status: string): Promise<LifecycleResult>;
|
|
250
|
+
/**
|
|
251
|
+
* Puts the open items of `from` on `to` with their status and priority, only where the target has no value;
|
|
252
|
+
* closed and merged ones stay, and are set to the template's done status when theirs is not a done one.
|
|
253
|
+
*/
|
|
254
|
+
move(_owner: string, from: BoardSummary, to: BoardSummary, template: BoardTemplate): Promise<MoveReport>;
|
|
255
|
+
/**
|
|
256
|
+
* Puts issues on the board (`addProjectV2ItemById`, the content id the issue's node id) and sets Status and Priority
|
|
257
|
+
* through the single select update, only where the item has no value yet. A status or priority with no option on
|
|
258
|
+
* the board is reported in `dropped`; no option is ever created, so no value is cleared.
|
|
259
|
+
*/
|
|
260
|
+
addItems(_owner: string, board: BoardSummary, items: BoardItemInput[], template: BoardTemplate): Promise<AddedItem[]>;
|
|
261
|
+
/** The board's own status for an input: the option named like its status, else the template's status of its category. */
|
|
262
|
+
private statusFor;
|
|
263
|
+
/** The node id of an issue, which `addProjectV2ItemById` takes as the content id. */
|
|
264
|
+
private nodeId;
|
|
265
|
+
/** A `holocron doctor` smoke check: how many boards the token sees in the configured repository's organization. */
|
|
266
|
+
whoami(): Promise<{
|
|
267
|
+
ok: boolean;
|
|
268
|
+
boards: number;
|
|
269
|
+
}>;
|
|
270
|
+
/** Sets a single select value by option name; a field or option the board lacks is skipped. */
|
|
271
|
+
private setOption;
|
|
272
|
+
private ownerId;
|
|
273
|
+
private readRaw;
|
|
274
|
+
private fetchItems;
|
|
275
|
+
private keyOf;
|
|
276
|
+
private parseKey;
|
|
277
|
+
}
|
|
103
278
|
interface SecretsOptions {
|
|
104
279
|
repo: string;
|
|
105
280
|
}
|
|
106
|
-
|
|
281
|
+
/** The GitHub implementation of the `secrets` capability, covering repository, environment and organization secrets. */
|
|
282
|
+
export declare class GitHubSecrets implements Secrets {
|
|
107
283
|
private readonly client;
|
|
108
284
|
private readonly opts;
|
|
285
|
+
private readonly orgClient?;
|
|
286
|
+
/** Capability key, always `"secrets"`. */
|
|
109
287
|
readonly key: "secrets";
|
|
288
|
+
/** Provider name, always `"github"`. */
|
|
110
289
|
readonly providerName = "github";
|
|
111
|
-
|
|
290
|
+
/**
|
|
291
|
+
* `client` handles repo and environment scopes; `orgClient`, when given, handles
|
|
292
|
+
* the organization scope. They differ when a dedicated org-only token exists:
|
|
293
|
+
* it can write org secrets but not repo ones, and `github.admin` is the reverse.
|
|
294
|
+
*/
|
|
295
|
+
constructor(client: GitHubClient, opts: SecretsOptions, orgClient?: GitHubClient | undefined);
|
|
296
|
+
/** Repository name to numeric id, so one run asks GitHub once per repository however many secrets name it. */
|
|
297
|
+
private readonly repoIds;
|
|
298
|
+
private clientFor;
|
|
112
299
|
listSecrets(scope: SecretScope): Promise<string[]>;
|
|
113
300
|
setSecret(scope: SecretScope, name: string, value: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Who can read each organization secret, by name (never a value): `selected` ones come with the names of their
|
|
303
|
+
* repositories. Any other scope has no visibility and gives `{}`.
|
|
304
|
+
*/
|
|
305
|
+
listSecretAccess(scope: SecretScope): Promise<Record<string, SecretAccess>>;
|
|
306
|
+
/** The `visibility` (and repository ids) of an organization write. No `visibility` keeps the older default, `all`. */
|
|
307
|
+
private readers;
|
|
308
|
+
private repoId;
|
|
309
|
+
/** Deletes the named secret in the given scope. */
|
|
114
310
|
deleteSecret(scope: SecretScope, name: string): Promise<void>;
|
|
115
311
|
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/capabilities/source.d.ts
|
|
118
312
|
interface SourceOptions {
|
|
119
313
|
repo: string;
|
|
120
314
|
repoRoot: string;
|
|
121
315
|
/** Secondary client authenticated with HOLOCRON_ORG_TOKEN for org-scoped operations (teams, custom properties). */
|
|
122
316
|
orgClient?: GitHubClient;
|
|
317
|
+
/** Client for the files that link GitHub accounts to other services (HOLOCRON_USER_SYNC_TOKEN); falls back to the org client. */
|
|
318
|
+
userSyncClient?: GitHubClient;
|
|
123
319
|
/** Forwarded to a secondary client created for Pages calls (HOLOCRON_DEPLOY_TOKEN). */
|
|
124
320
|
baseUrl?: string;
|
|
125
321
|
fetch?: typeof fetch;
|
|
126
322
|
}
|
|
127
|
-
|
|
323
|
+
/**
|
|
324
|
+
* The GitHub implementation of the `source` capability: repo settings, rulesets, branch protection, security
|
|
325
|
+
* features and local workflow files.
|
|
326
|
+
*/
|
|
327
|
+
export declare class GitHubSource implements Source {
|
|
128
328
|
private readonly client;
|
|
329
|
+
/** Capability key, always `"source"`. */
|
|
129
330
|
readonly key: "source";
|
|
331
|
+
/** Provider name, always `"github"`. */
|
|
130
332
|
readonly providerName = "github";
|
|
131
333
|
private readonly owner;
|
|
132
334
|
private readonly name;
|
|
@@ -134,83 +336,145 @@ declare class GitHubSource implements Source {
|
|
|
134
336
|
private readonly repoRoot;
|
|
135
337
|
private readonly workflowDir;
|
|
136
338
|
private readonly orgClient?;
|
|
339
|
+
private readonly userSyncClient?;
|
|
137
340
|
private readonly baseUrl?;
|
|
138
341
|
private readonly fetchImpl?;
|
|
139
342
|
constructor(client: GitHubClient, opts: SourceOptions);
|
|
343
|
+
/**
|
|
344
|
+
* Makes the GitHub webhook for a relay source: on one repository with the admin token, or on the organization
|
|
345
|
+
* (`options.org`) with the organization token. Found by URL, events and `active` brought in line, nothing deleted.
|
|
346
|
+
*/
|
|
347
|
+
ensureRelaySource(input: EnsureRelaySourceInput): Promise<EnsureRelaySourceResult>;
|
|
348
|
+
/** Reads the relay source's webhook back, changing nothing. GitHub never returns the secret, so `hasSecret` is left out. */
|
|
349
|
+
inspectRelaySource(input: InspectRelaySourceInput): Promise<RelaySourceState>;
|
|
350
|
+
/** The organization token for an organization's webhook, the repository one otherwise. */
|
|
351
|
+
private relayClient;
|
|
140
352
|
whoami(): Promise<{
|
|
141
353
|
login: string;
|
|
142
354
|
}>;
|
|
355
|
+
/** Returns the repo's owner, name and default branch. */
|
|
143
356
|
getRepo(): Promise<RepoRef>;
|
|
357
|
+
/** Lists the repo's rulesets. */
|
|
144
358
|
listRulesets(): Promise<Ruleset[]>;
|
|
359
|
+
/** Creates a ruleset from the given payload. */
|
|
145
360
|
createRuleset(payload: Record<string, unknown>): Promise<Ruleset>;
|
|
361
|
+
/** Updates the ruleset with the given id from the payload. */
|
|
146
362
|
updateRuleset(id: number, payload: Record<string, unknown>): Promise<Ruleset>;
|
|
363
|
+
/** Updates the repo's settings. */
|
|
147
364
|
updateRepoSettings(settings: RepoSettings): Promise<void>;
|
|
148
365
|
protectBranch(branch: string, payload: Record<string, unknown>): Promise<void>;
|
|
366
|
+
/** Enables Dependabot vulnerability alerts. */
|
|
149
367
|
enableVulnerabilityAlerts(): Promise<void>;
|
|
368
|
+
/** Enables Dependabot automated security fixes. */
|
|
150
369
|
enableAutomatedSecurityFixes(): Promise<void>;
|
|
370
|
+
/** Enables secret scanning. */
|
|
151
371
|
enableSecretScanning(): Promise<void>;
|
|
152
372
|
enableCodeScanning(): Promise<string>;
|
|
153
373
|
disableDefaultCodeScanning(): Promise<void>;
|
|
154
374
|
enableDependencyGraph(): Promise<void>;
|
|
375
|
+
/** Enables private vulnerability reporting. */
|
|
155
376
|
enablePrivateVulnerabilityReporting(): Promise<void>;
|
|
377
|
+
/** Lists the `.yml` and `.yaml` files in `.github/workflows`, sorted by name; empty when the folder is missing. */
|
|
156
378
|
listWorkflowFiles(): Promise<string[]>;
|
|
379
|
+
/** Reads a workflow file's text, or `null` when it does not exist. */
|
|
157
380
|
readWorkflowFile(name: string): Promise<string | null>;
|
|
381
|
+
/** Writes a workflow file, creating `.github/workflows` first when needed. */
|
|
158
382
|
writeWorkflowFile(name: string, contents: string): Promise<void>;
|
|
383
|
+
/** Removes a workflow file; a file that is already gone is not an error. */
|
|
159
384
|
removeWorkflowFile(name: string): Promise<void>;
|
|
160
385
|
writeRepoFile(path: string, contents: string): Promise<void>;
|
|
161
386
|
syncLabels(canonical: ReadonlyArray<LabelDef>, stale: ReadonlyArray<string>): Promise<string>;
|
|
387
|
+
ensureLabels(labels: ReadonlyArray<LabelDef>): Promise<string>;
|
|
162
388
|
syncProperties(values: Record<string, string | string[]>): Promise<string>;
|
|
389
|
+
getOrgPropertyValues(name: string): Promise<string[] | undefined>;
|
|
390
|
+
addOrgPropertyValues(name: string, values: string[]): Promise<string[]>;
|
|
391
|
+
checkPropertyValues(values: Record<string, string | string[]>): Promise<string[] | undefined>;
|
|
163
392
|
syncTeams(teams: TeamEntry$1[]): Promise<string>;
|
|
393
|
+
teamMembers(teamSlug: string, org?: string): Promise<SourceTeamMember[]>;
|
|
394
|
+
readFile(path: string, repo?: string): Promise<SourceFile | null>;
|
|
395
|
+
writeFile(path: string, content: string, opts: {
|
|
396
|
+
message: string;
|
|
397
|
+
version?: string;
|
|
398
|
+
repo?: string;
|
|
399
|
+
}): Promise<void>;
|
|
164
400
|
syncTopics(topics: string[]): Promise<string>;
|
|
401
|
+
syncVariables(variables: Record<string, string>, opts?: {
|
|
402
|
+
prune?: boolean;
|
|
403
|
+
dryRun?: boolean;
|
|
404
|
+
}): Promise<string>;
|
|
405
|
+
syncOrgVariables(org: string, variables: Record<string, {
|
|
406
|
+
value: string;
|
|
407
|
+
visibility: "all" | "private";
|
|
408
|
+
}>, opts?: {
|
|
409
|
+
prune?: boolean;
|
|
410
|
+
dryRun?: boolean;
|
|
411
|
+
}): Promise<string>;
|
|
412
|
+
listVariables(): Promise<Record<string, string>>;
|
|
413
|
+
listOrgVariables(org: string): Promise<Record<string, {
|
|
414
|
+
value: string;
|
|
415
|
+
visibility: "all" | "private" | "selected";
|
|
416
|
+
}>>;
|
|
417
|
+
getRepoInfo(): Promise<SourceRepoInfo>;
|
|
418
|
+
getProperties(): Promise<Record<string, string | string[]>>;
|
|
419
|
+
listLabels(): Promise<LabelDef[]>;
|
|
420
|
+
countIssues(query: string, repo?: string): Promise<number>;
|
|
421
|
+
listTeamAccess(): Promise<Array<{
|
|
422
|
+
slug: string;
|
|
423
|
+
permission: TeamPermission$1;
|
|
424
|
+
}>>;
|
|
425
|
+
getRulesetDetail(id: number): Promise<SourceRulesetDetail>;
|
|
426
|
+
getSecurity(): Promise<SourceSecurity>;
|
|
165
427
|
syncDescription(description: string): Promise<string>;
|
|
166
428
|
syncHomepage(homepage: string): Promise<string>;
|
|
167
429
|
getPullRequest(number: number, repo?: string): Promise<PullRequest>;
|
|
430
|
+
listPullRequests(state: "open" | "closed", repo?: string): Promise<PullRequest[]>;
|
|
431
|
+
listBranches(repo?: string): Promise<SourceBranch[]>;
|
|
432
|
+
deleteBranch(name: string, repo?: string): Promise<void>;
|
|
433
|
+
listPullRequestCommits(number: number, repo?: string): Promise<string[]>;
|
|
434
|
+
listPullRequestFiles(number: number, repo?: string): Promise<string[]>;
|
|
435
|
+
createPullRequest(input: PullRequestInput, repo?: string): Promise<PullRequestResult>;
|
|
436
|
+
updatePullRequest(number: number, patch: PullRequestPatch, repo?: string): Promise<PullRequestResult>;
|
|
437
|
+
markReady(number: number, repo?: string): Promise<boolean>;
|
|
438
|
+
getPullRequestChecks(number: number, repo?: string, required?: SourceRequiredChecks): Promise<PullRequestChecks>;
|
|
439
|
+
listCheckRuns(ref: string, repo?: string): Promise<SourceCheckRun[]>;
|
|
440
|
+
listCommitStatuses(ref: string, repo?: string): Promise<SourceCommitStatus[]>;
|
|
441
|
+
createCheckRun(sha: string, name: string, write: SourceCheckRunWrite, repo?: string): Promise<number>;
|
|
442
|
+
updateCheckRun(id: number, write: SourceCheckRunWrite, repo?: string): Promise<void>;
|
|
168
443
|
configurePages(config: PagesConfig, token: string): Promise<void>;
|
|
169
444
|
}
|
|
170
|
-
|
|
171
|
-
//#region src/capabilities/teams.d.ts
|
|
445
|
+
/** A team entry with the permission spelled out. */
|
|
172
446
|
interface NormalizedTeamEntry {
|
|
447
|
+
/** The team's slug. */
|
|
173
448
|
slug: string;
|
|
449
|
+
/** The permission the team gets on the repo. */
|
|
174
450
|
permission: TeamPermission;
|
|
175
451
|
}
|
|
176
|
-
|
|
177
|
-
declare function
|
|
178
|
-
|
|
179
|
-
|
|
452
|
+
/** Turns a team entry into slug and permission form; a bare slug gets `push`. */
|
|
453
|
+
export declare function normalizeTeamEntry(entry: TeamEntry): NormalizedTeamEntry;
|
|
454
|
+
/** Grants each team access to the repo and reports the outcome; throws when every team fails. */
|
|
455
|
+
export declare function syncTeams(client: GitHubClient, repo: string, teams: TeamEntry[]): Promise<string>;
|
|
180
456
|
/**
|
|
181
457
|
* Encrypt `value` for the given GitHub-provided base64 public key.
|
|
182
458
|
* Returns the base64 ciphertext to send as `encrypted_value`.
|
|
183
459
|
*/
|
|
184
|
-
declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/verify-token.d.ts
|
|
460
|
+
export declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
187
461
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* Kept as a standalone function (not a capability method) so the auth
|
|
193
|
-
* command can call it without initializing the full plugin — plugin
|
|
194
|
-
* construction requires an already-resolved token, which is exactly
|
|
195
|
-
* what we don't have yet at bootstrap time.
|
|
462
|
+
* Every token this plugin takes, for `holocron doctor tokens`, with what each layer's token must and must not be able
|
|
463
|
+
* to do. The release token is `optional`: only CI's release workflow reads it (from the org secret), so a development
|
|
464
|
+
* environment has no reason to hold it.
|
|
196
465
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
subject: string;
|
|
200
|
-
}
|
|
201
|
-
interface VerifyTokenFailure {
|
|
202
|
-
ok: false;
|
|
203
|
-
message: string;
|
|
204
|
-
}
|
|
205
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
466
|
+
export declare const tokens: PluginToken[];
|
|
467
|
+
/** Options for `verifyToken`. */
|
|
206
468
|
interface VerifyTokenOptions {
|
|
469
|
+
/** Overrides the API base URL, for tests. */
|
|
207
470
|
baseUrl?: string;
|
|
471
|
+
/** Overrides `fetch`, for tests. */
|
|
208
472
|
fetch?: typeof fetch;
|
|
209
473
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
interface GitHubPluginOptions extends ResolveTokenInput {
|
|
474
|
+
/** Checks a token against `GET /user` and returns who it belongs to, or why it failed. */
|
|
475
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
476
|
+
/** Options for the GitHub plugin. */
|
|
477
|
+
export interface GitHubPluginOptions extends ResolveTokenInput {
|
|
214
478
|
/** "owner/name" — e.g., "theholocron/holocron". Required. */
|
|
215
479
|
repo: string;
|
|
216
480
|
/** Absolute path to the working repo root. Used by `source`'s
|
|
@@ -218,39 +482,68 @@ interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
218
482
|
repoRoot?: string;
|
|
219
483
|
/** Lifecycle slot → label name. Used by the `issues` capability. */
|
|
220
484
|
labels?: {
|
|
485
|
+
/** Label that marks an issue as in progress. */
|
|
221
486
|
inProgress: string;
|
|
487
|
+
/** Label that marks an issue as in review. */
|
|
222
488
|
inReview: string;
|
|
223
489
|
};
|
|
490
|
+
/** `repo.labels` (the area map), handed in by the loader for the `issue-types` probe. */
|
|
491
|
+
areaLabels?: LabelsConfig;
|
|
492
|
+
/** The organization's issue Types (`issueTypes`, #2512), handed in by the loader: the names a kind is written as. */
|
|
493
|
+
issueTypes?: ReadonlyArray<{
|
|
494
|
+
name: string;
|
|
495
|
+
}>;
|
|
496
|
+
/** The token `provider github whoami` describes, by environment variable (default `HOLOCRON_READ_TOKEN`). */
|
|
497
|
+
whoamiToken?: string;
|
|
224
498
|
/** Override base URL for tests. Defaults to https://api.github.com. */
|
|
225
499
|
baseUrl?: string;
|
|
226
500
|
/** Override `fetch` for tests. Defaults to global `fetch`. */
|
|
227
501
|
fetch?: typeof fetch;
|
|
228
502
|
}
|
|
229
|
-
|
|
503
|
+
/** What the capability factories receive: the plugin options, a client, the repo and its root. */
|
|
504
|
+
export interface PluginContext {
|
|
505
|
+
/** The plugin options. */
|
|
230
506
|
options: GitHubPluginOptions;
|
|
507
|
+
/** The GitHub client the capability uses. */
|
|
231
508
|
client: GitHubClient;
|
|
509
|
+
/** The repo as `owner/name`. */
|
|
232
510
|
repo: string;
|
|
511
|
+
/** Absolute path to the working repo root. */
|
|
233
512
|
repoRoot: string;
|
|
234
513
|
}
|
|
235
|
-
|
|
236
|
-
declare function
|
|
237
|
-
|
|
238
|
-
declare function
|
|
239
|
-
|
|
240
|
-
declare function
|
|
514
|
+
/** Builds the `source` capability; the optional clients cover org-level and user-sync access. */
|
|
515
|
+
export declare function source(ctx: PluginContext, orgClient?: GitHubClient, userSyncClient?: GitHubClient): Source;
|
|
516
|
+
/** Builds the `secrets` capability; the optional client handles organization secrets. */
|
|
517
|
+
export declare function secrets(ctx: PluginContext, orgClient?: GitHubClient): Secrets;
|
|
518
|
+
/** Builds the `environments` capability. */
|
|
519
|
+
export declare function environments(ctx: PluginContext): Environments;
|
|
520
|
+
/** Builds the `ci` capability. */
|
|
521
|
+
export declare function ci(ctx: PluginContext): Ci;
|
|
522
|
+
/** Builds the `issues` capability, passing the lifecycle labels when configured. */
|
|
523
|
+
export declare function issues(ctx: PluginContext, orgClient?: () => GitHubClient | undefined): Issues;
|
|
524
|
+
/** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
|
|
525
|
+
export declare function projects(ctx: PluginContext): Projects;
|
|
526
|
+
/** Creates the plugin, resolving a token per capability when it is first used. */
|
|
527
|
+
export declare function createPlugin(options: GitHubPluginOptions): {
|
|
241
528
|
name: string;
|
|
529
|
+
probes: {
|
|
530
|
+
token: import("@theholocron/cli").Probe;
|
|
531
|
+
"issue-types": import("@theholocron/cli").Probe;
|
|
532
|
+
connection: import("@theholocron/cli").Probe;
|
|
533
|
+
};
|
|
534
|
+
whoami: import("@theholocron/cli").ProviderAction;
|
|
242
535
|
capabilities: {
|
|
243
536
|
source: () => Source;
|
|
244
537
|
ci: () => Ci;
|
|
245
538
|
secrets: () => Secrets;
|
|
246
539
|
environments: () => Environments;
|
|
247
540
|
issues: () => Issues;
|
|
541
|
+
projects: () => Projects;
|
|
248
542
|
};
|
|
249
543
|
};
|
|
250
544
|
/**
|
|
251
|
-
* One-line hint printed by `holocron
|
|
545
|
+
* One-line hint printed by `holocron new token github` when no token
|
|
252
546
|
* is supplied or the supplied token is rejected.
|
|
253
547
|
*/
|
|
254
|
-
declare const AUTH_HINT: string;
|
|
255
|
-
|
|
256
|
-
export { AUTH_HINT, type Auth, AuthError, type CanonicalLabel, GitHubCi, type GitHubClientOptions, GitHubEnvironments, GitHubIssues, GitHubPluginOptions, GitHubSecrets, GitHubSource, type NormalizedTeamEntry, PluginContext, type ResolveTokenInput, type TeamEntry, type TeamPermission, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, ci, createFeatureResolver, createGitHubClient, createPlugin, encryptSecret, environments, issues, normalizeTeamEntry, resolveAdminToken, resolveDeployToken, resolveIssuesToken, resolveOrgToken, resolveReadToken, resolveReleaseToken, resolveSyncToken, secrets, source, syncLabels, syncTeams, verifyToken };
|
|
548
|
+
export declare const AUTH_HINT: string;
|
|
549
|
+
export { type Auth, AuthError, type CanonicalLabel, type GitHubClientOptions, type NormalizedTeamEntry, type ProjectsOptions, type ResolveTokenInput, type TeamEntry, type TeamPermission, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createFeatureResolver, createGitHubClient };
|