@theholocron/github-client 1.5.5 → 1.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/README.md CHANGED
@@ -5,7 +5,7 @@ TypeScript client for the GitHub REST API, built on `@theholocron/http-client`.
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm i @theholocron/github-client
8
+ pnpm add @theholocron/github-client
9
9
  ```
10
10
 
11
11
  ## Usage
package/dist/index.d.mts CHANGED
@@ -113,6 +113,36 @@ interface GitHubLabel {
113
113
  description: string | null;
114
114
  }
115
115
  //#endregion
116
+ //#region src/pages/pages.d.ts
117
+ type PagesBuildType = "workflow" | "legacy";
118
+ interface GitHubPages {
119
+ status: "built" | "building" | "errored" | "unknown" | null;
120
+ build_type: PagesBuildType | null;
121
+ source?: {
122
+ branch: string;
123
+ path: string;
124
+ };
125
+ https_enforced: boolean;
126
+ custom_domain: string | null;
127
+ }
128
+ interface CreatePagesPayload {
129
+ build_type: PagesBuildType;
130
+ /** Required when build_type is "legacy". */
131
+ source?: {
132
+ branch: string;
133
+ path: string;
134
+ };
135
+ }
136
+ interface UpdatePagesPayload {
137
+ build_type?: PagesBuildType;
138
+ source?: {
139
+ branch: string;
140
+ path: string;
141
+ };
142
+ cname?: string | null;
143
+ https_enforced?: boolean;
144
+ }
145
+ //#endregion
116
146
  //#region src/repos/repos.d.ts
117
147
  interface GitHubRepo {
118
148
  default_branch: string;
@@ -232,6 +262,11 @@ declare function createGitHubClient(opts: GitHubClientOptions): {
232
262
  }) => Promise<GitHubLabel>;
233
263
  deleteLabel: (repo: string, name: string) => Promise<void>;
234
264
  };
265
+ pages: {
266
+ getPages: (repo: string) => Promise<GitHubPages | null>;
267
+ createPages: (repo: string, payload: CreatePagesPayload) => Promise<GitHubPages>;
268
+ updatePages: (repo: string, payload: UpdatePagesPayload) => Promise<void>;
269
+ };
235
270
  properties: {
236
271
  setProperties: (repo: string, values: Record<string, string>) => Promise<void>;
237
272
  };
@@ -276,4 +311,4 @@ declare function createGitHubClient(opts: GitHubClientOptions): {
276
311
  };
277
312
  type GitHubClient = ReturnType<typeof createGitHubClient>;
278
313
  //#endregion
279
- export { type CodeScanningSetupResult, type CreatePullInput, type GitBlob, type GitCommit, type GitContents, GitHubClient, type GitHubClientOptions, type GitHubContents, type GitHubEnvironment, type GitHubIssue, type GitHubLabel, type GitHubMilestone, type GitHubPublicKey, type GitHubRepo, type GitHubRuleset, type GitHubUser, type GitHubWorkflowRun, type GitPull, type GitRef, type GitTree, type GitTreeItem, type IssueSearchParams, type SecretScope, type TeamPermission, type WorkflowRunFilter, createGitHubClient };
314
+ export { type CodeScanningSetupResult, type CreatePagesPayload, type CreatePullInput, type GitBlob, type GitCommit, type GitContents, GitHubClient, type GitHubClientOptions, type GitHubContents, type GitHubEnvironment, type GitHubIssue, type GitHubLabel, type GitHubMilestone, type GitHubPages, type GitHubPublicKey, type GitHubRepo, type GitHubRuleset, type GitHubUser, type GitHubWorkflowRun, type GitPull, type GitRef, type GitTree, type GitTreeItem, type IssueSearchParams, type PagesBuildType, type SecretScope, type TeamPermission, type UpdatePagesPayload, type WorkflowRunFilter, createGitHubClient };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createRestClient } from "@theholocron/http-client";
1
+ import { ProviderApiError, createRestClient } from "@theholocron/http-client";
2
2
  //#region src/utils.ts
3
3
  function createGitHubRestClient(opts) {
4
4
  return createRestClient({
@@ -148,6 +148,38 @@ function labels(rest) {
148
148
  };
149
149
  }
150
150
  //#endregion
151
+ //#region src/pages/pages.ts
152
+ function pages(rest) {
153
+ return {
154
+ /** Returns null when Pages is not yet enabled (404). */
155
+ getPages: async (repo) => {
156
+ try {
157
+ return await rest.request(`${repoBase(repo)}/pages`);
158
+ } catch (err) {
159
+ if (err instanceof ProviderApiError && err.status === 404) return null;
160
+ throw err;
161
+ }
162
+ },
163
+ /**
164
+ * Enables Pages for the first time.
165
+ * Throws on all errors except 409 Conflict (already enabled — callers
166
+ * should catch that and fall through to updatePages).
167
+ */
168
+ createPages: (repo, payload) => rest.request(`${repoBase(repo)}/pages`, {
169
+ method: "POST",
170
+ body: payload
171
+ }),
172
+ /**
173
+ * Updates Pages settings on an existing site (build type, cname, https).
174
+ * GitHub returns 204 No Content.
175
+ */
176
+ updatePages: (repo, payload) => rest.request(`${repoBase(repo)}/pages`, {
177
+ method: "PUT",
178
+ body: payload
179
+ })
180
+ };
181
+ }
182
+ //#endregion
151
183
  //#region src/properties/properties.ts
152
184
  function properties(rest) {
153
185
  return { setProperties: (repo, values) => {
@@ -305,6 +337,7 @@ function createGitHubClient(opts) {
305
337
  git: git(rest),
306
338
  issues: issues(rest),
307
339
  labels: labels(rest),
340
+ pages: pages(rest),
308
341
  properties: properties(rest),
309
342
  repos: repos(rest),
310
343
  rulesets: rulesets(rest),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/github-client",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "A TypeScript client for the GitHub REST API",
5
5
  "homepage": "https://github.com/theholocron/clients/tree/main/packages/github-client#readme",
6
6
  "bugs": "https://github.com/theholocron/clients/issues",
@@ -30,7 +30,7 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@theholocron/http-client": "^1.5.5"
33
+ "@theholocron/http-client": "^1.6.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^26.1.2",