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