@theholocron/holocron-plugin-github 5.0.0-alpha.560 → 5.0.0-alpha.562
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 +3 -0
- package/dist/index.mjs +46 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -478,6 +478,8 @@ export interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
478
478
|
issueTypes?: ReadonlyArray<{
|
|
479
479
|
name: string;
|
|
480
480
|
}>;
|
|
481
|
+
/** The token `provider github whoami` describes, by environment variable (default `HOLOCRON_READ_TOKEN`). */
|
|
482
|
+
whoamiToken?: string;
|
|
481
483
|
/** Override base URL for tests. Defaults to https://api.github.com. */
|
|
482
484
|
baseUrl?: string;
|
|
483
485
|
/** Override `fetch` for tests. Defaults to global `fetch`. */
|
|
@@ -514,6 +516,7 @@ export declare function createPlugin(options: GitHubPluginOptions): {
|
|
|
514
516
|
"issue-types": import("@theholocron/cli").Probe;
|
|
515
517
|
connection: import("@theholocron/cli").Probe;
|
|
516
518
|
};
|
|
519
|
+
whoami: import("@theholocron/cli").ProviderAction;
|
|
517
520
|
capabilities: {
|
|
518
521
|
source: () => Source;
|
|
519
522
|
ci: () => Ci;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { AuthError, MissingTokenError, ProviderApiError, areaLabelsForFiles, areaLabelsForTitle, connectionProbe, createFeatureResolver, pickByCreation, readKeysLimited, reportProgress, tokenExpectations } from "@theholocron/cli";
|
|
2
|
+
import { AuthError, MissingTokenError, ProviderApiError, areaLabelsForFiles, areaLabelsForTitle, connectionProbe, createFeatureResolver, pickByCreation, readKeysLimited, reportProgress, tokenExpectations, whoamiAction } from "@theholocron/cli";
|
|
3
3
|
import { createGitHubClient, createGitHubClient as createGitHubClient$1 } from "@theholocron/github-client";
|
|
4
4
|
import { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
@@ -4373,6 +4373,40 @@ async function verifyToken(token, opts = {}) {
|
|
|
4373
4373
|
};
|
|
4374
4374
|
}
|
|
4375
4375
|
}
|
|
4376
|
+
/**
|
|
4377
|
+
* GitHub's `whoami`. The plugin holds nine tokens, so the one described is the option `whoamiToken` (an environment
|
|
4378
|
+
* variable name such as `HOLOCRON_ADMIN_TOKEN`, set through `--with whoamiToken=...`), default `HOLOCRON_READ_TOKEN`.
|
|
4379
|
+
* The first row says which token that is and why; the rest are `whoamiAction()`'s, over that token's declaration only.
|
|
4380
|
+
* An unknown name is a failing row listing the known ones. GitHub sends a token's expiry on the `GET /user` response,
|
|
4381
|
+
* which `verifyToken` already reads, so no separate lifetime call is made.
|
|
4382
|
+
*/
|
|
4383
|
+
function whoamiToken(options, deps) {
|
|
4384
|
+
const name = options.whoamiToken ?? "HOLOCRON_READ_TOKEN";
|
|
4385
|
+
const how = options.whoamiToken === void 0 ? "the default" : "chosen by the whoamiToken option";
|
|
4386
|
+
const resolver = deps.resolvers[name];
|
|
4387
|
+
return async (ctx) => {
|
|
4388
|
+
if (!resolver) return [{
|
|
4389
|
+
id: "github:whoami:token",
|
|
4390
|
+
title: "github token",
|
|
4391
|
+
status: "fail",
|
|
4392
|
+
detail: `${name} is not a GitHub token of this plugin`,
|
|
4393
|
+
problems: [`known: ${Object.keys(deps.resolvers).join(", ")}`]
|
|
4394
|
+
}];
|
|
4395
|
+
const action = deps.build({
|
|
4396
|
+
provider: "github",
|
|
4397
|
+
token: () => resolver(options),
|
|
4398
|
+
tokens: deps.tokens.filter((t) => t.envName === name),
|
|
4399
|
+
proveWith: `holocron probe github token --environment <layer> (or --token-name ${name})`
|
|
4400
|
+
});
|
|
4401
|
+
return [{
|
|
4402
|
+
id: "github:whoami:token",
|
|
4403
|
+
title: "token",
|
|
4404
|
+
status: "ok",
|
|
4405
|
+
detail: `${name} (${how}; the plugin holds ${Object.keys(deps.resolvers).length} tokens)`,
|
|
4406
|
+
problems: []
|
|
4407
|
+
}, ...await action(ctx)];
|
|
4408
|
+
};
|
|
4409
|
+
}
|
|
4376
4410
|
// src/index.ts
|
|
4377
4411
|
/** Builds the `source` capability; the optional clients cover org-level and user-sync access. */
|
|
4378
4412
|
function source(ctx, orgClient, userSyncClient) {
|
|
@@ -4505,6 +4539,17 @@ function createPlugin(options) {
|
|
|
4505
4539
|
})
|
|
4506
4540
|
})
|
|
4507
4541
|
},
|
|
4542
|
+
whoami: whoamiToken(options, {
|
|
4543
|
+
resolvers: TOKEN_RESOLVERS,
|
|
4544
|
+
tokens,
|
|
4545
|
+
build: (input) => whoamiAction({
|
|
4546
|
+
...input,
|
|
4547
|
+
verify: (token) => verifyToken(token, {
|
|
4548
|
+
baseUrl: options.baseUrl,
|
|
4549
|
+
fetch: options.fetch
|
|
4550
|
+
})
|
|
4551
|
+
})
|
|
4552
|
+
}),
|
|
4508
4553
|
capabilities: {
|
|
4509
4554
|
source: () => source(makeCtx(resolveAdminToken), makeOrgClient(), makeUserSyncClient()),
|
|
4510
4555
|
ci: () => ci(makeCtx(resolveReadToken)),
|
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.562",
|
|
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,11 +44,11 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
46
|
"vitest": "^5.1.1",
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.562",
|
|
48
48
|
"@theholocron/eslint-config": "^8.9.0-alpha.24",
|
|
49
49
|
"@theholocron/fs-utils": "^1.17.0-alpha.8",
|
|
50
|
-
"@theholocron/github-client": "^1.58.0-alpha.
|
|
51
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
50
|
+
"@theholocron/github-client": "^1.58.0-alpha.62",
|
|
51
|
+
"@theholocron/http-client": "^1.58.0-alpha.62",
|
|
52
52
|
"@theholocron/misc-utils": "^1.17.0-alpha.8",
|
|
53
53
|
"@theholocron/tsconfig": "^8.9.0-alpha.24",
|
|
54
54
|
"@theholocron/tsdown-config": "^8.9.0-alpha.24",
|
|
@@ -58,7 +58,7 @@
|
|
|
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.562"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|