@theholocron/holocron-plugin-github 5.0.0-alpha.54 → 5.0.0-alpha.541
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 +351 -76
- package/dist/index.mjs +3920 -154
- 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, 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,138 @@ 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
|
+
/** Options of the GitHub `projects` capability. */
|
|
188
|
+
interface ProjectsOptions {
|
|
189
|
+
/** The repository the provider is configured for, as `owner/name`; its items get the short key `#N`. */
|
|
190
|
+
repo: string;
|
|
191
|
+
}
|
|
192
|
+
/** The GitHub implementation of the `projects` capability, backed by Projects v2. */
|
|
193
|
+
export declare class GitHubProjects implements Projects {
|
|
194
|
+
private readonly graphql;
|
|
195
|
+
/** Capability key, always `"projects"`. */
|
|
196
|
+
readonly key: "projects";
|
|
197
|
+
/** Provider name, always `"github"`. */
|
|
198
|
+
readonly providerName = "github";
|
|
199
|
+
private readonly repo;
|
|
200
|
+
constructor(graphql: GraphQLClient, opts: ProjectsOptions);
|
|
201
|
+
/** Every board of the organization, open and closed. */
|
|
202
|
+
list(owner: string): Promise<BoardSummary[]>;
|
|
203
|
+
/** The open board with exactly this name. */
|
|
204
|
+
find(owner: string, name: string): Promise<BoardSummary | undefined>;
|
|
205
|
+
/**
|
|
206
|
+
* Makes a board. With `template.source` naming an open board it is copied (fields, options, views and automation
|
|
207
|
+
* rules, no items); otherwise the board is created and brought in line with the template.
|
|
208
|
+
*/
|
|
209
|
+
create(owner: string, name: string, template: BoardTemplate): Promise<BoardSummary>;
|
|
210
|
+
/** Closes the board; `updateProjectV2` with `closed: true` is the only way, and reversible. */
|
|
211
|
+
close(_owner: string, board: BoardSummary): Promise<void>;
|
|
212
|
+
/** The live board: statuses, other fields, views and automation rules. */
|
|
213
|
+
read(_owner: string, board: BoardSummary): Promise<BoardState>;
|
|
214
|
+
/**
|
|
215
|
+
* Brings the board in line with the template. Never deletes a field, option or view, and never sends an option
|
|
216
|
+
* list without ids. Stops (throws) when the status field cannot be read.
|
|
217
|
+
*/
|
|
218
|
+
ensure(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<EnsureReport>;
|
|
219
|
+
/**
|
|
220
|
+
* Makes a single select field hold the wanted options in order, every existing one sent with its id. Options the
|
|
221
|
+
* template does not mention stay, after the wanted ones. Returns what changed (`Blocked added`, `order set`).
|
|
222
|
+
*/
|
|
223
|
+
private ensureOptions;
|
|
224
|
+
private createField;
|
|
225
|
+
private createView;
|
|
226
|
+
private updateView;
|
|
227
|
+
/**
|
|
228
|
+
* The board's issues and pull requests with their status, whether they are open and their open blockers. A second step
|
|
229
|
+
* then reads, one small query per issue, the pull requests that close each open issue a rule could still move (it has a
|
|
230
|
+
* status that is not `done` or `blocked` and no open blocker), each with the aggregate `ci / Required checks` state of
|
|
231
|
+
* its head commit. An issue whose read fails keeps no `pullRequests` and carries `pullRequestsProblem` instead.
|
|
232
|
+
*/
|
|
233
|
+
items(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<BoardItem[]>;
|
|
234
|
+
/** Puts an item in a status; `transitioned` is false when it already is there. */
|
|
235
|
+
setStatus(_owner: string, board: BoardSummary, key: string, status: string): Promise<LifecycleResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Puts the open items of `from` on `to` with their status and priority, only where the target has no value;
|
|
238
|
+
* closed and merged ones stay, and are set to the template's done status when theirs is not a done one.
|
|
239
|
+
*/
|
|
240
|
+
move(_owner: string, from: BoardSummary, to: BoardSummary, template: BoardTemplate): Promise<MoveReport>;
|
|
241
|
+
/**
|
|
242
|
+
* Puts issues on the board (`addProjectV2ItemById`, the content id the issue's node id) and sets Status and Priority
|
|
243
|
+
* through the single select update, only where the item has no value yet. A status or priority with no option on
|
|
244
|
+
* the board is reported in `dropped`; no option is ever created, so no value is cleared.
|
|
245
|
+
*/
|
|
246
|
+
addItems(_owner: string, board: BoardSummary, items: BoardItemInput[], template: BoardTemplate): Promise<AddedItem[]>;
|
|
247
|
+
/** The board's own status for an input: the option named like its status, else the template's status of its category. */
|
|
248
|
+
private statusFor;
|
|
249
|
+
/** The node id of an issue, which `addProjectV2ItemById` takes as the content id. */
|
|
250
|
+
private nodeId;
|
|
251
|
+
/** A `holocron doctor` smoke check: how many boards the token sees in the configured repository's organization. */
|
|
252
|
+
whoami(): Promise<{
|
|
253
|
+
ok: boolean;
|
|
254
|
+
boards: number;
|
|
255
|
+
}>;
|
|
256
|
+
/** Sets a single select value by option name; a field or option the board lacks is skipped. */
|
|
257
|
+
private setOption;
|
|
258
|
+
private ownerId;
|
|
259
|
+
private readRaw;
|
|
260
|
+
private fetchItems;
|
|
261
|
+
private keyOf;
|
|
262
|
+
private parseKey;
|
|
263
|
+
}
|
|
103
264
|
interface SecretsOptions {
|
|
104
265
|
repo: string;
|
|
105
266
|
}
|
|
106
|
-
|
|
267
|
+
/** The GitHub implementation of the `secrets` capability, covering repository, environment and organization secrets. */
|
|
268
|
+
export declare class GitHubSecrets implements Secrets {
|
|
107
269
|
private readonly client;
|
|
108
270
|
private readonly opts;
|
|
271
|
+
private readonly orgClient?;
|
|
272
|
+
/** Capability key, always `"secrets"`. */
|
|
109
273
|
readonly key: "secrets";
|
|
274
|
+
/** Provider name, always `"github"`. */
|
|
110
275
|
readonly providerName = "github";
|
|
111
|
-
|
|
276
|
+
/**
|
|
277
|
+
* `client` handles repo and environment scopes; `orgClient`, when given, handles
|
|
278
|
+
* the organization scope. They differ when a dedicated org-only token exists:
|
|
279
|
+
* it can write org secrets but not repo ones, and `github.admin` is the reverse.
|
|
280
|
+
*/
|
|
281
|
+
constructor(client: GitHubClient, opts: SecretsOptions, orgClient?: GitHubClient | undefined);
|
|
282
|
+
/** Repository name to numeric id, so one run asks GitHub once per repository however many secrets name it. */
|
|
283
|
+
private readonly repoIds;
|
|
284
|
+
private clientFor;
|
|
112
285
|
listSecrets(scope: SecretScope): Promise<string[]>;
|
|
113
286
|
setSecret(scope: SecretScope, name: string, value: string): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* Who can read each organization secret, by name (never a value): `selected` ones come with the names of their
|
|
289
|
+
* repositories. Any other scope has no visibility and gives `{}`.
|
|
290
|
+
*/
|
|
291
|
+
listSecretAccess(scope: SecretScope): Promise<Record<string, SecretAccess>>;
|
|
292
|
+
/** The `visibility` (and repository ids) of an organization write. No `visibility` keeps the older default, `all`. */
|
|
293
|
+
private readers;
|
|
294
|
+
private repoId;
|
|
295
|
+
/** Deletes the named secret in the given scope. */
|
|
114
296
|
deleteSecret(scope: SecretScope, name: string): Promise<void>;
|
|
115
297
|
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/capabilities/source.d.ts
|
|
118
298
|
interface SourceOptions {
|
|
119
299
|
repo: string;
|
|
120
300
|
repoRoot: string;
|
|
121
301
|
/** Secondary client authenticated with HOLOCRON_ORG_TOKEN for org-scoped operations (teams, custom properties). */
|
|
122
302
|
orgClient?: GitHubClient;
|
|
303
|
+
/** Client for the files that link GitHub accounts to other services (HOLOCRON_USER_SYNC_TOKEN); falls back to the org client. */
|
|
304
|
+
userSyncClient?: GitHubClient;
|
|
123
305
|
/** Forwarded to a secondary client created for Pages calls (HOLOCRON_DEPLOY_TOKEN). */
|
|
124
306
|
baseUrl?: string;
|
|
125
307
|
fetch?: typeof fetch;
|
|
126
308
|
}
|
|
127
|
-
|
|
309
|
+
/**
|
|
310
|
+
* The GitHub implementation of the `source` capability: repo settings, rulesets, branch protection, security
|
|
311
|
+
* features and local workflow files.
|
|
312
|
+
*/
|
|
313
|
+
export declare class GitHubSource implements Source {
|
|
128
314
|
private readonly client;
|
|
315
|
+
/** Capability key, always `"source"`. */
|
|
129
316
|
readonly key: "source";
|
|
317
|
+
/** Provider name, always `"github"`. */
|
|
130
318
|
readonly providerName = "github";
|
|
131
319
|
private readonly owner;
|
|
132
320
|
private readonly name;
|
|
@@ -134,83 +322,144 @@ declare class GitHubSource implements Source {
|
|
|
134
322
|
private readonly repoRoot;
|
|
135
323
|
private readonly workflowDir;
|
|
136
324
|
private readonly orgClient?;
|
|
325
|
+
private readonly userSyncClient?;
|
|
137
326
|
private readonly baseUrl?;
|
|
138
327
|
private readonly fetchImpl?;
|
|
139
328
|
constructor(client: GitHubClient, opts: SourceOptions);
|
|
329
|
+
/**
|
|
330
|
+
* Makes the GitHub webhook for a relay source: on one repository with the admin token, or on the organization
|
|
331
|
+
* (`options.org`) with the organization token. Found by URL, events and `active` brought in line, nothing deleted.
|
|
332
|
+
*/
|
|
333
|
+
ensureRelaySource(input: EnsureRelaySourceInput): Promise<EnsureRelaySourceResult>;
|
|
334
|
+
/** Reads the relay source's webhook back, changing nothing. GitHub never returns the secret, so `hasSecret` is left out. */
|
|
335
|
+
inspectRelaySource(input: InspectRelaySourceInput): Promise<RelaySourceState>;
|
|
336
|
+
/** The organization token for an organization's webhook, the repository one otherwise. */
|
|
337
|
+
private relayClient;
|
|
140
338
|
whoami(): Promise<{
|
|
141
339
|
login: string;
|
|
142
340
|
}>;
|
|
341
|
+
/** Returns the repo's owner, name and default branch. */
|
|
143
342
|
getRepo(): Promise<RepoRef>;
|
|
343
|
+
/** Lists the repo's rulesets. */
|
|
144
344
|
listRulesets(): Promise<Ruleset[]>;
|
|
345
|
+
/** Creates a ruleset from the given payload. */
|
|
145
346
|
createRuleset(payload: Record<string, unknown>): Promise<Ruleset>;
|
|
347
|
+
/** Updates the ruleset with the given id from the payload. */
|
|
146
348
|
updateRuleset(id: number, payload: Record<string, unknown>): Promise<Ruleset>;
|
|
349
|
+
/** Updates the repo's settings. */
|
|
147
350
|
updateRepoSettings(settings: RepoSettings): Promise<void>;
|
|
148
351
|
protectBranch(branch: string, payload: Record<string, unknown>): Promise<void>;
|
|
352
|
+
/** Enables Dependabot vulnerability alerts. */
|
|
149
353
|
enableVulnerabilityAlerts(): Promise<void>;
|
|
354
|
+
/** Enables Dependabot automated security fixes. */
|
|
150
355
|
enableAutomatedSecurityFixes(): Promise<void>;
|
|
356
|
+
/** Enables secret scanning. */
|
|
151
357
|
enableSecretScanning(): Promise<void>;
|
|
152
358
|
enableCodeScanning(): Promise<string>;
|
|
153
359
|
disableDefaultCodeScanning(): Promise<void>;
|
|
154
360
|
enableDependencyGraph(): Promise<void>;
|
|
361
|
+
/** Enables private vulnerability reporting. */
|
|
155
362
|
enablePrivateVulnerabilityReporting(): Promise<void>;
|
|
363
|
+
/** Lists the `.yml` and `.yaml` files in `.github/workflows`, sorted by name; empty when the folder is missing. */
|
|
156
364
|
listWorkflowFiles(): Promise<string[]>;
|
|
365
|
+
/** Reads a workflow file's text, or `null` when it does not exist. */
|
|
157
366
|
readWorkflowFile(name: string): Promise<string | null>;
|
|
367
|
+
/** Writes a workflow file, creating `.github/workflows` first when needed. */
|
|
158
368
|
writeWorkflowFile(name: string, contents: string): Promise<void>;
|
|
369
|
+
/** Removes a workflow file; a file that is already gone is not an error. */
|
|
159
370
|
removeWorkflowFile(name: string): Promise<void>;
|
|
160
371
|
writeRepoFile(path: string, contents: string): Promise<void>;
|
|
161
372
|
syncLabels(canonical: ReadonlyArray<LabelDef>, stale: ReadonlyArray<string>): Promise<string>;
|
|
373
|
+
ensureLabels(labels: ReadonlyArray<LabelDef>): Promise<string>;
|
|
162
374
|
syncProperties(values: Record<string, string | string[]>): Promise<string>;
|
|
375
|
+
getOrgPropertyValues(name: string): Promise<string[] | undefined>;
|
|
376
|
+
addOrgPropertyValues(name: string, values: string[]): Promise<string[]>;
|
|
377
|
+
checkPropertyValues(values: Record<string, string | string[]>): Promise<string[] | undefined>;
|
|
163
378
|
syncTeams(teams: TeamEntry$1[]): Promise<string>;
|
|
379
|
+
teamMembers(teamSlug: string, org?: string): Promise<SourceTeamMember[]>;
|
|
380
|
+
readFile(path: string, repo?: string): Promise<SourceFile | null>;
|
|
381
|
+
writeFile(path: string, content: string, opts: {
|
|
382
|
+
message: string;
|
|
383
|
+
version?: string;
|
|
384
|
+
repo?: string;
|
|
385
|
+
}): Promise<void>;
|
|
164
386
|
syncTopics(topics: string[]): Promise<string>;
|
|
387
|
+
syncVariables(variables: Record<string, string>, opts?: {
|
|
388
|
+
prune?: boolean;
|
|
389
|
+
dryRun?: boolean;
|
|
390
|
+
}): Promise<string>;
|
|
391
|
+
syncOrgVariables(org: string, variables: Record<string, {
|
|
392
|
+
value: string;
|
|
393
|
+
visibility: "all" | "private";
|
|
394
|
+
}>, opts?: {
|
|
395
|
+
prune?: boolean;
|
|
396
|
+
dryRun?: boolean;
|
|
397
|
+
}): Promise<string>;
|
|
398
|
+
listVariables(): Promise<Record<string, string>>;
|
|
399
|
+
listOrgVariables(org: string): Promise<Record<string, {
|
|
400
|
+
value: string;
|
|
401
|
+
visibility: "all" | "private" | "selected";
|
|
402
|
+
}>>;
|
|
403
|
+
getRepoInfo(): Promise<SourceRepoInfo>;
|
|
404
|
+
getProperties(): Promise<Record<string, string | string[]>>;
|
|
405
|
+
listLabels(): Promise<LabelDef[]>;
|
|
406
|
+
listTeamAccess(): Promise<Array<{
|
|
407
|
+
slug: string;
|
|
408
|
+
permission: TeamPermission$1;
|
|
409
|
+
}>>;
|
|
410
|
+
getRulesetDetail(id: number): Promise<SourceRulesetDetail>;
|
|
411
|
+
getSecurity(): Promise<SourceSecurity>;
|
|
165
412
|
syncDescription(description: string): Promise<string>;
|
|
166
413
|
syncHomepage(homepage: string): Promise<string>;
|
|
167
414
|
getPullRequest(number: number, repo?: string): Promise<PullRequest>;
|
|
415
|
+
listPullRequests(state: "open" | "closed", repo?: string): Promise<PullRequest[]>;
|
|
416
|
+
listBranches(repo?: string): Promise<SourceBranch[]>;
|
|
417
|
+
deleteBranch(name: string, repo?: string): Promise<void>;
|
|
418
|
+
listPullRequestCommits(number: number, repo?: string): Promise<string[]>;
|
|
419
|
+
listPullRequestFiles(number: number, repo?: string): Promise<string[]>;
|
|
420
|
+
createPullRequest(input: PullRequestInput, repo?: string): Promise<PullRequestResult>;
|
|
421
|
+
updatePullRequest(number: number, patch: PullRequestPatch, repo?: string): Promise<PullRequestResult>;
|
|
422
|
+
markReady(number: number, repo?: string): Promise<boolean>;
|
|
423
|
+
getPullRequestChecks(number: number, repo?: string): Promise<PullRequestChecks>;
|
|
424
|
+
listCheckRuns(ref: string, repo?: string): Promise<SourceCheckRun[]>;
|
|
425
|
+
listCommitStatuses(ref: string, repo?: string): Promise<SourceCommitStatus[]>;
|
|
426
|
+
createCheckRun(sha: string, name: string, write: SourceCheckRunWrite, repo?: string): Promise<number>;
|
|
427
|
+
updateCheckRun(id: number, write: SourceCheckRunWrite, repo?: string): Promise<void>;
|
|
168
428
|
configurePages(config: PagesConfig, token: string): Promise<void>;
|
|
169
429
|
}
|
|
170
|
-
|
|
171
|
-
//#region src/capabilities/teams.d.ts
|
|
430
|
+
/** A team entry with the permission spelled out. */
|
|
172
431
|
interface NormalizedTeamEntry {
|
|
432
|
+
/** The team's slug. */
|
|
173
433
|
slug: string;
|
|
434
|
+
/** The permission the team gets on the repo. */
|
|
174
435
|
permission: TeamPermission;
|
|
175
436
|
}
|
|
176
|
-
|
|
177
|
-
declare function
|
|
178
|
-
|
|
179
|
-
|
|
437
|
+
/** Turns a team entry into slug and permission form; a bare slug gets `push`. */
|
|
438
|
+
export declare function normalizeTeamEntry(entry: TeamEntry): NormalizedTeamEntry;
|
|
439
|
+
/** Grants each team access to the repo and reports the outcome; throws when every team fails. */
|
|
440
|
+
export declare function syncTeams(client: GitHubClient, repo: string, teams: TeamEntry[]): Promise<string>;
|
|
180
441
|
/**
|
|
181
442
|
* Encrypt `value` for the given GitHub-provided base64 public key.
|
|
182
443
|
* Returns the base64 ciphertext to send as `encrypted_value`.
|
|
183
444
|
*/
|
|
184
|
-
declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/verify-token.d.ts
|
|
445
|
+
export declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
187
446
|
/**
|
|
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.
|
|
447
|
+
* Every token this plugin takes, for `holocron doctor tokens`, with what each layer's token must and must not be able
|
|
448
|
+
* to do. The release token is `optional`: only CI's release workflow reads it (from the org secret), so a development
|
|
449
|
+
* environment has no reason to hold it.
|
|
196
450
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
subject: string;
|
|
200
|
-
}
|
|
201
|
-
interface VerifyTokenFailure {
|
|
202
|
-
ok: false;
|
|
203
|
-
message: string;
|
|
204
|
-
}
|
|
205
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
451
|
+
export declare const tokens: PluginToken[];
|
|
452
|
+
/** Options for `verifyToken`. */
|
|
206
453
|
interface VerifyTokenOptions {
|
|
454
|
+
/** Overrides the API base URL, for tests. */
|
|
207
455
|
baseUrl?: string;
|
|
456
|
+
/** Overrides `fetch`, for tests. */
|
|
208
457
|
fetch?: typeof fetch;
|
|
209
458
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
interface GitHubPluginOptions extends ResolveTokenInput {
|
|
459
|
+
/** Checks a token against `GET /user` and returns who it belongs to, or why it failed. */
|
|
460
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
461
|
+
/** Options for the GitHub plugin. */
|
|
462
|
+
export interface GitHubPluginOptions extends ResolveTokenInput {
|
|
214
463
|
/** "owner/name" — e.g., "theholocron/holocron". Required. */
|
|
215
464
|
repo: string;
|
|
216
465
|
/** Absolute path to the working repo root. Used by `source`'s
|
|
@@ -218,39 +467,65 @@ interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
218
467
|
repoRoot?: string;
|
|
219
468
|
/** Lifecycle slot → label name. Used by the `issues` capability. */
|
|
220
469
|
labels?: {
|
|
470
|
+
/** Label that marks an issue as in progress. */
|
|
221
471
|
inProgress: string;
|
|
472
|
+
/** Label that marks an issue as in review. */
|
|
222
473
|
inReview: string;
|
|
223
474
|
};
|
|
475
|
+
/** `repo.labels` (the area map), handed in by the loader for the `issue-types` probe. */
|
|
476
|
+
areaLabels?: LabelsConfig;
|
|
477
|
+
/** The organization's issue Types (`issueTypes`, #2512), handed in by the loader: the names a kind is written as. */
|
|
478
|
+
issueTypes?: ReadonlyArray<{
|
|
479
|
+
name: string;
|
|
480
|
+
}>;
|
|
224
481
|
/** Override base URL for tests. Defaults to https://api.github.com. */
|
|
225
482
|
baseUrl?: string;
|
|
226
483
|
/** Override `fetch` for tests. Defaults to global `fetch`. */
|
|
227
484
|
fetch?: typeof fetch;
|
|
228
485
|
}
|
|
229
|
-
|
|
486
|
+
/** What the capability factories receive: the plugin options, a client, the repo and its root. */
|
|
487
|
+
export interface PluginContext {
|
|
488
|
+
/** The plugin options. */
|
|
230
489
|
options: GitHubPluginOptions;
|
|
490
|
+
/** The GitHub client the capability uses. */
|
|
231
491
|
client: GitHubClient;
|
|
492
|
+
/** The repo as `owner/name`. */
|
|
232
493
|
repo: string;
|
|
494
|
+
/** Absolute path to the working repo root. */
|
|
233
495
|
repoRoot: string;
|
|
234
496
|
}
|
|
235
|
-
|
|
236
|
-
declare function
|
|
237
|
-
|
|
238
|
-
declare function
|
|
239
|
-
|
|
240
|
-
declare function
|
|
497
|
+
/** Builds the `source` capability; the optional clients cover org-level and user-sync access. */
|
|
498
|
+
export declare function source(ctx: PluginContext, orgClient?: GitHubClient, userSyncClient?: GitHubClient): Source;
|
|
499
|
+
/** Builds the `secrets` capability; the optional client handles organization secrets. */
|
|
500
|
+
export declare function secrets(ctx: PluginContext, orgClient?: GitHubClient): Secrets;
|
|
501
|
+
/** Builds the `environments` capability. */
|
|
502
|
+
export declare function environments(ctx: PluginContext): Environments;
|
|
503
|
+
/** Builds the `ci` capability. */
|
|
504
|
+
export declare function ci(ctx: PluginContext): Ci;
|
|
505
|
+
/** Builds the `issues` capability, passing the lifecycle labels when configured. */
|
|
506
|
+
export declare function issues(ctx: PluginContext, orgClient?: () => GitHubClient | undefined): Issues;
|
|
507
|
+
/** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
|
|
508
|
+
export declare function projects(ctx: PluginContext): Projects;
|
|
509
|
+
/** Creates the plugin, resolving a token per capability when it is first used. */
|
|
510
|
+
export declare function createPlugin(options: GitHubPluginOptions): {
|
|
241
511
|
name: string;
|
|
512
|
+
probes: {
|
|
513
|
+
token: import("@theholocron/cli").Probe;
|
|
514
|
+
"issue-types": import("@theholocron/cli").Probe;
|
|
515
|
+
connection: import("@theholocron/cli").Probe;
|
|
516
|
+
};
|
|
242
517
|
capabilities: {
|
|
243
518
|
source: () => Source;
|
|
244
519
|
ci: () => Ci;
|
|
245
520
|
secrets: () => Secrets;
|
|
246
521
|
environments: () => Environments;
|
|
247
522
|
issues: () => Issues;
|
|
523
|
+
projects: () => Projects;
|
|
248
524
|
};
|
|
249
525
|
};
|
|
250
526
|
/**
|
|
251
|
-
* One-line hint printed by `holocron
|
|
527
|
+
* One-line hint printed by `holocron new token github` when no token
|
|
252
528
|
* is supplied or the supplied token is rejected.
|
|
253
529
|
*/
|
|
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 };
|
|
530
|
+
export declare const AUTH_HINT: string;
|
|
531
|
+
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 };
|