@deepseek-ai/dsh-experimental-forge-github 0.0.0-stage → 0.2.2-alpha.2
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/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +104 -2
- package/README.zh.md +105 -0
- package/lib/index.js +813 -0
- package/lib/types/gh.d.ts +43 -0
- package/lib/types/graphql.d.ts +45 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/provider.d.ts +49 -0
- package/lib/types/urls.d.ts +44 -0
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +44 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { MAX_TIMER_DELAY_MS } from "@deepseek-ai/dsh-timeout";
|
|
3
|
+
import { scrubbedParentEnv } from "@deepseek-ai/dsh-subprocess";
|
|
4
|
+
import { execa } from "execa";
|
|
5
|
+
import { changeRequestKey } from "@deepseek-ai/dsh-experimental-forge";
|
|
6
|
+
import { z as z$1 } from "zod";
|
|
7
|
+
//#region lib/types/gh.js
|
|
8
|
+
/** Runs the GitHub CLI on the host with a scrubbed, non-interactive environment. */
|
|
9
|
+
/** Thrown when the `gh` executable cannot start, for example because it is not installed. */
|
|
10
|
+
var GhUnavailableError = class extends Error {
|
|
11
|
+
name = "GhUnavailableError";
|
|
12
|
+
};
|
|
13
|
+
/** Thrown when one invocation outlives `timeoutMs`; the process is killed. */
|
|
14
|
+
var GhTimeoutError = class extends Error {
|
|
15
|
+
name = "GhTimeoutError";
|
|
16
|
+
};
|
|
17
|
+
/** Thrown when an output stream exceeds `maxOutputBytes`; the process is killed. */
|
|
18
|
+
var GhOutputLimitError = class extends Error {
|
|
19
|
+
name = "GhOutputLimitError";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Build a runner for `gh` on the host. The child inherits the scrubbed parent
|
|
23
|
+
* environment, so variables whose names contain KEY, PASSWORD, SECRET, or
|
|
24
|
+
* TOKEN never reach it and `gh` authenticates from its own credential store.
|
|
25
|
+
* Prompts, update notices, pagers, and colors are disabled.
|
|
26
|
+
* @param config - executable and limits.
|
|
27
|
+
* @returns the runner.
|
|
28
|
+
*/
|
|
29
|
+
function ghRunner(config) {
|
|
30
|
+
return async (args, signal) => {
|
|
31
|
+
const result = await execa(config.ghCommand, args, {
|
|
32
|
+
env: {
|
|
33
|
+
...scrubbedParentEnv(),
|
|
34
|
+
GH_PROMPT_DISABLED: "1",
|
|
35
|
+
GH_NO_UPDATE_NOTIFIER: "1",
|
|
36
|
+
GH_PAGER: "",
|
|
37
|
+
NO_COLOR: "1",
|
|
38
|
+
CLICOLOR: "0"
|
|
39
|
+
},
|
|
40
|
+
extendEnv: false,
|
|
41
|
+
stdin: "ignore",
|
|
42
|
+
reject: false,
|
|
43
|
+
timeout: config.timeoutMs,
|
|
44
|
+
cancelSignal: signal,
|
|
45
|
+
maxBuffer: config.maxOutputBytes
|
|
46
|
+
});
|
|
47
|
+
const command = ["gh", ...args.slice(0, 1)].join(" ");
|
|
48
|
+
if (result.isCanceled) throw signal.reason;
|
|
49
|
+
if (result.timedOut) throw new GhTimeoutError(`${command} timed out after ${config.timeoutMs}ms`);
|
|
50
|
+
if (result.isMaxBuffer) throw new GhOutputLimitError(`${command} output exceeds maxOutputBytes`);
|
|
51
|
+
if (result.exitCode === void 0) throw new GhUnavailableError(`gh could not start: ${String(result.shortMessage)}`);
|
|
52
|
+
return {
|
|
53
|
+
exitCode: result.exitCode,
|
|
54
|
+
stdout: result.stdout,
|
|
55
|
+
stderr: result.stderr
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region lib/types/urls.js
|
|
61
|
+
/** GitHub remote URL and pull request URL parsing, and validation of the parts inlined into requests. */
|
|
62
|
+
/** Characters GitHub permits in owner and repository names. */
|
|
63
|
+
const SEGMENT = /^[A-Za-z0-9_.-]+$/;
|
|
64
|
+
/**
|
|
65
|
+
* Check one owner or repository name segment.
|
|
66
|
+
* @param value - candidate segment.
|
|
67
|
+
* @returns whether GitHub permits the segment and it is not a dot path.
|
|
68
|
+
*/
|
|
69
|
+
function isSegment(value) {
|
|
70
|
+
return SEGMENT.test(value) && value !== "." && value !== "..";
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validate a pull request before its owner, name, and number are inlined into
|
|
74
|
+
* a GraphQL document, a `gh` argument, or an API path.
|
|
75
|
+
* @param ref - pull request on a GitHub host.
|
|
76
|
+
* @returns its repository.
|
|
77
|
+
* @throws when the owner or name is not a permitted segment or the number is not a positive integer.
|
|
78
|
+
*/
|
|
79
|
+
function checkedRepository(ref) {
|
|
80
|
+
const { owner, name } = ref.repository;
|
|
81
|
+
if (!isSegment(owner) || !isSegment(name)) throw new Error(`forge-github: invalid repository ${JSON.stringify(`${owner}/${name}`)}`);
|
|
82
|
+
if (!Number.isSafeInteger(ref.number) || ref.number <= 0) throw new Error(`forge-github: invalid pull request number ${ref.number}`);
|
|
83
|
+
return ref.repository;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse a Git remote URL. Accepts `http(s)://[user@]host[:port]/owner/name`,
|
|
87
|
+
* `ssh://[user@]host[:port]/owner/name`, `git://host/owner/name`, and the
|
|
88
|
+
* scp-like `[user@]host:owner/name`, each with an optional `.git` suffix or
|
|
89
|
+
* trailing slash. HTTP(S) ports belong to the host identity; SSH and Git
|
|
90
|
+
* transport ports do not.
|
|
91
|
+
* @param url - fetch or push URL as Git reports it.
|
|
92
|
+
* @returns the location, or undefined for other URL shapes.
|
|
93
|
+
*/
|
|
94
|
+
function parseRemoteUrl(url) {
|
|
95
|
+
const trimmed = url.trim();
|
|
96
|
+
const scheme = /^https?:\/\/(?:[^@/]+@)?([^/:]+(?::\d+)?)\/(.+)$/i.exec(trimmed) ?? /^(?:ssh|git):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/i.exec(trimmed);
|
|
97
|
+
const scp = scheme === null ? /^(?:[^@/:]+@)?([^/:]+):(?!\/\/)(.+)$/.exec(trimmed) : null;
|
|
98
|
+
const match = scheme ?? scp;
|
|
99
|
+
if (match === null) return void 0;
|
|
100
|
+
const [, host = "", path = ""] = match;
|
|
101
|
+
const parts = path.replace(/\/+$/, "").replace(/\.git$/i, "").split("/");
|
|
102
|
+
if (parts.length !== 2) return void 0;
|
|
103
|
+
const [owner = "", name = ""] = parts;
|
|
104
|
+
if (!isSegment(owner) || !isSegment(name)) return void 0;
|
|
105
|
+
return {
|
|
106
|
+
host: host.toLowerCase(),
|
|
107
|
+
owner,
|
|
108
|
+
name
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Parse a pull request web URL such as `https://github.com/owner/name/pull/12/files`.
|
|
113
|
+
* @param url - web URL of a pull request.
|
|
114
|
+
* @returns the location and number, or undefined for other URLs.
|
|
115
|
+
*/
|
|
116
|
+
function parsePullRequestUrl(url) {
|
|
117
|
+
const match = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:[/?#].*)?$/i.exec(url.trim());
|
|
118
|
+
if (match === null) return void 0;
|
|
119
|
+
const [, host = "", owner = "", name = "", digits = ""] = match;
|
|
120
|
+
const number = Number(digits);
|
|
121
|
+
if (!isSegment(owner) || !isSegment(name) || !Number.isSafeInteger(number) || number <= 0) return void 0;
|
|
122
|
+
return {
|
|
123
|
+
host: host.toLowerCase(),
|
|
124
|
+
owner,
|
|
125
|
+
name,
|
|
126
|
+
number
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region lib/types/graphql.js
|
|
131
|
+
/** GitHub GraphQL documents and their mapping into provider-neutral results. */
|
|
132
|
+
const PULL_REQUEST_FIELDS = `number url title state isDraft updatedAt closedAt
|
|
133
|
+
author { login }
|
|
134
|
+
headRefName headRefOid baseRefName additions deletions mergeable mergeStateStatus reviewDecision
|
|
135
|
+
reviewThreads(first: 100) { nodes { isResolved } }
|
|
136
|
+
commits(last: 1) { nodes { commit { statusCheckRollup { state contexts(first: 100) {
|
|
137
|
+
pageInfo { hasNextPage }
|
|
138
|
+
nodes {
|
|
139
|
+
__typename
|
|
140
|
+
... on CheckRun { name status conclusion detailsUrl startedAt completedAt checkSuite { workflowRun { workflow { name } } } }
|
|
141
|
+
... on StatusContext { context state targetUrl }
|
|
142
|
+
}
|
|
143
|
+
} } } } }`;
|
|
144
|
+
const REPOSITORY_FIELDS = "squashMergeAllowed mergeCommitAllowed rebaseMergeAllowed viewerPermission viewerDefaultMergeMethod";
|
|
145
|
+
/** Head-branch lookup; variables `owner`, `name`, and `branch` are passed as strings. */
|
|
146
|
+
const HEAD_QUERY = `query($owner: String!, $name: String!, $branch: String!) {
|
|
147
|
+
repository(owner: $owner, name: $name) {
|
|
148
|
+
defaultBranchRef { name }
|
|
149
|
+
pullRequests(headRefName: $branch, states: OPEN, first: 20, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { number isCrossRepository } }
|
|
150
|
+
}
|
|
151
|
+
}`;
|
|
152
|
+
const checkRunSchema = z$1.object({
|
|
153
|
+
__typename: z$1.literal("CheckRun"),
|
|
154
|
+
name: z$1.string(),
|
|
155
|
+
status: z$1.string(),
|
|
156
|
+
conclusion: z$1.string().nullable(),
|
|
157
|
+
detailsUrl: z$1.string().nullable(),
|
|
158
|
+
startedAt: z$1.string().nullable(),
|
|
159
|
+
completedAt: z$1.string().nullable(),
|
|
160
|
+
checkSuite: z$1.object({ workflowRun: z$1.object({ workflow: z$1.object({ name: z$1.string() }) }).nullable() }).nullable()
|
|
161
|
+
});
|
|
162
|
+
const statusContextSchema = z$1.object({
|
|
163
|
+
__typename: z$1.literal("StatusContext"),
|
|
164
|
+
context: z$1.string(),
|
|
165
|
+
state: z$1.string(),
|
|
166
|
+
targetUrl: z$1.string().nullable()
|
|
167
|
+
});
|
|
168
|
+
const pullRequestSchema = z$1.object({
|
|
169
|
+
url: z$1.string(),
|
|
170
|
+
title: z$1.string(),
|
|
171
|
+
state: z$1.enum([
|
|
172
|
+
"OPEN",
|
|
173
|
+
"CLOSED",
|
|
174
|
+
"MERGED"
|
|
175
|
+
]),
|
|
176
|
+
isDraft: z$1.boolean(),
|
|
177
|
+
updatedAt: z$1.string(),
|
|
178
|
+
closedAt: z$1.string().nullable(),
|
|
179
|
+
author: z$1.object({ login: z$1.string() }).nullable(),
|
|
180
|
+
headRefName: z$1.string(),
|
|
181
|
+
headRefOid: z$1.string(),
|
|
182
|
+
baseRefName: z$1.string(),
|
|
183
|
+
additions: z$1.number().int().nonnegative(),
|
|
184
|
+
deletions: z$1.number().int().nonnegative(),
|
|
185
|
+
mergeable: z$1.string(),
|
|
186
|
+
mergeStateStatus: z$1.string(),
|
|
187
|
+
reviewDecision: z$1.string().nullable(),
|
|
188
|
+
reviewThreads: z$1.object({ nodes: z$1.array(z$1.object({ isResolved: z$1.boolean() })) }),
|
|
189
|
+
commits: z$1.object({ nodes: z$1.array(z$1.object({ commit: z$1.object({ statusCheckRollup: z$1.object({
|
|
190
|
+
state: z$1.string(),
|
|
191
|
+
contexts: z$1.object({
|
|
192
|
+
pageInfo: z$1.object({ hasNextPage: z$1.boolean() }),
|
|
193
|
+
nodes: z$1.array(z$1.unknown())
|
|
194
|
+
})
|
|
195
|
+
}).nullable() }) })) })
|
|
196
|
+
});
|
|
197
|
+
const repositorySchema = z$1.object({
|
|
198
|
+
squashMergeAllowed: z$1.boolean(),
|
|
199
|
+
mergeCommitAllowed: z$1.boolean(),
|
|
200
|
+
rebaseMergeAllowed: z$1.boolean(),
|
|
201
|
+
viewerPermission: z$1.string().nullable(),
|
|
202
|
+
viewerDefaultMergeMethod: z$1.string()
|
|
203
|
+
});
|
|
204
|
+
const responseSchema = z$1.object({
|
|
205
|
+
data: z$1.record(z$1.string(), z$1.record(z$1.string(), z$1.unknown()).nullable()).nullable().optional(),
|
|
206
|
+
errors: z$1.array(z$1.object({
|
|
207
|
+
type: z$1.string().optional(),
|
|
208
|
+
path: z$1.array(z$1.union([z$1.string(), z$1.number()])).optional(),
|
|
209
|
+
message: z$1.string()
|
|
210
|
+
})).optional()
|
|
211
|
+
}).refine(hasGraphqlFields);
|
|
212
|
+
/**
|
|
213
|
+
* Distinguish GraphQL response fields from HTTP error bodies.
|
|
214
|
+
* @param body - parsed JSON returned by GitHub.
|
|
215
|
+
* @returns whether the object carries GraphQL data or errors; field validation remains with the query mapper.
|
|
216
|
+
*/
|
|
217
|
+
function hasGraphqlFields(body) {
|
|
218
|
+
return typeof body === "object" && body !== null && ("data" in body || "errors" in body);
|
|
219
|
+
}
|
|
220
|
+
const headSchema = z$1.object({ data: z$1.object({ repository: z$1.object({
|
|
221
|
+
defaultBranchRef: z$1.object({ name: z$1.string() }).nullable(),
|
|
222
|
+
pullRequests: z$1.object({ nodes: z$1.array(z$1.object({
|
|
223
|
+
number: z$1.number(),
|
|
224
|
+
isCrossRepository: z$1.boolean()
|
|
225
|
+
})) })
|
|
226
|
+
}).nullable() }) });
|
|
227
|
+
/** GitHub merge states in which the merge button works: mergeable, with passing or non-required failing checks. */
|
|
228
|
+
const MERGEABLE_NOW = new Set([
|
|
229
|
+
"CLEAN",
|
|
230
|
+
"HAS_HOOKS",
|
|
231
|
+
"UNSTABLE"
|
|
232
|
+
]);
|
|
233
|
+
/** Repository permissions that may merge. */
|
|
234
|
+
const MERGERS = new Set([
|
|
235
|
+
"ADMIN",
|
|
236
|
+
"MAINTAIN",
|
|
237
|
+
"WRITE"
|
|
238
|
+
]);
|
|
239
|
+
/** Merge methods in menu order, with the repository setting that allows each and GitHub's name for it. */
|
|
240
|
+
const METHODS = [
|
|
241
|
+
{
|
|
242
|
+
method: "squash",
|
|
243
|
+
allowed: "squashMergeAllowed",
|
|
244
|
+
name: "SQUASH"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
method: "merge",
|
|
248
|
+
allowed: "mergeCommitAllowed",
|
|
249
|
+
name: "MERGE"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
method: "rebase",
|
|
253
|
+
allowed: "rebaseMergeAllowed",
|
|
254
|
+
name: "REBASE"
|
|
255
|
+
}
|
|
256
|
+
];
|
|
257
|
+
/**
|
|
258
|
+
* Build one query that reads every change request in `refs`, grouping them by
|
|
259
|
+
* repository. Owners, names, and numbers are validated before they are inlined.
|
|
260
|
+
* @param refs - change requests on one host.
|
|
261
|
+
* @returns the document and its alias targets.
|
|
262
|
+
* @throws when an owner, name, or number cannot be inlined safely.
|
|
263
|
+
*/
|
|
264
|
+
function snapshotQuery(refs) {
|
|
265
|
+
const repositories = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const ref of refs) {
|
|
267
|
+
const { owner, name } = checkedRepository(ref);
|
|
268
|
+
const id = `${owner}/${name}`.toLowerCase();
|
|
269
|
+
let entry = repositories.get(id);
|
|
270
|
+
if (entry === void 0) {
|
|
271
|
+
entry = {
|
|
272
|
+
repository: ref.repository,
|
|
273
|
+
numbers: /* @__PURE__ */ new Map()
|
|
274
|
+
};
|
|
275
|
+
repositories.set(id, entry);
|
|
276
|
+
}
|
|
277
|
+
if (!entry.numbers.has(ref.number)) entry.numbers.set(ref.number, ref);
|
|
278
|
+
}
|
|
279
|
+
const targets = /* @__PURE__ */ new Map();
|
|
280
|
+
const fields = [];
|
|
281
|
+
for (const [r, { repository, numbers }] of [...repositories.values()].entries()) {
|
|
282
|
+
const pulls = [];
|
|
283
|
+
for (const [p, [number, ref]] of [...numbers].entries()) {
|
|
284
|
+
pulls.push(`p${p}: pullRequest(number: ${number}) { ...ChangeRequestFields }`);
|
|
285
|
+
targets.set(`r${r}.p${p}`, ref);
|
|
286
|
+
}
|
|
287
|
+
const owner = JSON.stringify(repository.owner);
|
|
288
|
+
fields.push(`r${r}: repository(owner: ${owner}, name: ${JSON.stringify(repository.name)}) { ${REPOSITORY_FIELDS} ${pulls.join(" ")} }`);
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
document: `query { ${fields.join(" ")} }\nfragment ChangeRequestFields on PullRequest { ${PULL_REQUEST_FIELDS} }`,
|
|
292
|
+
targets
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Map a snapshot response, including GitHub's partial-error form, into one
|
|
297
|
+
* result per alias target. Path-scoped errors apply to their repository or
|
|
298
|
+
* pull request; errors without a path apply to every unresolved target. A
|
|
299
|
+
* repository without readable merge settings offers no merge.
|
|
300
|
+
* @param body - parsed JSON printed by `gh api graphql`.
|
|
301
|
+
* @param query - the query that produced the response.
|
|
302
|
+
* @returns a snapshot or failure for every target.
|
|
303
|
+
*/
|
|
304
|
+
function mapSnapshotResponse(body, query) {
|
|
305
|
+
const results = /* @__PURE__ */ new Map();
|
|
306
|
+
const parsed = responseSchema.safeParse(body);
|
|
307
|
+
for (const [alias, ref] of query.targets) {
|
|
308
|
+
const key = changeRequestKey(ref);
|
|
309
|
+
if (!parsed.success) {
|
|
310
|
+
results.set(key, {
|
|
311
|
+
code: "unavailable",
|
|
312
|
+
message: "unexpected GitHub response"
|
|
313
|
+
});
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
const [repositoryAlias = "", pullAlias = ""] = alias.split(".");
|
|
317
|
+
const errors = parsed.data.errors ?? [];
|
|
318
|
+
const error = errors.find((entry) => entry.path?.[0] === repositoryAlias && (entry.path.length === 1 || entry.path[1] === pullAlias)) ?? errors.find((entry) => entry.path === void 0);
|
|
319
|
+
const raw = parsed.data.data?.[repositoryAlias]?.[pullAlias];
|
|
320
|
+
const node = pullRequestSchema.safeParse(raw);
|
|
321
|
+
const settings = repositorySchema.safeParse(parsed.data.data?.[repositoryAlias]);
|
|
322
|
+
if (node.success) results.set(key, toSnapshot(ref, node.data, settings.success ? settings.data : void 0));
|
|
323
|
+
else if (error !== void 0) results.set(key, {
|
|
324
|
+
code: error.type === "NOT_FOUND" ? "not-found" : "unavailable",
|
|
325
|
+
message: error.message
|
|
326
|
+
});
|
|
327
|
+
else if (raw === null || raw === void 0) results.set(key, {
|
|
328
|
+
code: "not-found",
|
|
329
|
+
message: "pull request not found"
|
|
330
|
+
});
|
|
331
|
+
else results.set(key, {
|
|
332
|
+
code: "unavailable",
|
|
333
|
+
message: "unexpected pull request fields"
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
return results;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Map a head-branch lookup of {@link HEAD_QUERY}, which selects open pull requests, into change requests.
|
|
340
|
+
* @param body - parsed JSON printed by `gh api graphql`.
|
|
341
|
+
* @param repository - repository that was queried.
|
|
342
|
+
* @param branch - head branch that was queried.
|
|
343
|
+
* @returns open non-fork change requests for `branch`, or none when it is the default branch.
|
|
344
|
+
* @throws when the response is malformed or the repository is not visible.
|
|
345
|
+
*/
|
|
346
|
+
function mapHeadResponse(body, repository, branch) {
|
|
347
|
+
const parsed = headSchema.safeParse(body);
|
|
348
|
+
if (!parsed.success) throw new Error("forge-github: unexpected GitHub response to the head branch lookup");
|
|
349
|
+
const found = parsed.data.data.repository;
|
|
350
|
+
if (found === null) throw new Error(`forge-github: repository ${repository.owner}/${repository.name} is not visible`);
|
|
351
|
+
if (found.defaultBranchRef?.name === branch) return [];
|
|
352
|
+
return found.pullRequests.nodes.filter((node) => !node.isCrossRepository).map((node) => ({
|
|
353
|
+
repository,
|
|
354
|
+
number: node.number
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
function toSnapshot(ref, node, settings) {
|
|
358
|
+
const rollup = node.commits.nodes[0]?.commit.statusCheckRollup ?? null;
|
|
359
|
+
const checks = [];
|
|
360
|
+
for (const context of rollup?.contexts.nodes ?? []) {
|
|
361
|
+
const run = checkRunSchema.safeParse(context);
|
|
362
|
+
if (run.success) {
|
|
363
|
+
checks.push({
|
|
364
|
+
name: run.data.name,
|
|
365
|
+
state: checkRunState(run.data.status, run.data.conclusion),
|
|
366
|
+
url: run.data.detailsUrl,
|
|
367
|
+
workflow: run.data.checkSuite?.workflowRun?.workflow.name ?? null,
|
|
368
|
+
startedAt: run.data.startedAt,
|
|
369
|
+
completedAt: run.data.completedAt
|
|
370
|
+
});
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const status = statusContextSchema.safeParse(context);
|
|
374
|
+
if (status.success) checks.push({
|
|
375
|
+
name: status.data.context,
|
|
376
|
+
state: statusContextState(status.data.state),
|
|
377
|
+
url: status.data.targetUrl,
|
|
378
|
+
workflow: null,
|
|
379
|
+
startedAt: null,
|
|
380
|
+
completedAt: null
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
ref,
|
|
385
|
+
url: node.url,
|
|
386
|
+
title: node.title,
|
|
387
|
+
state: changeRequestState(node.state),
|
|
388
|
+
draft: node.isDraft,
|
|
389
|
+
author: node.author?.login ?? null,
|
|
390
|
+
headBranch: node.headRefName,
|
|
391
|
+
headSha: node.headRefOid,
|
|
392
|
+
baseBranch: node.baseRefName,
|
|
393
|
+
additions: node.additions,
|
|
394
|
+
deletions: node.deletions,
|
|
395
|
+
mergeability: mergeability(node.mergeable),
|
|
396
|
+
mergeReady: settings !== void 0 && MERGERS.has(settings.viewerPermission ?? "") && node.state === "OPEN" && !node.isDraft && MERGEABLE_NOW.has(node.mergeStateStatus),
|
|
397
|
+
mergeMethods: settings === void 0 ? [] : mergeMethods(settings),
|
|
398
|
+
reviewDecision: reviewDecision(node.reviewDecision),
|
|
399
|
+
checks,
|
|
400
|
+
checksRollup: checksRollup(rollup?.state),
|
|
401
|
+
checksTruncated: rollup?.contexts.pageInfo.hasNextPage ?? false,
|
|
402
|
+
unresolvedThreads: node.reviewThreads.nodes.filter((thread) => !thread.isResolved).length,
|
|
403
|
+
updatedAt: node.updatedAt,
|
|
404
|
+
closedAt: node.closedAt
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/** The methods the repository allows, the viewer's default first. */
|
|
408
|
+
function mergeMethods(settings) {
|
|
409
|
+
const allowed = METHODS.filter((entry) => settings[entry.allowed]);
|
|
410
|
+
const usual = allowed.filter((entry) => entry.name === settings.viewerDefaultMergeMethod);
|
|
411
|
+
return [...usual, ...allowed.filter((entry) => !usual.includes(entry))].map((entry) => entry.method);
|
|
412
|
+
}
|
|
413
|
+
function changeRequestState(state) {
|
|
414
|
+
switch (state) {
|
|
415
|
+
case "OPEN": return "open";
|
|
416
|
+
case "CLOSED": return "closed";
|
|
417
|
+
case "MERGED": return "merged";
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/** GitHub enum values outside the documented set read as the most conservative state. */
|
|
421
|
+
function checkRunState(status, conclusion) {
|
|
422
|
+
if (status !== "COMPLETED") return "pending";
|
|
423
|
+
switch (conclusion) {
|
|
424
|
+
case "SUCCESS": return "success";
|
|
425
|
+
case "FAILURE":
|
|
426
|
+
case "TIMED_OUT":
|
|
427
|
+
case "STARTUP_FAILURE":
|
|
428
|
+
case "ACTION_REQUIRED": return "failure";
|
|
429
|
+
case "CANCELLED": return "cancelled";
|
|
430
|
+
case "SKIPPED": return "skipped";
|
|
431
|
+
default: return "neutral";
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function statusContextState(state) {
|
|
435
|
+
switch (state) {
|
|
436
|
+
case "SUCCESS": return "success";
|
|
437
|
+
case "FAILURE":
|
|
438
|
+
case "ERROR": return "failure";
|
|
439
|
+
default: return "pending";
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function checksRollup(state) {
|
|
443
|
+
switch (state) {
|
|
444
|
+
case void 0: return "none";
|
|
445
|
+
case "SUCCESS": return "success";
|
|
446
|
+
case "FAILURE":
|
|
447
|
+
case "ERROR": return "failure";
|
|
448
|
+
default: return "pending";
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function mergeability(value) {
|
|
452
|
+
switch (value) {
|
|
453
|
+
case "MERGEABLE": return "mergeable";
|
|
454
|
+
case "CONFLICTING": return "conflicting";
|
|
455
|
+
default: return "unknown";
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function reviewDecision(value) {
|
|
459
|
+
switch (value) {
|
|
460
|
+
case "APPROVED": return "approved";
|
|
461
|
+
case "CHANGES_REQUESTED": return "changes-requested";
|
|
462
|
+
case "REVIEW_REQUIRED": return "review-required";
|
|
463
|
+
default: return "none";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region lib/types/provider.js
|
|
468
|
+
/** GitHub implementation of the forge provider contract. */
|
|
469
|
+
const AUTHENTICATION = /gh auth login|authentication|bad credentials|HTTP 401/i;
|
|
470
|
+
/** Status code `gh api` appends to the message of a failed request. */
|
|
471
|
+
const HTTP_STATUS = /\(HTTP (\d{3})\)/;
|
|
472
|
+
/**
|
|
473
|
+
* GitHub's error code for an answer over its size limits, such as a diff over
|
|
474
|
+
* 300 files: `gh pr diff` prints it after the field, and `gh api` returns it in the JSON error body.
|
|
475
|
+
*/
|
|
476
|
+
const TOO_LARGE = /\btoo_large\b/;
|
|
477
|
+
/** A full SHA-1 or SHA-256 object name. */
|
|
478
|
+
const COMMIT = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
479
|
+
/** Reads GitHub and GitHub Enterprise pull requests through a `gh` runner. */
|
|
480
|
+
var GitHubProvider = class {
|
|
481
|
+
gh;
|
|
482
|
+
forge = "github";
|
|
483
|
+
hosts;
|
|
484
|
+
/**
|
|
485
|
+
* @param gh - runner that executes `gh` on the host.
|
|
486
|
+
* @param hosts - host names this provider serves, such as `github.com` and Enterprise hosts.
|
|
487
|
+
*/
|
|
488
|
+
constructor(gh, hosts) {
|
|
489
|
+
this.gh = gh;
|
|
490
|
+
this.hosts = new Set(hosts.map((host) => host.toLowerCase()));
|
|
491
|
+
}
|
|
492
|
+
repositoryFromRemote(url) {
|
|
493
|
+
const location = parseRemoteUrl(url);
|
|
494
|
+
if (location === void 0 || !this.hosts.has(location.host)) return void 0;
|
|
495
|
+
return {
|
|
496
|
+
forge: this.forge,
|
|
497
|
+
...location
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
changeRequestFromUrl(url) {
|
|
501
|
+
const parsed = parsePullRequestUrl(url);
|
|
502
|
+
if (parsed === void 0 || !this.hosts.has(parsed.host)) return void 0;
|
|
503
|
+
return {
|
|
504
|
+
repository: {
|
|
505
|
+
forge: this.forge,
|
|
506
|
+
host: parsed.host,
|
|
507
|
+
owner: parsed.owner,
|
|
508
|
+
name: parsed.name
|
|
509
|
+
},
|
|
510
|
+
number: parsed.number
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
changeRequestUrl(ref) {
|
|
514
|
+
const { host, owner, name } = ref.repository;
|
|
515
|
+
return `https://${host}/${owner}/${name}/pull/${ref.number}`;
|
|
516
|
+
}
|
|
517
|
+
async fetch(refs, signal) {
|
|
518
|
+
const byHost = /* @__PURE__ */ new Map();
|
|
519
|
+
const results = /* @__PURE__ */ new Map();
|
|
520
|
+
for (const ref of refs) {
|
|
521
|
+
const failure = this.hostFailure(ref.repository.host);
|
|
522
|
+
if (failure !== void 0) {
|
|
523
|
+
results.set(changeRequestKey(ref), failure);
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
const group = byHost.get(ref.repository.host);
|
|
527
|
+
if (group === void 0) byHost.set(ref.repository.host, [ref]);
|
|
528
|
+
else group.push(ref);
|
|
529
|
+
}
|
|
530
|
+
for (const [host, group] of byHost) for (const [key, result] of await this.fetchHost(host, group, signal)) results.set(key, result);
|
|
531
|
+
return results;
|
|
532
|
+
}
|
|
533
|
+
async findByHead(repository, branch, signal) {
|
|
534
|
+
const failure = this.hostFailure(repository.host);
|
|
535
|
+
if (failure !== void 0) throw new Error(failure.message);
|
|
536
|
+
const output = await this.gh([
|
|
537
|
+
"api",
|
|
538
|
+
"graphql",
|
|
539
|
+
"--hostname",
|
|
540
|
+
repository.host,
|
|
541
|
+
"-f",
|
|
542
|
+
`query=${HEAD_QUERY}`,
|
|
543
|
+
"-f",
|
|
544
|
+
`owner=${repository.owner}`,
|
|
545
|
+
"-f",
|
|
546
|
+
`name=${repository.name}`,
|
|
547
|
+
"-f",
|
|
548
|
+
`branch=${branch}`
|
|
549
|
+
], signal);
|
|
550
|
+
const body = parseJson(output.stdout);
|
|
551
|
+
if (!hasGraphqlFields(body)) throw new Error(`forge-github: head branch lookup failed: ${responseFailure(output, body).message}`);
|
|
552
|
+
return mapHeadResponse(body, repository, branch);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Mark a draft pull request ready for review with `gh pr ready`; one that
|
|
556
|
+
* is already ready stays ready.
|
|
557
|
+
*/
|
|
558
|
+
async markReady(ref, signal) {
|
|
559
|
+
const { host, owner, name } = checkedRepository(ref);
|
|
560
|
+
const failure = this.hostFailure(host);
|
|
561
|
+
if (failure !== void 0) return {
|
|
562
|
+
code: "failed",
|
|
563
|
+
message: failure.message
|
|
564
|
+
};
|
|
565
|
+
return await this.act([
|
|
566
|
+
"pr",
|
|
567
|
+
"ready",
|
|
568
|
+
String(ref.number),
|
|
569
|
+
"--repo",
|
|
570
|
+
`${host}/${owner}/${name}`
|
|
571
|
+
], signal);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Merge a pull request through the REST merge endpoint with the expected
|
|
575
|
+
* head commit, so GitHub refuses with 409 once new commits arrived. Unlike
|
|
576
|
+
* `gh pr merge`, it never enables auto-merge, never joins a merge queue, and
|
|
577
|
+
* never deletes the head branch.
|
|
578
|
+
*/
|
|
579
|
+
async merge(ref, request, signal) {
|
|
580
|
+
const { host, owner, name } = checkedRepository(ref);
|
|
581
|
+
const failure = this.hostFailure(host);
|
|
582
|
+
if (failure !== void 0) return {
|
|
583
|
+
code: "failed",
|
|
584
|
+
message: failure.message
|
|
585
|
+
};
|
|
586
|
+
if (!COMMIT.test(request.headSha)) throw new Error(`forge-github: invalid head commit ${JSON.stringify(request.headSha)}`);
|
|
587
|
+
return await this.act([
|
|
588
|
+
"api",
|
|
589
|
+
"--hostname",
|
|
590
|
+
host,
|
|
591
|
+
"--method",
|
|
592
|
+
"PUT",
|
|
593
|
+
`repos/${owner}/${name}/pulls/${ref.number}/merge`,
|
|
594
|
+
"-f",
|
|
595
|
+
`merge_method=${request.method}`,
|
|
596
|
+
"-f",
|
|
597
|
+
`sha=${request.headSha}`
|
|
598
|
+
], signal);
|
|
599
|
+
}
|
|
600
|
+
/** Read the pull request's diff with `gh pr diff`, which GitHub computes against the merge base. */
|
|
601
|
+
async diff(ref, signal) {
|
|
602
|
+
const { host, owner, name } = checkedRepository(ref);
|
|
603
|
+
const failure = this.hostFailure(host);
|
|
604
|
+
if (failure !== void 0) return failure;
|
|
605
|
+
return await this.read([
|
|
606
|
+
"pr",
|
|
607
|
+
"diff",
|
|
608
|
+
String(ref.number),
|
|
609
|
+
"--repo",
|
|
610
|
+
`${host}/${owner}/${name}`,
|
|
611
|
+
"--color",
|
|
612
|
+
"never"
|
|
613
|
+
], signal);
|
|
614
|
+
}
|
|
615
|
+
/** Read one file at a commit through the contents API in its raw form. */
|
|
616
|
+
async fileText(ref, commit, path, signal) {
|
|
617
|
+
const { host, owner, name } = checkedRepository(ref);
|
|
618
|
+
const failure = this.hostFailure(host);
|
|
619
|
+
if (failure !== void 0) return failure;
|
|
620
|
+
if (!COMMIT.test(commit)) throw new Error(`forge-github: invalid commit ${JSON.stringify(commit)}`);
|
|
621
|
+
return await this.read([
|
|
622
|
+
"api",
|
|
623
|
+
"--hostname",
|
|
624
|
+
host,
|
|
625
|
+
"-H",
|
|
626
|
+
"Accept: application/vnd.github.raw+json",
|
|
627
|
+
`repos/${owner}/${name}/contents/${encodedPath(path)}?ref=${commit}`
|
|
628
|
+
], signal);
|
|
629
|
+
}
|
|
630
|
+
fileUrl(ref, commit, path) {
|
|
631
|
+
const { host, owner, name } = ref.repository;
|
|
632
|
+
return `https://${host}/${owner}/${name}/blob/${commit}/${encodedPath(path)}`;
|
|
633
|
+
}
|
|
634
|
+
async readiness(host, signal) {
|
|
635
|
+
const failure = this.hostFailure(host);
|
|
636
|
+
if (failure !== void 0) return {
|
|
637
|
+
state: "unavailable",
|
|
638
|
+
message: failure.message
|
|
639
|
+
};
|
|
640
|
+
try {
|
|
641
|
+
const output = await this.gh([
|
|
642
|
+
"auth",
|
|
643
|
+
"status",
|
|
644
|
+
"--hostname",
|
|
645
|
+
host
|
|
646
|
+
], signal);
|
|
647
|
+
if (output.exitCode === 0) return {
|
|
648
|
+
state: "ready",
|
|
649
|
+
message: null
|
|
650
|
+
};
|
|
651
|
+
return {
|
|
652
|
+
state: "unauthenticated",
|
|
653
|
+
message: firstLine(output.stderr) ?? firstLine(output.stdout) ?? `gh is not signed in to ${host}`
|
|
654
|
+
};
|
|
655
|
+
} catch (error) {
|
|
656
|
+
if (error instanceof GhUnavailableError) return {
|
|
657
|
+
state: "unavailable",
|
|
658
|
+
message: error.message
|
|
659
|
+
};
|
|
660
|
+
throw error;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Run one reading `gh` command, returning its output. A refusal, a `gh` that
|
|
665
|
+
* cannot start, output over `maxOutputBytes`, and a run past `timeoutMs` become failures.
|
|
666
|
+
*/
|
|
667
|
+
async read(args, signal) {
|
|
668
|
+
let output;
|
|
669
|
+
try {
|
|
670
|
+
output = await this.attempt(args, signal);
|
|
671
|
+
} catch (error) {
|
|
672
|
+
if (error instanceof GhOutputLimitError) return {
|
|
673
|
+
code: "too-large",
|
|
674
|
+
message: error.message
|
|
675
|
+
};
|
|
676
|
+
if (error instanceof GhTimeoutError) return {
|
|
677
|
+
code: "unavailable",
|
|
678
|
+
message: error.message
|
|
679
|
+
};
|
|
680
|
+
throw error;
|
|
681
|
+
}
|
|
682
|
+
if (output instanceof GhUnavailableError) return {
|
|
683
|
+
code: "unavailable",
|
|
684
|
+
message: output.message
|
|
685
|
+
};
|
|
686
|
+
if (output.exitCode === 0) return output.stdout;
|
|
687
|
+
const { message, status } = refusal(output);
|
|
688
|
+
if (AUTHENTICATION.test(output.stderr)) return {
|
|
689
|
+
code: "unauthenticated",
|
|
690
|
+
message
|
|
691
|
+
};
|
|
692
|
+
if (TOO_LARGE.test(output.stderr) || TOO_LARGE.test(output.stdout)) return {
|
|
693
|
+
code: "too-large",
|
|
694
|
+
message
|
|
695
|
+
};
|
|
696
|
+
return {
|
|
697
|
+
code: status === "404" || /could not resolve to a pullrequest/i.test(output.stderr) ? "not-found" : "unavailable",
|
|
698
|
+
message
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
/** Run one changing `gh` command; a refusal or a `gh` that cannot start becomes a failure. */
|
|
702
|
+
async act(args, signal) {
|
|
703
|
+
const output = await this.attempt(args, signal);
|
|
704
|
+
if (output instanceof GhUnavailableError) return {
|
|
705
|
+
code: "failed",
|
|
706
|
+
message: output.message
|
|
707
|
+
};
|
|
708
|
+
if (output.exitCode === 0) return void 0;
|
|
709
|
+
const { message, status } = refusal(output);
|
|
710
|
+
if (status === "409") return {
|
|
711
|
+
code: "stale",
|
|
712
|
+
message
|
|
713
|
+
};
|
|
714
|
+
if (AUTHENTICATION.test(output.stderr)) return {
|
|
715
|
+
code: "unauthenticated",
|
|
716
|
+
message
|
|
717
|
+
};
|
|
718
|
+
return {
|
|
719
|
+
code: "failed",
|
|
720
|
+
message
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
/** Run one `gh` command; a `gh` that cannot start resolves to its error, and every other rejection passes on. */
|
|
724
|
+
async attempt(args, signal) {
|
|
725
|
+
try {
|
|
726
|
+
return await this.gh(args, signal);
|
|
727
|
+
} catch (error) {
|
|
728
|
+
if (error instanceof GhUnavailableError) return error;
|
|
729
|
+
throw error;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
hostFailure(host) {
|
|
733
|
+
return this.hosts.has(host.toLowerCase()) ? void 0 : {
|
|
734
|
+
code: "unavailable",
|
|
735
|
+
message: `forge-github: host ${JSON.stringify(host)} is not configured`
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
async fetchHost(host, refs, signal) {
|
|
739
|
+
const query = snapshotQuery(refs);
|
|
740
|
+
const output = await this.gh([
|
|
741
|
+
"api",
|
|
742
|
+
"graphql",
|
|
743
|
+
"--hostname",
|
|
744
|
+
host,
|
|
745
|
+
"-f",
|
|
746
|
+
`query=${query.document}`
|
|
747
|
+
], signal);
|
|
748
|
+
const body = parseJson(output.stdout);
|
|
749
|
+
if (hasGraphqlFields(body)) return mapSnapshotResponse(body, query);
|
|
750
|
+
const failure = responseFailure(output, body);
|
|
751
|
+
return new Map([...query.targets.values()].map((ref) => [changeRequestKey(ref), failure]));
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
/** Why `gh` refused: GitHub's message, else its first diagnostic line, with the HTTP status it names. */
|
|
755
|
+
function refusal(output) {
|
|
756
|
+
return {
|
|
757
|
+
message: hostMessage(output.stdout) ?? firstLine(output.stderr) ?? `gh exited with ${output.exitCode}`,
|
|
758
|
+
status: HTTP_STATUS.exec(output.stderr)?.[1]
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/** The `message` of the JSON error body `gh api` prints for a failed request. */
|
|
762
|
+
function hostMessage(stdout) {
|
|
763
|
+
const body = parseJson(stdout);
|
|
764
|
+
if (typeof body !== "object" || body === null || !("message" in body) || typeof body.message !== "string") return void 0;
|
|
765
|
+
return body.message.trim().length > 0 ? body.message : void 0;
|
|
766
|
+
}
|
|
767
|
+
/** A repository path with each segment percent-encoded, for an API path or a web URL. */
|
|
768
|
+
function encodedPath(path) {
|
|
769
|
+
return path.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
770
|
+
}
|
|
771
|
+
function responseFailure(output, body) {
|
|
772
|
+
const detail = typeof body === "object" && body !== null && "message" in body && typeof body.message === "string" ? firstLine(body.message) : void 0;
|
|
773
|
+
const message = firstLine(output.stderr) ?? detail ?? (output.exitCode === 0 ? "unexpected GitHub response" : `gh exited with ${output.exitCode}`);
|
|
774
|
+
return {
|
|
775
|
+
code: AUTHENTICATION.test(message) ? "unauthenticated" : "unavailable",
|
|
776
|
+
message
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function parseJson(text) {
|
|
780
|
+
let value;
|
|
781
|
+
try {
|
|
782
|
+
value = JSON.parse(text);
|
|
783
|
+
} catch (error) {
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
return value;
|
|
787
|
+
}
|
|
788
|
+
function firstLine(text) {
|
|
789
|
+
return text.split("\n").map((line) => line.trim()).find((line) => line.length > 0);
|
|
790
|
+
}
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region lib/types/index.js
|
|
793
|
+
/** Registers the GitHub provider of `ctx.forge`, which reads pull requests through the GitHub CLI on the host. */
|
|
794
|
+
const name = "forge-github";
|
|
795
|
+
const inject = ["forge"];
|
|
796
|
+
const Config = z.object({
|
|
797
|
+
ghCommand: z.string().default("gh"),
|
|
798
|
+
hosts: z.array(z.string()).default(["github.com"]),
|
|
799
|
+
timeoutMs: z.number().default(3e4),
|
|
800
|
+
maxOutputBytes: z.number().default(8388608)
|
|
801
|
+
});
|
|
802
|
+
const HOST = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(:\d+)?$/i;
|
|
803
|
+
function apply(ctx, config) {
|
|
804
|
+
const resolved = config;
|
|
805
|
+
if (resolved.ghCommand.trim().length === 0) throw new Error("forge-github: ghCommand must not be empty");
|
|
806
|
+
if (resolved.hosts.length === 0) throw new Error("forge-github: hosts must list at least one host");
|
|
807
|
+
for (const host of resolved.hosts) if (!HOST.test(host)) throw new Error(`forge-github: invalid host ${JSON.stringify(host)}`);
|
|
808
|
+
if (!Number.isSafeInteger(resolved.timeoutMs) || resolved.timeoutMs <= 0 || resolved.timeoutMs > MAX_TIMER_DELAY_MS) throw new Error(`forge-github: timeoutMs must be a positive integer no greater than ${MAX_TIMER_DELAY_MS}`);
|
|
809
|
+
if (!Number.isSafeInteger(resolved.maxOutputBytes) || resolved.maxOutputBytes <= 0) throw new Error("forge-github: maxOutputBytes must be a positive safe integer");
|
|
810
|
+
ctx.forge.register(new GitHubProvider(ghRunner(resolved), resolved.hosts));
|
|
811
|
+
}
|
|
812
|
+
//#endregion
|
|
813
|
+
export { Config, apply, inject, name };
|