@theholocron/holocron-plugin-github 5.0.0-alpha.37 → 5.0.0-alpha.371
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 +28 -3
- package/dist/index.d.mts +236 -71
- package/dist/index.mjs +1308 -68
- package/package.json +29 -25
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# `@theholocron/holocron-plugin-github`
|
|
2
2
|
|
|
3
|
-
GitHub plugin for [Holocron](../cli). Implements
|
|
4
|
-
against the GitHub REST
|
|
3
|
+
GitHub plugin for [Holocron](../cli). Implements six capabilities
|
|
4
|
+
against the GitHub REST and GraphQL APIs:
|
|
5
5
|
|
|
6
6
|
| Capability | What this plugin does |
|
|
7
7
|
| -------------- | ---------------------------------------------------------------- |
|
|
@@ -10,6 +10,7 @@ against the GitHub REST API:
|
|
|
10
10
|
| `secrets` | GH Actions secrets (repo + environment + organization) |
|
|
11
11
|
| `environments` | Named deployment environments (reviewers, wait timers) |
|
|
12
12
|
| `issues` | GitHub Issues as a tracker (with lifecycle slots) |
|
|
13
|
+
| `projects` | GitHub Projects v2 boards (GraphQL) |
|
|
13
14
|
|
|
14
15
|
## Install
|
|
15
16
|
|
|
@@ -34,6 +35,7 @@ Each capability resolves its own fine-grained token so a compromised credential
|
|
|
34
35
|
| `HOLOCRON_SYNC_TOKEN` | `github.sync` | `sync-github` command |
|
|
35
36
|
| `HOLOCRON_RELEASE_TOKEN` | `github.release` | semantic-release, GitHub releases |
|
|
36
37
|
| `HOLOCRON_ADMIN_TOKEN` | `github.admin` | `source`, `secrets`, `environments` |
|
|
38
|
+
| `HOLOCRON_ORG_TOKEN` | `github.org` | `projects` |
|
|
37
39
|
|
|
38
40
|
Store tokens once via the keyring so they are picked up automatically:
|
|
39
41
|
|
|
@@ -45,7 +47,7 @@ holocron auth set github.release ghp_xxx # semantic-release
|
|
|
45
47
|
holocron auth set github.admin ghp_xxx # setup, secrets, environments
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
See [
|
|
50
|
+
See the [token reference](https://docs.theholocron.dev/holocron/tokens/) for full scope requirements and CI setup.
|
|
49
51
|
|
|
50
52
|
## Config
|
|
51
53
|
|
|
@@ -64,6 +66,29 @@ See [docs/tokens.md](../../docs/tokens.md) for full scope requirements and CI se
|
|
|
64
66
|
|
|
65
67
|
```
|
|
66
68
|
|
|
69
|
+
## `projects` capability
|
|
70
|
+
|
|
71
|
+
GitHub Projects v2 boards over GraphQL, for `holocron project ...` (SPEC-0020, #1744). It uses the org token
|
|
72
|
+
(`HOLOCRON_ORG_TOKEN`, keyring `github.org`) with the **Projects** organization permission. Items are keyed `#N` in the
|
|
73
|
+
configured `repo` and `owner/repo#N` elsewhere.
|
|
74
|
+
|
|
75
|
+
| Method | What it does |
|
|
76
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `list` | Every project of the organization, open and closed. `find` is the exact name among the open ones. |
|
|
78
|
+
| `create` | Copies the board `template.source` names (fields, options, views, automation rules, no items), or creates a project and applies the template. |
|
|
79
|
+
| `close` | `updateProjectV2` with `closed: true`. Reversible. |
|
|
80
|
+
| `read` | Statuses, other fields, board and table views and automation rules. |
|
|
81
|
+
| `ensure` | Adds what the template lists and the board lacks (options, fields, views, filters). Never deletes. Rules and view grouping the API cannot set come back as `todos`. |
|
|
82
|
+
| `items` | Each issue or pull request with its status, category, whether it is open and its open blockers. |
|
|
83
|
+
| `setStatus` | Sets an item's status. Idempotent: `transitioned: false` when it is already there. |
|
|
84
|
+
| `move` | Puts open items on another board with status and priority (only where the target has none); closed and merged ones stay and are set to done when theirs is not a done one. |
|
|
85
|
+
| `whoami` | How many boards the token sees, for `holocron doctor`. |
|
|
86
|
+
|
|
87
|
+
`ensure` is safe on a field that has items. `updateProjectV2Field` replaces a single select field's whole option list,
|
|
88
|
+
and an option sent without its `id` blanks the field on every item, so `ensure` reads the field first, sends every
|
|
89
|
+
existing option with its `id` in the template's order (new ones without), and stops when the field cannot be read. It
|
|
90
|
+
also keeps the item values in memory and, if a re-read shows any gone, writes them back by option name and fails.
|
|
91
|
+
|
|
67
92
|
## Status
|
|
68
93
|
|
|
69
94
|
**`v2.0.0-alpha.0`** — published on npm under the `alpha` dist-tag.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,47 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const resolveReadToken: (
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
|
|
8
|
-
declare const
|
|
9
|
-
|
|
10
|
-
declare const
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Auth, AuthError, BoardItem, BoardState, BoardSummary, BoardTemplate, Ci, CiRun, CiRunFilter, EnsureReport, Environment, Environments, ImportOptions, ImportResult, Issue, IssueRecord, IssueSearchFilter, IssueSelector, Issues, LabelDef, LifecycleResult, LifecycleSlot, MoveReport, PagesConfig, PluginToken, Projects, PullRequest, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretScope, Secrets, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TeamPermission as TeamPermission$1, TrackerDoctorReport, TrackerUser, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, createFeatureResolver } from "@theholocron/cli";
|
|
2
|
+
import { GitHubClient, GitHubClientOptions, GraphQLClient, createGitHubClient } from "@theholocron/github-client";
|
|
3
|
+
/** Resolves the token for read-only GitHub access (`HOLOCRON_READ_TOKEN`, keyring key `github.read`). */
|
|
4
|
+
export declare const resolveReadToken: import("@theholocron/cli").FeatureResolver;
|
|
5
|
+
/** Resolves the token for issue operations (`HOLOCRON_ISSUES_TOKEN`, keyring key `github.issues`). */
|
|
6
|
+
export declare const resolveIssuesToken: import("@theholocron/cli").FeatureResolver;
|
|
7
|
+
/** Resolves the token for syncing repo files and settings (`HOLOCRON_SYNC_TOKEN`, keyring key `github.sync`). */
|
|
8
|
+
export declare const resolveSyncToken: import("@theholocron/cli").FeatureResolver;
|
|
9
|
+
/** Resolves the token for release operations (`HOLOCRON_RELEASE_TOKEN`, keyring key `github.release`). */
|
|
10
|
+
export declare const resolveReleaseToken: import("@theholocron/cli").FeatureResolver;
|
|
11
|
+
/** Resolves the repo-scoped admin token (`HOLOCRON_ADMIN_TOKEN`, keyring key `github.admin`). */
|
|
12
|
+
export declare const resolveAdminToken: import("@theholocron/cli").FeatureResolver;
|
|
13
|
+
/** Resolves the org-level secrets token (`HOLOCRON_SECRETS_TOKEN`, keyring key `github.secrets`). */
|
|
14
|
+
export declare const resolveSecretsToken: import("@theholocron/cli").FeatureResolver;
|
|
15
|
+
/** Resolves the token for deployment operations (`HOLOCRON_DEPLOY_TOKEN`, keyring key `github.deploy`). */
|
|
16
|
+
export declare const resolveDeployToken: import("@theholocron/cli").FeatureResolver;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the token for the user-sync files in the org's private config repo (`HOLOCRON_USER_SYNC_TOKEN`, keyring
|
|
19
|
+
* key `github.user-sync`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveUserSyncToken: import("@theholocron/cli").FeatureResolver;
|
|
22
|
+
/** Resolves the org-level token (`HOLOCRON_ORG_TOKEN`, keyring key `github.org`). */
|
|
23
|
+
export declare const resolveOrgToken: import("@theholocron/cli").FeatureResolver;
|
|
13
24
|
interface CiOptions {
|
|
14
25
|
repo: string;
|
|
15
26
|
}
|
|
16
|
-
|
|
27
|
+
/** The GitHub implementation of the `ci` capability, backed by GitHub Actions workflow runs. */
|
|
28
|
+
export declare class GitHubCi implements Ci {
|
|
17
29
|
private readonly client;
|
|
18
30
|
private readonly opts;
|
|
31
|
+
/** Capability key, always `"ci"`. */
|
|
19
32
|
readonly key: "ci";
|
|
33
|
+
/** Provider name, always `"github"`. */
|
|
20
34
|
readonly providerName = "github";
|
|
21
35
|
constructor(client: GitHubClient, opts: CiOptions);
|
|
36
|
+
/** Lists workflow runs for the repo, optionally filtered by branch, status and limit. */
|
|
22
37
|
listRuns(filter?: CiRunFilter): Promise<CiRun[]>;
|
|
38
|
+
/** Fetches one workflow run by id. */
|
|
23
39
|
getRun(id: string | number): Promise<CiRun>;
|
|
24
40
|
private mapRun;
|
|
25
41
|
private mapConclusion;
|
|
26
42
|
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/capabilities/environments.d.ts
|
|
29
43
|
interface EnvironmentsOptions {
|
|
30
44
|
repo: string;
|
|
31
45
|
}
|
|
32
|
-
|
|
46
|
+
/** The GitHub implementation of the `environments` capability, managing a repo's deployment environments. */
|
|
47
|
+
export declare class GitHubEnvironments implements Environments {
|
|
33
48
|
private readonly client;
|
|
34
49
|
private readonly opts;
|
|
50
|
+
/** Capability key, always `"environments"`. */
|
|
35
51
|
readonly key: "environments";
|
|
52
|
+
/** Provider name, always `"github"`. */
|
|
36
53
|
readonly providerName = "github";
|
|
37
54
|
constructor(client: GitHubClient, opts: EnvironmentsOptions);
|
|
55
|
+
/** Lists the repo's environments with their wait timer, self-review rule and required reviewers. */
|
|
38
56
|
listEnvironments(): Promise<Environment[]>;
|
|
57
|
+
/** Creates or updates an environment, sending only the settings the given environment defines. */
|
|
39
58
|
upsertEnvironment(env: Environment): Promise<void>;
|
|
59
|
+
/** Deletes the named environment. */
|
|
40
60
|
deleteEnvironment(name: string): Promise<void>;
|
|
41
61
|
private flattenReviewers;
|
|
42
62
|
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/capabilities/issues.d.ts
|
|
45
63
|
interface IssuesOptions {
|
|
46
64
|
repo: string;
|
|
47
65
|
/**
|
|
@@ -55,9 +73,12 @@ interface IssuesOptions {
|
|
|
55
73
|
inReview: string;
|
|
56
74
|
};
|
|
57
75
|
}
|
|
58
|
-
|
|
76
|
+
/** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
|
|
77
|
+
export declare class GitHubIssues implements Issues {
|
|
59
78
|
private readonly client;
|
|
79
|
+
/** Capability key, always `"issues"`. */
|
|
60
80
|
readonly key: "issues";
|
|
81
|
+
/** Provider name, always `"github"`. */
|
|
61
82
|
readonly providerName = "github";
|
|
62
83
|
private readonly owner;
|
|
63
84
|
private readonly repoName;
|
|
@@ -65,8 +86,11 @@ declare class GitHubIssues implements Issues {
|
|
|
65
86
|
private readonly labels;
|
|
66
87
|
constructor(client: GitHubClient, opts: IssuesOptions);
|
|
67
88
|
getMyself(): Promise<TrackerUser>;
|
|
89
|
+
/** Searches the repo's issues, newest update first, leaving out pull requests. */
|
|
68
90
|
search(filter: IssueSearchFilter): Promise<Issue[]>;
|
|
91
|
+
/** Fetches one issue by its key. */
|
|
69
92
|
get(key: string): Promise<Issue>;
|
|
93
|
+
/** Creates an issue and returns its key as `#<number>`; the milestone is resolved from its title. */
|
|
70
94
|
create(input: {
|
|
71
95
|
summary: string;
|
|
72
96
|
body?: string;
|
|
@@ -76,17 +100,25 @@ declare class GitHubIssues implements Issues {
|
|
|
76
100
|
key: string;
|
|
77
101
|
}>;
|
|
78
102
|
transition(key: string, slot: LifecycleSlot): Promise<LifecycleResult>;
|
|
103
|
+
/** Adds a comment to the issue with the given key. */
|
|
79
104
|
comment(key: string, body: string): Promise<void>;
|
|
105
|
+
/** Checks the authenticated user, the repo and the label-backed lifecycle slots, and reports what resolves. */
|
|
80
106
|
doctor(): Promise<TrackerDoctorReport>;
|
|
107
|
+
/** Reads issues with their comments, priority label, parent and blockers, for `holocron migrate`. */
|
|
108
|
+
export(selector: IssueSelector): Promise<IssueRecord[]>;
|
|
109
|
+
/** Makes the records as issues; one already made by an earlier run is skipped. */
|
|
110
|
+
import(records: IssueRecord[], options?: ImportOptions): Promise<ImportResult[]>;
|
|
81
111
|
private resolveMilestone;
|
|
82
112
|
private removeStatusLabels;
|
|
83
113
|
private mapIssue;
|
|
84
114
|
}
|
|
85
|
-
|
|
86
|
-
//#region src/capabilities/labels.d.ts
|
|
115
|
+
/** A label the repo is expected to have. */
|
|
87
116
|
interface CanonicalLabel {
|
|
117
|
+
/** The label's name. */
|
|
88
118
|
readonly name: string;
|
|
119
|
+
/** The label's color, as a hex string. */
|
|
89
120
|
readonly color: string;
|
|
121
|
+
/** The label's description. */
|
|
90
122
|
readonly description: string;
|
|
91
123
|
}
|
|
92
124
|
/**
|
|
@@ -97,36 +129,113 @@ interface CanonicalLabel {
|
|
|
97
129
|
* - DELETEs labels listed in `stale`.
|
|
98
130
|
* - Leaves unrecognised labels that aren't in `stale` untouched.
|
|
99
131
|
*/
|
|
100
|
-
declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
|
|
101
|
-
|
|
102
|
-
|
|
132
|
+
export declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
|
|
133
|
+
/** Options of the GitHub `projects` capability. */
|
|
134
|
+
interface ProjectsOptions {
|
|
135
|
+
/** The repository the provider is configured for, as `owner/name`; its items get the short key `#N`. */
|
|
136
|
+
repo: string;
|
|
137
|
+
}
|
|
138
|
+
/** The GitHub implementation of the `projects` capability, backed by Projects v2. */
|
|
139
|
+
export declare class GitHubProjects implements Projects {
|
|
140
|
+
private readonly graphql;
|
|
141
|
+
/** Capability key, always `"projects"`. */
|
|
142
|
+
readonly key: "projects";
|
|
143
|
+
/** Provider name, always `"github"`. */
|
|
144
|
+
readonly providerName = "github";
|
|
145
|
+
private readonly repo;
|
|
146
|
+
constructor(graphql: GraphQLClient, opts: ProjectsOptions);
|
|
147
|
+
/** Every board of the organization, open and closed. */
|
|
148
|
+
list(owner: string): Promise<BoardSummary[]>;
|
|
149
|
+
/** The open board with exactly this name. */
|
|
150
|
+
find(owner: string, name: string): Promise<BoardSummary | undefined>;
|
|
151
|
+
/**
|
|
152
|
+
* Makes a board. With `template.source` naming an open board it is copied (fields, options, views and automation
|
|
153
|
+
* rules, no items); otherwise the board is created and brought in line with the template.
|
|
154
|
+
*/
|
|
155
|
+
create(owner: string, name: string, template: BoardTemplate): Promise<BoardSummary>;
|
|
156
|
+
/** Closes the board; `updateProjectV2` with `closed: true` is the only way, and reversible. */
|
|
157
|
+
close(_owner: string, board: BoardSummary): Promise<void>;
|
|
158
|
+
/** The live board: statuses, other fields, views and automation rules. */
|
|
159
|
+
read(_owner: string, board: BoardSummary): Promise<BoardState>;
|
|
160
|
+
/**
|
|
161
|
+
* Brings the board in line with the template. Never deletes a field, option or view, and never sends an option
|
|
162
|
+
* list without ids. Stops (throws) when the status field cannot be read.
|
|
163
|
+
*/
|
|
164
|
+
ensure(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<EnsureReport>;
|
|
165
|
+
/**
|
|
166
|
+
* Makes a single select field hold the wanted options in order, every existing one sent with its id. Options the
|
|
167
|
+
* template does not mention stay, after the wanted ones. Returns what changed (`Blocked added`, `order set`).
|
|
168
|
+
*/
|
|
169
|
+
private ensureOptions;
|
|
170
|
+
private createField;
|
|
171
|
+
private createView;
|
|
172
|
+
private updateView;
|
|
173
|
+
/** The board's issues and pull requests with their status, whether they are open and their open blockers. */
|
|
174
|
+
items(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<BoardItem[]>;
|
|
175
|
+
/** Puts an item in a status; `transitioned` is false when it already is there. */
|
|
176
|
+
setStatus(_owner: string, board: BoardSummary, key: string, status: string): Promise<LifecycleResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Puts the open items of `from` on `to` with their status and priority, only where the target has no value;
|
|
179
|
+
* closed and merged ones stay, and are set to the template's done status when theirs is not a done one.
|
|
180
|
+
*/
|
|
181
|
+
move(_owner: string, from: BoardSummary, to: BoardSummary, template: BoardTemplate): Promise<MoveReport>;
|
|
182
|
+
/** A `holocron doctor` smoke check: how many boards the token sees in the configured repository's organization. */
|
|
183
|
+
whoami(): Promise<{
|
|
184
|
+
ok: boolean;
|
|
185
|
+
boards: number;
|
|
186
|
+
}>;
|
|
187
|
+
/** Sets a single select value by option name; a field or option the board lacks is skipped. */
|
|
188
|
+
private setOption;
|
|
189
|
+
private ownerId;
|
|
190
|
+
private readRaw;
|
|
191
|
+
private fetchItems;
|
|
192
|
+
private keyOf;
|
|
193
|
+
private parseKey;
|
|
194
|
+
}
|
|
103
195
|
interface SecretsOptions {
|
|
104
196
|
repo: string;
|
|
105
197
|
}
|
|
106
|
-
|
|
198
|
+
/** The GitHub implementation of the `secrets` capability, covering repository, environment and organization secrets. */
|
|
199
|
+
export declare class GitHubSecrets implements Secrets {
|
|
107
200
|
private readonly client;
|
|
108
201
|
private readonly opts;
|
|
202
|
+
private readonly orgClient?;
|
|
203
|
+
/** Capability key, always `"secrets"`. */
|
|
109
204
|
readonly key: "secrets";
|
|
205
|
+
/** Provider name, always `"github"`. */
|
|
110
206
|
readonly providerName = "github";
|
|
111
|
-
|
|
207
|
+
/**
|
|
208
|
+
* `client` handles repo and environment scopes; `orgClient`, when given, handles
|
|
209
|
+
* the organization scope. They differ when a dedicated org-only token exists:
|
|
210
|
+
* it can write org secrets but not repo ones, and `github.admin` is the reverse.
|
|
211
|
+
*/
|
|
212
|
+
constructor(client: GitHubClient, opts: SecretsOptions, orgClient?: GitHubClient | undefined);
|
|
213
|
+
private clientFor;
|
|
112
214
|
listSecrets(scope: SecretScope): Promise<string[]>;
|
|
113
215
|
setSecret(scope: SecretScope, name: string, value: string): Promise<void>;
|
|
216
|
+
/** Deletes the named secret in the given scope. */
|
|
114
217
|
deleteSecret(scope: SecretScope, name: string): Promise<void>;
|
|
115
218
|
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/capabilities/source.d.ts
|
|
118
219
|
interface SourceOptions {
|
|
119
220
|
repo: string;
|
|
120
221
|
repoRoot: string;
|
|
121
222
|
/** Secondary client authenticated with HOLOCRON_ORG_TOKEN for org-scoped operations (teams, custom properties). */
|
|
122
223
|
orgClient?: GitHubClient;
|
|
224
|
+
/** Client for the files that link GitHub accounts to other services (HOLOCRON_USER_SYNC_TOKEN); falls back to the org client. */
|
|
225
|
+
userSyncClient?: GitHubClient;
|
|
123
226
|
/** Forwarded to a secondary client created for Pages calls (HOLOCRON_DEPLOY_TOKEN). */
|
|
124
227
|
baseUrl?: string;
|
|
125
228
|
fetch?: typeof fetch;
|
|
126
229
|
}
|
|
127
|
-
|
|
230
|
+
/**
|
|
231
|
+
* The GitHub implementation of the `source` capability: repo settings, rulesets, branch protection, security
|
|
232
|
+
* features and local workflow files.
|
|
233
|
+
*/
|
|
234
|
+
export declare class GitHubSource implements Source {
|
|
128
235
|
private readonly client;
|
|
236
|
+
/** Capability key, always `"source"`. */
|
|
129
237
|
readonly key: "source";
|
|
238
|
+
/** Provider name, always `"github"`. */
|
|
130
239
|
readonly providerName = "github";
|
|
131
240
|
private readonly owner;
|
|
132
241
|
private readonly name;
|
|
@@ -134,83 +243,119 @@ declare class GitHubSource implements Source {
|
|
|
134
243
|
private readonly repoRoot;
|
|
135
244
|
private readonly workflowDir;
|
|
136
245
|
private readonly orgClient?;
|
|
246
|
+
private readonly userSyncClient?;
|
|
137
247
|
private readonly baseUrl?;
|
|
138
248
|
private readonly fetchImpl?;
|
|
139
249
|
constructor(client: GitHubClient, opts: SourceOptions);
|
|
140
250
|
whoami(): Promise<{
|
|
141
251
|
login: string;
|
|
142
252
|
}>;
|
|
253
|
+
/** Returns the repo's owner, name and default branch. */
|
|
143
254
|
getRepo(): Promise<RepoRef>;
|
|
255
|
+
/** Lists the repo's rulesets. */
|
|
144
256
|
listRulesets(): Promise<Ruleset[]>;
|
|
257
|
+
/** Creates a ruleset from the given payload. */
|
|
145
258
|
createRuleset(payload: Record<string, unknown>): Promise<Ruleset>;
|
|
259
|
+
/** Updates the ruleset with the given id from the payload. */
|
|
146
260
|
updateRuleset(id: number, payload: Record<string, unknown>): Promise<Ruleset>;
|
|
261
|
+
/** Updates the repo's settings. */
|
|
147
262
|
updateRepoSettings(settings: RepoSettings): Promise<void>;
|
|
148
263
|
protectBranch(branch: string, payload: Record<string, unknown>): Promise<void>;
|
|
264
|
+
/** Enables Dependabot vulnerability alerts. */
|
|
149
265
|
enableVulnerabilityAlerts(): Promise<void>;
|
|
266
|
+
/** Enables Dependabot automated security fixes. */
|
|
150
267
|
enableAutomatedSecurityFixes(): Promise<void>;
|
|
268
|
+
/** Enables secret scanning. */
|
|
151
269
|
enableSecretScanning(): Promise<void>;
|
|
152
270
|
enableCodeScanning(): Promise<string>;
|
|
153
271
|
disableDefaultCodeScanning(): Promise<void>;
|
|
154
272
|
enableDependencyGraph(): Promise<void>;
|
|
273
|
+
/** Enables private vulnerability reporting. */
|
|
155
274
|
enablePrivateVulnerabilityReporting(): Promise<void>;
|
|
275
|
+
/** Lists the `.yml` and `.yaml` files in `.github/workflows`, sorted by name; empty when the folder is missing. */
|
|
156
276
|
listWorkflowFiles(): Promise<string[]>;
|
|
277
|
+
/** Reads a workflow file's text, or `null` when it does not exist. */
|
|
157
278
|
readWorkflowFile(name: string): Promise<string | null>;
|
|
279
|
+
/** Writes a workflow file, creating `.github/workflows` first when needed. */
|
|
158
280
|
writeWorkflowFile(name: string, contents: string): Promise<void>;
|
|
281
|
+
/** Removes a workflow file; a file that is already gone is not an error. */
|
|
159
282
|
removeWorkflowFile(name: string): Promise<void>;
|
|
160
283
|
writeRepoFile(path: string, contents: string): Promise<void>;
|
|
161
284
|
syncLabels(canonical: ReadonlyArray<LabelDef>, stale: ReadonlyArray<string>): Promise<string>;
|
|
162
285
|
syncProperties(values: Record<string, string | string[]>): Promise<string>;
|
|
286
|
+
getOrgPropertyValues(name: string): Promise<string[] | undefined>;
|
|
287
|
+
addOrgPropertyValues(name: string, values: string[]): Promise<string[]>;
|
|
288
|
+
checkPropertyValues(values: Record<string, string | string[]>): Promise<string[] | undefined>;
|
|
163
289
|
syncTeams(teams: TeamEntry$1[]): Promise<string>;
|
|
290
|
+
teamMembers(teamSlug: string, org?: string): Promise<SourceTeamMember[]>;
|
|
291
|
+
readFile(path: string, repo?: string): Promise<SourceFile | null>;
|
|
292
|
+
writeFile(path: string, content: string, opts: {
|
|
293
|
+
message: string;
|
|
294
|
+
version?: string;
|
|
295
|
+
repo?: string;
|
|
296
|
+
}): Promise<void>;
|
|
164
297
|
syncTopics(topics: string[]): Promise<string>;
|
|
298
|
+
syncVariables(variables: Record<string, string>, opts?: {
|
|
299
|
+
prune?: boolean;
|
|
300
|
+
dryRun?: boolean;
|
|
301
|
+
}): Promise<string>;
|
|
302
|
+
syncOrgVariables(org: string, variables: Record<string, {
|
|
303
|
+
value: string;
|
|
304
|
+
visibility: "all" | "private";
|
|
305
|
+
}>, opts?: {
|
|
306
|
+
prune?: boolean;
|
|
307
|
+
dryRun?: boolean;
|
|
308
|
+
}): Promise<string>;
|
|
309
|
+
listVariables(): Promise<Record<string, string>>;
|
|
310
|
+
listOrgVariables(org: string): Promise<Record<string, {
|
|
311
|
+
value: string;
|
|
312
|
+
visibility: "all" | "private" | "selected";
|
|
313
|
+
}>>;
|
|
314
|
+
getRepoInfo(): Promise<SourceRepoInfo>;
|
|
315
|
+
getProperties(): Promise<Record<string, string | string[]>>;
|
|
316
|
+
listLabels(): Promise<LabelDef[]>;
|
|
317
|
+
listTeamAccess(): Promise<Array<{
|
|
318
|
+
slug: string;
|
|
319
|
+
permission: TeamPermission$1;
|
|
320
|
+
}>>;
|
|
321
|
+
getRulesetDetail(id: number): Promise<SourceRulesetDetail>;
|
|
322
|
+
getSecurity(): Promise<SourceSecurity>;
|
|
165
323
|
syncDescription(description: string): Promise<string>;
|
|
166
324
|
syncHomepage(homepage: string): Promise<string>;
|
|
167
325
|
getPullRequest(number: number, repo?: string): Promise<PullRequest>;
|
|
326
|
+
listPullRequests(state: "open" | "closed", repo?: string): Promise<PullRequest[]>;
|
|
327
|
+
listBranches(repo?: string): Promise<SourceBranch[]>;
|
|
328
|
+
deleteBranch(name: string, repo?: string): Promise<void>;
|
|
329
|
+
listPullRequestCommits(number: number, repo?: string): Promise<string[]>;
|
|
168
330
|
configurePages(config: PagesConfig, token: string): Promise<void>;
|
|
169
331
|
}
|
|
170
|
-
|
|
171
|
-
//#region src/capabilities/teams.d.ts
|
|
332
|
+
/** A team entry with the permission spelled out. */
|
|
172
333
|
interface NormalizedTeamEntry {
|
|
334
|
+
/** The team's slug. */
|
|
173
335
|
slug: string;
|
|
336
|
+
/** The permission the team gets on the repo. */
|
|
174
337
|
permission: TeamPermission;
|
|
175
338
|
}
|
|
176
|
-
|
|
177
|
-
declare function
|
|
178
|
-
|
|
179
|
-
|
|
339
|
+
/** Turns a team entry into slug and permission form; a bare slug gets `push`. */
|
|
340
|
+
export declare function normalizeTeamEntry(entry: TeamEntry): NormalizedTeamEntry;
|
|
341
|
+
/** Grants each team access to the repo and reports the outcome; throws when every team fails. */
|
|
342
|
+
export declare function syncTeams(client: GitHubClient, repo: string, teams: TeamEntry[]): Promise<string>;
|
|
180
343
|
/**
|
|
181
344
|
* Encrypt `value` for the given GitHub-provided base64 public key.
|
|
182
345
|
* Returns the base64 ciphertext to send as `encrypted_value`.
|
|
183
346
|
*/
|
|
184
|
-
declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
185
|
-
|
|
186
|
-
//#region src/verify-token.d.ts
|
|
187
|
-
/**
|
|
188
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
189
|
-
* `holocron auth check`. Hits `GET /user` and translates the response
|
|
190
|
-
* into the normalized `VerifyTokenResult` shape.
|
|
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.
|
|
196
|
-
*/
|
|
197
|
-
interface VerifyTokenSuccess {
|
|
198
|
-
ok: true;
|
|
199
|
-
subject: string;
|
|
200
|
-
}
|
|
201
|
-
interface VerifyTokenFailure {
|
|
202
|
-
ok: false;
|
|
203
|
-
message: string;
|
|
204
|
-
}
|
|
205
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
347
|
+
export declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
|
|
348
|
+
/** Options for `verifyToken`. */
|
|
206
349
|
interface VerifyTokenOptions {
|
|
350
|
+
/** Overrides the API base URL, for tests. */
|
|
207
351
|
baseUrl?: string;
|
|
352
|
+
/** Overrides `fetch`, for tests. */
|
|
208
353
|
fetch?: typeof fetch;
|
|
209
354
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
interface GitHubPluginOptions extends ResolveTokenInput {
|
|
355
|
+
/** Checks a token against `GET /user` and returns who it belongs to, or why it failed. */
|
|
356
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
357
|
+
/** Options for the GitHub plugin. */
|
|
358
|
+
export interface GitHubPluginOptions extends ResolveTokenInput {
|
|
214
359
|
/** "owner/name" — e.g., "theholocron/holocron". Required. */
|
|
215
360
|
repo: string;
|
|
216
361
|
/** Absolute path to the working repo root. Used by `source`'s
|
|
@@ -218,7 +363,9 @@ interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
218
363
|
repoRoot?: string;
|
|
219
364
|
/** Lifecycle slot → label name. Used by the `issues` capability. */
|
|
220
365
|
labels?: {
|
|
366
|
+
/** Label that marks an issue as in progress. */
|
|
221
367
|
inProgress: string;
|
|
368
|
+
/** Label that marks an issue as in review. */
|
|
222
369
|
inReview: string;
|
|
223
370
|
};
|
|
224
371
|
/** Override base URL for tests. Defaults to https://api.github.com. */
|
|
@@ -226,31 +373,49 @@ interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
226
373
|
/** Override `fetch` for tests. Defaults to global `fetch`. */
|
|
227
374
|
fetch?: typeof fetch;
|
|
228
375
|
}
|
|
229
|
-
|
|
376
|
+
/** What the capability factories receive: the plugin options, a client, the repo and its root. */
|
|
377
|
+
export interface PluginContext {
|
|
378
|
+
/** The plugin options. */
|
|
230
379
|
options: GitHubPluginOptions;
|
|
380
|
+
/** The GitHub client the capability uses. */
|
|
231
381
|
client: GitHubClient;
|
|
382
|
+
/** The repo as `owner/name`. */
|
|
232
383
|
repo: string;
|
|
384
|
+
/** Absolute path to the working repo root. */
|
|
233
385
|
repoRoot: string;
|
|
234
386
|
}
|
|
235
|
-
|
|
236
|
-
declare function
|
|
237
|
-
|
|
238
|
-
declare function
|
|
239
|
-
|
|
240
|
-
declare function
|
|
387
|
+
/** Builds the `source` capability; the optional clients cover org-level and user-sync access. */
|
|
388
|
+
export declare function source(ctx: PluginContext, orgClient?: GitHubClient, userSyncClient?: GitHubClient): Source;
|
|
389
|
+
/** Builds the `secrets` capability; the optional client handles organization secrets. */
|
|
390
|
+
export declare function secrets(ctx: PluginContext, orgClient?: GitHubClient): Secrets;
|
|
391
|
+
/** Builds the `environments` capability. */
|
|
392
|
+
export declare function environments(ctx: PluginContext): Environments;
|
|
393
|
+
/** Builds the `ci` capability. */
|
|
394
|
+
export declare function ci(ctx: PluginContext): Ci;
|
|
395
|
+
/** Builds the `issues` capability, passing the lifecycle labels when configured. */
|
|
396
|
+
export declare function issues(ctx: PluginContext): Issues;
|
|
397
|
+
/** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
|
|
398
|
+
export declare function projects(ctx: PluginContext): Projects;
|
|
399
|
+
/** Creates the plugin, resolving a token per capability when it is first used. */
|
|
400
|
+
export declare function createPlugin(options: GitHubPluginOptions): {
|
|
241
401
|
name: string;
|
|
402
|
+
probes: {
|
|
403
|
+
connection: import("@theholocron/cli").Probe;
|
|
404
|
+
};
|
|
242
405
|
capabilities: {
|
|
243
406
|
source: () => Source;
|
|
244
407
|
ci: () => Ci;
|
|
245
408
|
secrets: () => Secrets;
|
|
246
409
|
environments: () => Environments;
|
|
247
410
|
issues: () => Issues;
|
|
411
|
+
projects: () => Projects;
|
|
248
412
|
};
|
|
249
413
|
};
|
|
250
414
|
/**
|
|
251
415
|
* One-line hint printed by `holocron auth set github` when no token
|
|
252
416
|
* is supplied or the supplied token is rejected.
|
|
253
417
|
*/
|
|
254
|
-
declare const AUTH_HINT: string;
|
|
255
|
-
|
|
256
|
-
export
|
|
418
|
+
export declare const AUTH_HINT: string;
|
|
419
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
420
|
+
export declare const tokens: PluginToken[];
|
|
421
|
+
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 };
|