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