@theholocron/holocron-plugin-github 3.5.3 → 3.6.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/dist/index.d.mts CHANGED
@@ -1,11 +1,12 @@
1
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";
2
+ import { Auth, AuthError, Ci, CiRun, CiRunFilter, Environment, Environments, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, PagesConfig, 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
4
  declare const resolveReadToken: (input?: ResolveTokenInput) => string;
5
5
  declare const resolveIssuesToken: (input?: ResolveTokenInput) => string;
6
6
  declare const resolveSyncToken: (input?: ResolveTokenInput) => string;
7
7
  declare const resolveReleaseToken: (input?: ResolveTokenInput) => string;
8
8
  declare const resolveAdminToken: (input?: ResolveTokenInput) => string;
9
+ declare const resolveDeployToken: (input?: ResolveTokenInput) => string;
9
10
  //#endregion
10
11
  //#region src/capabilities/ci.d.ts
11
12
  interface CiOptions {
@@ -116,6 +117,9 @@ declare class GitHubSecrets implements Secrets {
116
117
  interface SourceOptions {
117
118
  repo: string;
118
119
  repoRoot: string;
120
+ /** Forwarded to a secondary client created for Pages calls (HOLOCRON_DEPLOY_TOKEN). */
121
+ baseUrl?: string;
122
+ fetch?: typeof fetch;
119
123
  }
120
124
  declare class GitHubSource implements Source {
121
125
  private readonly client;
@@ -126,6 +130,8 @@ declare class GitHubSource implements Source {
126
130
  private readonly repo;
127
131
  private readonly repoRoot;
128
132
  private readonly workflowDir;
133
+ private readonly baseUrl?;
134
+ private readonly fetchImpl?;
129
135
  constructor(client: GitHubClient, opts: SourceOptions);
130
136
  whoami(): Promise<{
131
137
  login: string;
@@ -154,6 +160,7 @@ declare class GitHubSource implements Source {
154
160
  syncTopics(topics: string[]): Promise<string>;
155
161
  syncDescription(description: string): Promise<string>;
156
162
  syncHomepage(homepage: string): Promise<string>;
163
+ configurePages(config: PagesConfig, token: string): Promise<void>;
157
164
  }
158
165
  //#endregion
159
166
  //#region src/capabilities/teams.d.ts
@@ -241,4 +248,4 @@ declare function createPlugin(options: GitHubPluginOptions): {
241
248
  */
242
249
  declare const AUTH_HINT: string;
243
250
  //#endregion
244
- 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 };
251
+ 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, resolveReadToken, resolveReleaseToken, resolveSyncToken, secrets, source, syncLabels, syncTeams, verifyToken };
package/dist/index.mjs CHANGED
@@ -24,6 +24,10 @@ const resolveAdminToken = createFeatureResolver({
24
24
  envName: "HOLOCRON_ADMIN_TOKEN",
25
25
  keyringKey: "github.admin"
26
26
  });
27
+ const resolveDeployToken = createFeatureResolver({
28
+ envName: "HOLOCRON_DEPLOY_TOKEN",
29
+ keyringKey: "github.deploy"
30
+ });
27
31
  //#endregion
28
32
  //#region src/capabilities/ci.ts
29
33
  var GitHubCi = class {
@@ -479,6 +483,8 @@ var GitHubSource = class {
479
483
  repo;
480
484
  repoRoot;
481
485
  workflowDir;
486
+ baseUrl;
487
+ fetchImpl;
482
488
  constructor(client, opts) {
483
489
  this.client = client;
484
490
  const [owner = "", name = ""] = opts.repo.split("/", 2);
@@ -487,6 +493,8 @@ var GitHubSource = class {
487
493
  this.repo = opts.repo;
488
494
  this.repoRoot = opts.repoRoot;
489
495
  this.workflowDir = join(opts.repoRoot, ".github", "workflows");
496
+ this.baseUrl = opts.baseUrl;
497
+ this.fetchImpl = opts.fetch;
490
498
  }
491
499
  async whoami() {
492
500
  return { login: (await this.client.user.getCurrentUser()).login };
@@ -588,6 +596,28 @@ var GitHubSource = class {
588
596
  await this.client.repos.updateRepo(this.repo, { homepage });
589
597
  return "homepage updated";
590
598
  }
599
+ async configurePages(config, token) {
600
+ const pagesClient = createGitHubClient$1({
601
+ token,
602
+ baseUrl: this.baseUrl,
603
+ fetch: this.fetchImpl
604
+ });
605
+ const buildType = config.build === "workflow" ? "workflow" : "legacy";
606
+ const branchSource = config.build === "branch" ? {
607
+ branch: "gh-pages",
608
+ path: "/"
609
+ } : void 0;
610
+ if (!await pagesClient.pages.getPages(this.repo)) {
611
+ const createPayload = { build_type: buildType };
612
+ if (branchSource) createPayload.source = branchSource;
613
+ await pagesClient.pages.createPages(this.repo, createPayload);
614
+ }
615
+ const updatePayload = { build_type: buildType };
616
+ if (branchSource) updatePayload.source = branchSource;
617
+ if (config.domain !== void 0) updatePayload.cname = config.domain;
618
+ if (config.https !== void 0) updatePayload.https_enforced = config.https;
619
+ await pagesClient.pages.updatePages(this.repo, updatePayload);
620
+ }
591
621
  };
592
622
  function isENOENT(err) {
593
623
  return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
@@ -639,7 +669,9 @@ async function verifyToken(token, opts = {}) {
639
669
  function source(ctx) {
640
670
  return new GitHubSource(ctx.client, {
641
671
  repo: ctx.repo,
642
- repoRoot: ctx.repoRoot
672
+ repoRoot: ctx.repoRoot,
673
+ baseUrl: ctx.options.baseUrl,
674
+ fetch: ctx.options.fetch
643
675
  });
644
676
  }
645
677
  function secrets(ctx) {
@@ -686,4 +718,4 @@ function createPlugin(options) {
686
718
  */
687
719
  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>";
688
720
  //#endregion
689
- 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 };
721
+ export { AUTH_HINT, AuthError, GitHubCi, GitHubEnvironments, GitHubIssues, GitHubSecrets, GitHubSource, ci, createFeatureResolver, createGitHubClient, createPlugin, encryptSecret, environments, issues, normalizeTeamEntry, resolveAdminToken, resolveDeployToken, 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.5.3",
3
+ "version": "3.6.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",
@@ -22,15 +22,15 @@
22
22
  }
23
23
  },
24
24
  "peerDependencies": {
25
- "@theholocron/github-client": "^1.3.5",
26
- "@theholocron/cli": "3.5.3"
25
+ "@theholocron/github-client": "^1.6.0",
26
+ "@theholocron/cli": "3.6.0"
27
27
  },
28
28
  "dependencies": {
29
29
  "libsodium-wrappers": "^0.8.4"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@theholocron/eslint-config": "^7.6.1",
33
- "@theholocron/github-client": "^1.3.5",
33
+ "@theholocron/github-client": "^1.6.0",
34
34
  "@theholocron/tsconfig": "^7.6.1",
35
35
  "@theholocron/tsdown-config": "^7.6.1",
36
36
  "@theholocron/vitest-config": "^7.6.1",
@@ -44,7 +44,7 @@
44
44
  "tsx": "4.23.1",
45
45
  "typescript": "^5.9.3",
46
46
  "vitest": "^4.1.10",
47
- "@theholocron/cli": "3.5.3"
47
+ "@theholocron/cli": "3.6.0"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"