@vite-hub/forge 0.7.0 → 0.9.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 +8 -2
- package/dist/build/node.js +0 -6
- package/dist/{webhooks-Bc6QhmI8-CvF2iFBp.js → define-C9xZZNVR-C-oojQRP.js} +3 -997
- package/dist/{definition-BQFdu9ti-BURTyX81.js → definition-BQFdu9ti-BZgR-gkB.js} +5 -4
- package/dist/{github-Csy_qzZc.js → definition-s83gxg2p-JwDgFji9.js} +26 -28
- package/dist/{events-BL0zcgMf-DGySmhNt.js → events-BL0zcgMf-Exs7JLX1.js} +4 -2
- package/dist/{events-DDdJnmD2-BhNdO8U_.js → events-DDdJnmD2-CdPFePvp.js} +4 -3
- package/dist/{events-DHqSJ5KI-DfFbbwBb.js → events-DHqSJ5KI-mRtn-qQ0.js} +4 -3
- package/dist/{events-DXE-Ul2S-U2BH_jTW.js → events-DXE-Ul2S-BEUw4sQF.js} +4 -3
- package/dist/{feed-B1OiHFg0-a2dzl1Va.js → feed-B1OiHFg0-ppQHqkxG.js} +4 -2
- package/dist/{feed-DROLF1tb-A1eZev0R.js → feed-DROLF1tb-CMAanXw8.js} +4 -2
- package/dist/{feed-iWegqepj-id4yPYnY.js → feed-iWegqepj-DKBLqhvD.js} +4 -2
- package/dist/{forgejo-aZiaqKRW.js → forgejo-Deckk49p.js} +2 -2
- package/dist/{gitea-CCZ3fS7H.js → gitea-ChQKeRrf.js} +2 -2
- package/dist/{gitee-CKt4pEC0-dsy0hiLG.js → gitee-CKt4pEC0-BuzC1PrM.js} +1 -1
- package/dist/{gitlab-AAJN-eVR.js → gitlab-CzCikZzN.js} +5 -4
- package/dist/{graphql-DxRA9BGO-CiA7HWVp.js → graphql-DxRA9BGO-Cy511t8-.js} +2 -1
- package/dist/index.d.ts +50 -8
- package/dist/index.js +187 -20
- package/dist/kit-CrquHPqr.js +4 -0
- package/dist/{templates-0m5QBVIh-Bop0TOo9.js → templates-0m5QBVIh-C1DcQ_yo.js} +1 -2
- package/dist/utils-DEwhctg5-BM3AMnSs.js +1213 -0
- package/dist/webhooks-Bc6QhmI8-CgoCnwj1.js +71 -0
- package/package.json +2 -2
- package/dist/kit-UEdJKGws.js +0 -3
- package/dist/model-Biiu1CfI-CVLamGai.js +0 -288
package/README.md
CHANGED
|
@@ -29,13 +29,17 @@ await github.request("POST", "/repos/acme/web/issues", { body: { title: "Nightly
|
|
|
29
29
|
| Call | Returns |
|
|
30
30
|
| --- | --- |
|
|
31
31
|
| `useForge({ forge, baseUrl, env, fetch, userAgent, conditionalRequests })` | The Forge of this deployment. `conditionalRequests: false` stops GitHub providers from revalidating repeated GETs with ETags. `forge` defaults to `"github"`. `env` defaults to the active Cloudflare bindings, then `process.env`. Throws `FORGE_MISSING_ENV` or `FORGE_INVALID_ENV` when the env cannot work. |
|
|
32
|
-
| `checkForge(options)` | Checks the same env with no request, for a Setup page. Returns `[undefined, { kind, auth }]`, or `[error, undefined]` with `FORGE_MISSING_ENV` or `FORGE_INVALID_ENV`. It checks the base URL and verifies that the inline or file-based GitHub App private key can sign. It does not test whether the forge accepts the credentials. |
|
|
32
|
+
| `checkForge(options)` | Checks the same env with no request, for a Setup page. Returns `[undefined, { kind, auth, user }]`, where `user` says whether `forge.user` is set, or `[error, undefined]` with `FORGE_MISSING_ENV` or `FORGE_INVALID_ENV`. It checks the base URL and verifies that the inline or file-based GitHub App private key can sign. It does not test whether the forge accepts the credentials. |
|
|
33
33
|
| `forge.kind`, `forge.auth`, `forge.baseUrl` | The Forge, `"app"` or `"token"`, and the API base. |
|
|
34
34
|
| `forge.token({ repository, installation, refresh, minLifetime, signal })` | `[error, { token, expiresAt }]`. With a GitHub App, an installation token for `installation`, such as `installation.id` of a webhook delivery, else for the owner of `repository` (see [Installations](https://vitehub.dev/docs/forge/configure#installations)), or for `VITEHUB_GITHUB_INSTALLATION_ID` without `repository`. Cached until `minLifetime` milliseconds (default one minute) before it expires. |
|
|
35
35
|
| `forge.provider({ repository, installation, refresh, minLifetime, signal })` | `[error, provider]`, a `forges` provider that sends `token()`. A GitHub provider has `graphql()`. |
|
|
36
36
|
| `forge.app({ signal })` | `[error, { id, slug, login, email }]` of the GitHub App. Throws `FORGE_NOT_APP` with a token. |
|
|
37
|
+
| `forge.user` | GitHub App user-to-server tokens, to act as a person who authorized the App. `undefined` unless the Forge is GitHub and `VITEHUB_GITHUB_CLIENT_ID` and `VITEHUB_GITHUB_CLIENT_SECRET` are set. See [Act as a person](https://vitehub.dev/docs/forge/server-api#act-as-a-person). |
|
|
38
|
+
| `forge.user.authorizeUrl({ redirectUri, state })` | The GitHub page that asks the person to authorize the App. On GitHub Enterprise Server, the web host of the API base. |
|
|
39
|
+
| `forge.user.exchange({ code, redirectUri, signal })`, `forge.user.refresh({ refreshToken, signal })` | `[error, { token, expiresAt, refreshToken, refreshTokenExpiresAt, login, id }]`. `login` and `id` come from `GET /user` with the new token. The expiries are `undefined` when the App has user token expiry off. Errors are `FORGE_USER_AUTH_FAILED` and `FORGE_REQUEST_FAILED`. |
|
|
40
|
+
| `forge.user.provider({ token })` | A `forges` GitHub provider that sends the user token. |
|
|
37
41
|
|
|
38
|
-
GitHub uses the App when `VITEHUB_GITHUB_APP_ID` is set, and `VITEHUB_GITHUB_TOKEN` otherwise. Runtime errors are `FORGE_APP_NOT_INSTALLED` and `
|
|
42
|
+
GitHub uses the App when `VITEHUB_GITHUB_APP_ID` is set, and `VITEHUB_GITHUB_TOKEN` otherwise. Runtime errors are `FORGE_APP_NOT_INSTALLED`, `FORGE_REQUEST_FAILED` and, from `forge.user`, `FORGE_USER_AUTH_FAILED`. A cancelled call rejects with the abort reason. The codes are documented at [Forge limits and errors](https://vitehub.dev/docs/forge/limits-and-errors).
|
|
39
43
|
|
|
40
44
|
## Server Env
|
|
41
45
|
|
|
@@ -47,6 +51,8 @@ Each field reads its `VITEHUB_` name first, then the `FORGES_` name that the `fo
|
|
|
47
51
|
| `github.appId` | `VITEHUB_GITHUB_APP_ID`, `FORGES_GITHUB_APP_ID` |
|
|
48
52
|
| `github.privateKey` | `VITEHUB_GITHUB_PRIVATE_KEY`, `FORGES_GITHUB_PRIVATE_KEY` |
|
|
49
53
|
| `github.privateKeyPath` | `VITEHUB_GITHUB_PRIVATE_KEY_PATH` |
|
|
54
|
+
| `github.clientId` | `VITEHUB_GITHUB_CLIENT_ID`, `FORGES_GITHUB_CLIENT_ID` |
|
|
55
|
+
| `github.clientSecret` | `VITEHUB_GITHUB_CLIENT_SECRET`, `FORGES_GITHUB_CLIENT_SECRET` |
|
|
50
56
|
| `github.installationId` | `VITEHUB_GITHUB_INSTALLATION_ID`, `FORGES_GITHUB_INSTALLATION_ID` |
|
|
51
57
|
| `github.appOwner` | `VITEHUB_GITHUB_APP_OWNER` |
|
|
52
58
|
| `github.appInstallations` | `VITEHUB_GITHUB_APP_INSTALLATIONS` |
|
package/dist/build/node.js
CHANGED
|
@@ -3,7 +3,6 @@ import { execFile } from "node:child_process";
|
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
// ../internal/src/build/revision.ts
|
|
6
|
-
/** CI and host variables that name the commit and branch of a build, in the order they are read. */
|
|
7
6
|
const buildVariables = [
|
|
8
7
|
["VERCEL_GIT_COMMIT_SHA", "VERCEL_GIT_COMMIT_REF"],
|
|
9
8
|
["WORKERS_CI_COMMIT_SHA", "WORKERS_CI_BRANCH"],
|
|
@@ -26,10 +25,6 @@ async function readGit(root, args) {
|
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
/**
|
|
30
|
-
* On a GitHub Actions `pull_request` event, `GITHUB_SHA` is the test merge commit, which matches no deployment of the
|
|
31
|
-
* pull request. The event payload names the head commit.
|
|
32
|
-
*/
|
|
33
28
|
async function pullRequestHead(env) {
|
|
34
29
|
if (!env.GITHUB_EVENT_NAME?.startsWith("pull_request") || !env.GITHUB_EVENT_PATH) return void 0;
|
|
35
30
|
try {
|
|
@@ -39,7 +34,6 @@ async function pullRequestHead(env) {
|
|
|
39
34
|
return;
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
|
-
/** The commit and branch that the CI or host names, else Git's. Empty outside a Git checkout. */
|
|
43
37
|
async function discoveredRevision(env, git) {
|
|
44
38
|
for (const [commitName, branchName] of buildVariables) {
|
|
45
39
|
const commit = commitName === "GITHUB_SHA" ? await pullRequestHead(env) ?? env.GITHUB_SHA : env[commitName];
|