@theholocron/holocron-plugin-github 5.0.0-alpha.418 → 5.0.0-alpha.419
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/dist/index.d.mts +11 -1
- package/dist/index.mjs +41 -1
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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, 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";
|
|
1
|
+
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";
|
|
2
2
|
import { GitHubClient, GitHubClientOptions, GraphQLClient, createGitHubClient } from "@theholocron/github-client";
|
|
3
3
|
/** Resolves the token for read-only GitHub access (`HOLOCRON_READ_TOKEN`, keyring key `github.read`). */
|
|
4
4
|
export declare const resolveReadToken: import("@theholocron/cli").FeatureResolver;
|
|
@@ -232,9 +232,19 @@ export declare class GitHubSecrets implements Secrets {
|
|
|
232
232
|
* it can write org secrets but not repo ones, and `github.admin` is the reverse.
|
|
233
233
|
*/
|
|
234
234
|
constructor(client: GitHubClient, opts: SecretsOptions, orgClient?: GitHubClient | undefined);
|
|
235
|
+
/** Repository name to numeric id, so one run asks GitHub once per repository however many secrets name it. */
|
|
236
|
+
private readonly repoIds;
|
|
235
237
|
private clientFor;
|
|
236
238
|
listSecrets(scope: SecretScope): Promise<string[]>;
|
|
237
239
|
setSecret(scope: SecretScope, name: string, value: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Who can read each organization secret, by name (never a value): `selected` ones come with the names of their
|
|
242
|
+
* repositories. Any other scope has no visibility and gives `{}`.
|
|
243
|
+
*/
|
|
244
|
+
listSecretAccess(scope: SecretScope): Promise<Record<string, SecretAccess>>;
|
|
245
|
+
/** The `visibility` (and repository ids) of an organization write. No `visibility` keeps the older default, `all`. */
|
|
246
|
+
private readers;
|
|
247
|
+
private repoId;
|
|
238
248
|
/** Deletes the named secret in the given scope. */
|
|
239
249
|
deleteSecret(scope: SecretScope, name: string): Promise<void>;
|
|
240
250
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1387,6 +1387,8 @@ var GitHubSecrets = class {
|
|
|
1387
1387
|
this.opts = opts;
|
|
1388
1388
|
this.orgClient = orgClient;
|
|
1389
1389
|
}
|
|
1390
|
+
/** Repository name to numeric id, so one run asks GitHub once per repository however many secrets name it. */
|
|
1391
|
+
repoIds = /* @__PURE__ */ new Map();
|
|
1390
1392
|
clientFor(scope) {
|
|
1391
1393
|
return scope.kind === "organization" ? this.orgClient ?? this.client : this.client;
|
|
1392
1394
|
}
|
|
@@ -1396,14 +1398,52 @@ var GitHubSecrets = class {
|
|
|
1396
1398
|
async setSecret(scope, name, value) {
|
|
1397
1399
|
const ghScope = toGHScope(scope);
|
|
1398
1400
|
const client = this.clientFor(scope);
|
|
1401
|
+
const readers = scope.kind === "organization" ? await this.readers(scope) : {};
|
|
1399
1402
|
const pk = await client.secrets.getPublicKey(this.opts.repo, ghScope);
|
|
1400
1403
|
const body = {
|
|
1401
1404
|
encrypted_value: await encryptSecret(pk.key, value),
|
|
1402
1405
|
key_id: pk.key_id
|
|
1403
1406
|
};
|
|
1404
|
-
|
|
1407
|
+
Object.assign(body, readers);
|
|
1405
1408
|
await client.secrets.putSecret(this.opts.repo, ghScope, name, body);
|
|
1406
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Who can read each organization secret, by name (never a value): `selected` ones come with the names of their
|
|
1412
|
+
* repositories. Any other scope has no visibility and gives `{}`.
|
|
1413
|
+
*/
|
|
1414
|
+
async listSecretAccess(scope) {
|
|
1415
|
+
if (scope.kind !== "organization") return {};
|
|
1416
|
+
const client = this.clientFor(scope);
|
|
1417
|
+
const found = {};
|
|
1418
|
+
for (const info of await client.secrets.listOrgSecretInfo(scope.name)) found[info.name] = info.visibility === "selected" ? {
|
|
1419
|
+
visibility: "selected",
|
|
1420
|
+
repos: await client.secrets.listSelectedRepositories(scope.name, info.name)
|
|
1421
|
+
} : { visibility: info.visibility };
|
|
1422
|
+
return found;
|
|
1423
|
+
}
|
|
1424
|
+
/** The `visibility` (and repository ids) of an organization write. No `visibility` keeps the older default, `all`. */
|
|
1425
|
+
async readers(scope) {
|
|
1426
|
+
const visibility = scope.visibility ?? "all";
|
|
1427
|
+
if (visibility !== "selected") return { visibility };
|
|
1428
|
+
if (!scope.repos?.length) throw new Error(`organization secret with visibility "selected" needs a non-empty repos list`);
|
|
1429
|
+
const ids = [];
|
|
1430
|
+
for (const name of scope.repos) ids.push(await this.repoId(scope.name, name));
|
|
1431
|
+
return {
|
|
1432
|
+
visibility,
|
|
1433
|
+
selected_repository_ids: ids
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
repoId(org, name) {
|
|
1437
|
+
const full = `${org}/${name}`;
|
|
1438
|
+
let id = this.repoIds.get(full);
|
|
1439
|
+
if (!id) {
|
|
1440
|
+
id = this.client.repos.getRepo(full).then((repo) => repo.id, (err) => {
|
|
1441
|
+
throw new Error(`could not resolve repository ${full}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1442
|
+
});
|
|
1443
|
+
this.repoIds.set(full, id);
|
|
1444
|
+
}
|
|
1445
|
+
return id;
|
|
1446
|
+
}
|
|
1407
1447
|
/** Deletes the named secret in the given scope. */
|
|
1408
1448
|
async deleteSecret(scope, name) {
|
|
1409
1449
|
await this.clientFor(scope).secrets.deleteSecret(this.opts.repo, toGHScope(scope), name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-github",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.419",
|
|
4
4
|
"description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
|
-
"@theholocron/fs-utils": "^1.17.0-alpha.4",
|
|
48
47
|
"@theholocron/eslint-config": "^8.9.0-alpha.16",
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
51
|
-
"@theholocron/
|
|
52
|
-
"@theholocron/
|
|
48
|
+
"@theholocron/github-client": "^1.58.0-alpha.28",
|
|
49
|
+
"@theholocron/http-client": "^1.58.0-alpha.28",
|
|
50
|
+
"@theholocron/fs-utils": "^1.17.0-alpha.4",
|
|
51
|
+
"@theholocron/cli": "5.0.0-alpha.419",
|
|
53
52
|
"@theholocron/tsdown-config": "^8.9.0-alpha.16",
|
|
53
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.16",
|
|
54
54
|
"@theholocron/vitest-config": "^8.9.0-alpha.16",
|
|
55
|
-
"@theholocron/
|
|
55
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@theholocron/fs-utils": "^1.16.0",
|
|
59
59
|
"@theholocron/github-client": "^1.58.0",
|
|
60
60
|
"@theholocron/misc-utils": "^1.16.0",
|
|
61
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
61
|
+
"@theholocron/cli": "5.0.0-alpha.419"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|