@theholocron/holocron-plugin-github 2.2.3 → 3.0.0
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 +23 -9
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +40 -29
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -21,17 +21,31 @@ pnpm add -D @theholocron/holocron-plugin-github@alpha
|
|
|
21
21
|
|
|
22
22
|
## Auth
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Each capability resolves its own fine-grained token so a compromised credential can only affect that feature. The resolution chain per capability is:
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
```
|
|
27
|
+
--token flag → HOLOCRON_<FEATURE>_TOKEN → keyring("github.<feature>")
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Env var | Keyring key | Capabilities |
|
|
31
|
+
| ------------------------ | ---------------- | ----------------------------------- |
|
|
32
|
+
| `HOLOCRON_READ_TOKEN` | `github.read` | `clone`, `ci` |
|
|
33
|
+
| `HOLOCRON_ISSUES_TOKEN` | `github.issues` | `issues` |
|
|
34
|
+
| `HOLOCRON_SYNC_TOKEN` | `github.sync` | `sync-github` command |
|
|
35
|
+
| `HOLOCRON_RELEASE_TOKEN` | `github.release` | semantic-release, GitHub releases |
|
|
36
|
+
| `HOLOCRON_ADMIN_TOKEN` | `github.admin` | `source`, `secrets`, `environments` |
|
|
37
|
+
|
|
38
|
+
Store tokens once via the keyring so they are picked up automatically:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
holocron auth set github.read ghp_xxx # clone + CI run listing
|
|
42
|
+
holocron auth set github.issues ghp_xxx # issue management
|
|
43
|
+
holocron auth set github.sync ghp_xxx # sync-github workflow templates
|
|
44
|
+
holocron auth set github.release ghp_xxx # semantic-release
|
|
45
|
+
holocron auth set github.admin ghp_xxx # setup, secrets, environments
|
|
46
|
+
```
|
|
29
47
|
|
|
30
|
-
|
|
31
|
-
options above. There is **no** `gh auth token` fallback because the
|
|
32
|
-
scopes that local `gh` auth has are usually narrower than what
|
|
33
|
-
admin-level holocron commands need (rulesets, repo settings, security
|
|
34
|
-
toggles, etc.) — silent fallback would surface as mysterious 403s.
|
|
48
|
+
See [docs/tokens.md](../../docs/tokens.md) for full scope requirements and CI setup.
|
|
35
49
|
|
|
36
50
|
## Config
|
|
37
51
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { GitHubClient, createGitHubClient } from "@theholocron/github-client";
|
|
2
|
-
import { Auth, AuthError, Ci, CiRun, CiRunFilter, Environment, Environments, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretScope, Secrets, Source, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TrackerDoctorReport, TrackerUser } from "@theholocron/cli";
|
|
1
|
+
import { GitHubClient, GitHubClientOptions, createGitHubClient } from "@theholocron/github-client";
|
|
2
|
+
import { Auth, AuthError, Ci, CiRun, CiRunFilter, Environment, Environments, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretScope, Secrets, Source, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TrackerDoctorReport, TrackerUser, createFeatureResolver } from "@theholocron/cli";
|
|
3
3
|
//#region src/auth.d.ts
|
|
4
|
-
declare const
|
|
4
|
+
declare const resolveReadToken: (input?: ResolveTokenInput) => string;
|
|
5
|
+
declare const resolveIssuesToken: (input?: ResolveTokenInput) => string;
|
|
6
|
+
declare const resolveSyncToken: (input?: ResolveTokenInput) => string;
|
|
7
|
+
declare const resolveReleaseToken: (input?: ResolveTokenInput) => string;
|
|
8
|
+
declare const resolveAdminToken: (input?: ResolveTokenInput) => string;
|
|
5
9
|
//#endregion
|
|
6
10
|
//#region src/sodium.d.ts
|
|
7
11
|
/**
|
|
@@ -215,7 +219,6 @@ interface PluginContext {
|
|
|
215
219
|
repo: string;
|
|
216
220
|
repoRoot: string;
|
|
217
221
|
}
|
|
218
|
-
declare function createContext(options: GitHubPluginOptions): PluginContext;
|
|
219
222
|
declare function source(ctx: PluginContext): Source;
|
|
220
223
|
declare function secrets(ctx: PluginContext): Secrets;
|
|
221
224
|
declare function environments(ctx: PluginContext): Environments;
|
|
@@ -233,10 +236,8 @@ declare function createPlugin(options: GitHubPluginOptions): {
|
|
|
233
236
|
};
|
|
234
237
|
/**
|
|
235
238
|
* One-line hint printed by `holocron auth set github` when no token
|
|
236
|
-
* is supplied or the supplied token is rejected.
|
|
237
|
-
* https://github.com/settings/tokens with `repo` + `admin:repo_hook`
|
|
238
|
-
* scopes (add `admin:org` for org-level operations).
|
|
239
|
+
* is supplied or the supplied token is rejected.
|
|
239
240
|
*/
|
|
240
241
|
declare const AUTH_HINT: string;
|
|
241
242
|
//#endregion
|
|
242
|
-
export { AUTH_HINT, type Auth, AuthError, type CanonicalLabel, GitHubCi, GitHubEnvironments, GitHubIssues, GitHubPluginOptions, GitHubSecrets, GitHubSource, type NormalizedTeamEntry, PluginContext, type ResolveTokenInput, type TeamEntry, type TeamPermission, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, ci,
|
|
243
|
+
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, resolveIssuesToken, resolveReadToken, resolveReleaseToken, resolveSyncToken, secrets, source, syncLabels, syncTeams, verifyToken };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { createGitHubClient, createGitHubClient as createGitHubClient$1 } from "@theholocron/github-client";
|
|
3
|
-
import { AuthError,
|
|
3
|
+
import { AuthError, createFeatureResolver } from "@theholocron/cli";
|
|
4
4
|
import { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
//#region src/auth.ts
|
|
7
|
-
const
|
|
8
|
-
envName: "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const resolveReadToken = createFeatureResolver({
|
|
8
|
+
envName: "HOLOCRON_READ_TOKEN",
|
|
9
|
+
keyringKey: "github.read"
|
|
10
|
+
});
|
|
11
|
+
const resolveIssuesToken = createFeatureResolver({
|
|
12
|
+
envName: "HOLOCRON_ISSUES_TOKEN",
|
|
13
|
+
keyringKey: "github.issues"
|
|
14
|
+
});
|
|
15
|
+
const resolveSyncToken = createFeatureResolver({
|
|
16
|
+
envName: "HOLOCRON_SYNC_TOKEN",
|
|
17
|
+
keyringKey: "github.sync"
|
|
18
|
+
});
|
|
19
|
+
const resolveReleaseToken = createFeatureResolver({
|
|
20
|
+
envName: "HOLOCRON_RELEASE_TOKEN",
|
|
21
|
+
keyringKey: "github.release"
|
|
22
|
+
});
|
|
23
|
+
const resolveAdminToken = createFeatureResolver({
|
|
24
|
+
envName: "HOLOCRON_ADMIN_TOKEN",
|
|
25
|
+
keyringKey: "github.admin"
|
|
12
26
|
});
|
|
13
27
|
//#endregion
|
|
14
28
|
//#region src/capabilities/ci.ts
|
|
@@ -618,18 +632,6 @@ async function verifyToken(token, opts = {}) {
|
|
|
618
632
|
}
|
|
619
633
|
//#endregion
|
|
620
634
|
//#region src/index.ts
|
|
621
|
-
function createContext(options) {
|
|
622
|
-
return {
|
|
623
|
-
options,
|
|
624
|
-
client: createGitHubClient$1({
|
|
625
|
-
token: resolveToken(options),
|
|
626
|
-
baseUrl: options.baseUrl,
|
|
627
|
-
fetch: options.fetch
|
|
628
|
-
}),
|
|
629
|
-
repo: options.repo,
|
|
630
|
-
repoRoot: options.repoRoot ?? process.cwd()
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
635
|
function source(ctx) {
|
|
634
636
|
return new GitHubSource(ctx.client, {
|
|
635
637
|
repo: ctx.repo,
|
|
@@ -651,24 +653,33 @@ function issues(ctx) {
|
|
|
651
653
|
return new GitHubIssues(ctx.client, opts);
|
|
652
654
|
}
|
|
653
655
|
function createPlugin(options) {
|
|
654
|
-
|
|
656
|
+
function makeCtx(resolver) {
|
|
657
|
+
return {
|
|
658
|
+
options,
|
|
659
|
+
client: createGitHubClient$1({
|
|
660
|
+
token: resolver(options),
|
|
661
|
+
baseUrl: options.baseUrl,
|
|
662
|
+
fetch: options.fetch
|
|
663
|
+
}),
|
|
664
|
+
repo: options.repo,
|
|
665
|
+
repoRoot: options.repoRoot ?? process.cwd()
|
|
666
|
+
};
|
|
667
|
+
}
|
|
655
668
|
return {
|
|
656
669
|
name: "@theholocron/holocron-plugin-github",
|
|
657
670
|
capabilities: {
|
|
658
|
-
source: () => source(
|
|
659
|
-
ci: () => ci(
|
|
660
|
-
secrets: () => secrets(
|
|
661
|
-
environments: () => environments(
|
|
662
|
-
issues: () => issues(
|
|
671
|
+
source: () => source(makeCtx(resolveAdminToken)),
|
|
672
|
+
ci: () => ci(makeCtx(resolveReadToken)),
|
|
673
|
+
secrets: () => secrets(makeCtx(resolveAdminToken)),
|
|
674
|
+
environments: () => environments(makeCtx(resolveAdminToken)),
|
|
675
|
+
issues: () => issues(makeCtx(resolveIssuesToken))
|
|
663
676
|
}
|
|
664
677
|
};
|
|
665
678
|
}
|
|
666
679
|
/**
|
|
667
680
|
* One-line hint printed by `holocron auth set github` when no token
|
|
668
|
-
* is supplied or the supplied token is rejected.
|
|
669
|
-
* https://github.com/settings/tokens with `repo` + `admin:repo_hook`
|
|
670
|
-
* scopes (add `admin:org` for org-level operations).
|
|
681
|
+
* is supplied or the supplied token is rejected.
|
|
671
682
|
*/
|
|
672
|
-
const AUTH_HINT = "generate
|
|
683
|
+
const AUTH_HINT = "generate fine-grained Personal Access Tokens at https://github.com/settings/tokens (one per feature — see docs/tokens.md for required scopes per operation), then run: holocron auth set github.<feature> <PAT>";
|
|
673
684
|
//#endregion
|
|
674
|
-
export { AUTH_HINT, AuthError, GitHubCi, GitHubEnvironments, GitHubIssues, GitHubSecrets, GitHubSource, ci,
|
|
685
|
+
export { AUTH_HINT, AuthError, GitHubCi, GitHubEnvironments, GitHubIssues, GitHubSecrets, GitHubSource, ci, createFeatureResolver, createGitHubClient, createPlugin, encryptSecret, environments, issues, normalizeTeamEntry, resolveAdminToken, resolveIssuesToken, resolveReadToken, resolveReleaseToken, resolveSyncToken, secrets, source, syncLabels, syncTeams, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-github",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
|
|
5
5
|
"homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-github#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"author": "Newton Koumantzelis",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
19
|
"types": "./dist/index.d.mts",
|
|
@@ -21,18 +22,18 @@
|
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
|
-
"@theholocron/github-client": "^1.3.
|
|
25
|
-
"@theholocron/cli": "
|
|
25
|
+
"@theholocron/github-client": "^1.3.3",
|
|
26
|
+
"@theholocron/cli": "3.0.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"libsodium-wrappers": "^0.8.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@theholocron/eslint-config": "^7.
|
|
32
|
-
"@theholocron/github-client": "^1.3.
|
|
33
|
-
"@theholocron/tsconfig": "^7.
|
|
34
|
-
"@theholocron/tsdown-config": "^7.
|
|
35
|
-
"@theholocron/vitest-config": "^7.
|
|
32
|
+
"@theholocron/eslint-config": "^7.5.0",
|
|
33
|
+
"@theholocron/github-client": "^1.3.3",
|
|
34
|
+
"@theholocron/tsconfig": "^7.5.0",
|
|
35
|
+
"@theholocron/tsdown-config": "^7.5.0",
|
|
36
|
+
"@theholocron/vitest-config": "^7.5.0",
|
|
36
37
|
"@types/node": "^26",
|
|
37
38
|
"@vitest/coverage-v8": "^4.1.10",
|
|
38
39
|
"@vitest/eslint-plugin": "^1.6.23",
|
|
@@ -40,10 +41,10 @@
|
|
|
40
41
|
"eslint-plugin-n": "^18.2.2",
|
|
41
42
|
"globals": "^17.7.0",
|
|
42
43
|
"tsdown": "^0.22.13",
|
|
43
|
-
"tsx": "4.
|
|
44
|
+
"tsx": "4.23.1",
|
|
44
45
|
"typescript": "^5.9.3",
|
|
45
46
|
"vitest": "^4.1.10",
|
|
46
|
-
"@theholocron/cli": "
|
|
47
|
+
"@theholocron/cli": "3.0.0"
|
|
47
48
|
},
|
|
48
49
|
"publishConfig": {
|
|
49
50
|
"access": "public"
|
|
@@ -60,6 +61,5 @@
|
|
|
60
61
|
"test:watch": "vitest",
|
|
61
62
|
"test:coverage": "vitest run --coverage",
|
|
62
63
|
"validate": "tsx scripts/validate.mjs"
|
|
63
|
-
}
|
|
64
|
-
"types": "./dist/index.d.mts"
|
|
64
|
+
}
|
|
65
65
|
}
|