ref0-git 0.14.0 → 0.20.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/app/apps/github/generated/git-rest.ts +170 -3
- package/app/apps/github/generated/routeTree.gen.ts +42 -21
- package/app/apps/github/src/clients/host-calls.ts +59 -34
- package/app/apps/github/src/components/states/states.tsx +1 -19
- package/app/apps/github/src/components/view-tabs.tsx +6 -2
- package/app/apps/github/src/context/context.ts +7 -4
- package/app/apps/github/src/context/host.ts +72 -36
- package/app/apps/github/src/issues/issue-list.tsx +11 -3
- package/app/apps/github/src/issues/issues.ts +11 -8
- package/app/apps/github/src/lists/across-list.tsx +358 -0
- package/app/apps/github/src/lists/across.ts +239 -0
- package/app/apps/github/src/names/owners.ts +3 -1
- package/app/apps/github/src/palette/targets.ts +3 -2
- package/app/apps/github/src/policy.ts +21 -23
- package/app/apps/github/src/private-repos.ts +24 -24
- package/app/apps/github/src/pulls/pulls.ts +2 -1
- package/app/apps/github/src/routes/-nav.tsx +40 -12
- package/app/apps/github/src/routes/issues.tsx +15 -0
- package/app/apps/github/src/routes/orgs/$owner/-org-list.ts +31 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +10 -3
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +10 -3
- package/app/apps/github/src/routes/pulls.tsx +15 -0
- package/app/apps/github/src/seed/seed.ts +104 -52
- package/app/apps/github/src/server.ts +17 -7
- package/app/apps/github/src/signin/approval.ts +24 -16
- package/app/apps/github/src/signin/auth.ts +27 -19
- package/app/apps/github/src/signin/revoke.ts +9 -17
- package/app/apps/github/src/signin/unborn.ts +33 -20
- package/dist/cli/setup.mjs +3 -3
- package/dist/init/app.mjs +3 -2
- package/dist/init/cloudflare.mjs +8 -3
- package/dist/init/git-module.mjs +3 -3
- package/dist/init/metadata.mjs +1 -1
- package/dist/init/node.mjs +1 -1
- package/dist/init/templates.mjs +16 -16
- package/dist/init/versions.mjs +1 -1
- package/package.json +5 -5
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +0 -8
package/dist/cli/setup.mjs
CHANGED
|
@@ -138,9 +138,9 @@ const filesUnder = /* @__PURE__ */ Effect.fnUntraced(function* (folder, keep, un
|
|
|
138
138
|
const found = [];
|
|
139
139
|
for (const entry of yield* fs.readDirectory(`${folder}/${under}`)) {
|
|
140
140
|
const path = `${under}${entry}`;
|
|
141
|
-
if ((
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
if (!entered(path) || /\.test\.tsx?$/.test(entry)) continue;
|
|
142
|
+
if ((yield* fs.stat(`${folder}/${path}`)).type === "Directory") found.push(...yield* filesUnder(folder, keep, `${path}/`));
|
|
143
|
+
else if (keep(path)) found.push(path);
|
|
144
144
|
}
|
|
145
145
|
return found;
|
|
146
146
|
});
|
package/dist/init/app.mjs
CHANGED
|
@@ -93,7 +93,7 @@ const gitImport = (choices) => importLine([
|
|
|
93
93
|
"Merges",
|
|
94
94
|
choices.queue === "on" && "MergeQueue",
|
|
95
95
|
"Objects",
|
|
96
|
-
"
|
|
96
|
+
"Repos",
|
|
97
97
|
"Rest",
|
|
98
98
|
"SignIn",
|
|
99
99
|
"Tokens"
|
|
@@ -104,6 +104,7 @@ const githubImport = (choices) => importLine([
|
|
|
104
104
|
"Deployments",
|
|
105
105
|
"GitHub",
|
|
106
106
|
"Inbox",
|
|
107
|
+
"IssueLists",
|
|
107
108
|
choices.objects === "packs" && "Releases",
|
|
108
109
|
"RepoGrants",
|
|
109
110
|
"Search",
|
|
@@ -158,7 +159,7 @@ const dialectOn = {
|
|
|
158
159
|
const nodeHead = (choices) => {
|
|
159
160
|
const queue = choices.queue === "on";
|
|
160
161
|
const dialect = dialectOn[choices.records];
|
|
161
|
-
return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Collaborators from '@ref0/github/collaborators';", "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as
|
|
162
|
+
return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Collaborators from '@ref0/github/collaborators';", "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as Effect from 'effect/Effect';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "", "import {", " hostLayer,", " onHost,", " type OnHost,", " peopleOver,", " repoRecordsOn,", " tokensOn,", "} from './context/host.ts';", "import { repoGrantsDropped } from './context/repo-grants.ts';", "import { repoIcons } from './context/repo-icons.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import {", " admin,", " approvalPage,", " type GrantsPolicy,", " hostPolicy,", " hostRules,", " type Identify,", "} from './policy.ts';", "import { privateReposOf } from './private-repos.ts';", "import { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';", "import { avatars } from './signin/avatars.ts';", "import { clientIpHeader } from './signin/client-ip.ts';", "import { appAuth } from './signin/host-session.ts';", "import { orgsOver } from './signin/orgs.ts';", "import { grantsOver } from './signin/repo-grants.ts';", "import { sealKey } from './signin/seal.ts';", "", "/** What the app reads from `.env`, as the server's entry reads it here. */", "export { env };", "", storeLines(choices), bucketLines(choices), "", peopleOn[choices.records], "");
|
|
162
163
|
};
|
|
163
164
|
/** The app's `src/git.ts` on Node: `apps/github`'s own past its head, Node's head and parts in Cloudflare's place. */
|
|
164
165
|
const nodeGit = (choices) => filled(templates.appGitNode, {
|
package/dist/init/cloudflare.mjs
CHANGED
|
@@ -225,9 +225,9 @@ const devVars = (names, secret) => ({
|
|
|
225
225
|
merge: (current) => withLines(current, names.map((name) => `${name}=${Redacted.value(secret())}`), (line) => line.split("=")[0] ?? "")
|
|
226
226
|
});
|
|
227
227
|
/**
|
|
228
|
-
* The packs' bucket's
|
|
229
|
-
*
|
|
230
|
-
*
|
|
228
|
+
* The packs' bucket's lifecycle rules: abort incomplete uploads after 1 day and expire crash-left
|
|
229
|
+
* `uploads/` sidecars after 2 days (strictly longer than the abort age so live sidecars outlive
|
|
230
|
+
* their upload). Alchemy clears undeclared rules, so both go here, as in `examples/git-alchemy`.
|
|
231
231
|
*/
|
|
232
232
|
const abortUploads = [
|
|
233
233
|
" lifecycleRules: [",
|
|
@@ -235,6 +235,11 @@ const abortUploads = [
|
|
|
235
235
|
" id: \"abort-uploads\",",
|
|
236
236
|
" abortMultipartUploadsTransition: { condition: { type: \"Age\", maxAge: 86_400 } },",
|
|
237
237
|
" },",
|
|
238
|
+
" {",
|
|
239
|
+
" id: \"expire-upload-sidecars\",",
|
|
240
|
+
" prefix: \"uploads/\",",
|
|
241
|
+
" deleteObjectsTransition: { condition: { type: \"Age\", maxAge: 172_800 } },",
|
|
242
|
+
" },",
|
|
238
243
|
" ],"
|
|
239
244
|
];
|
|
240
245
|
/** Alchemy's lines for Git's part of a Worker's `env`, as the Alchemy guide gives them. */
|
package/dist/init/git-module.mjs
CHANGED
|
@@ -73,7 +73,7 @@ const gitImports = (choices, admins = false) => lines(namedImport(gitNames(choic
|
|
|
73
73
|
* Effect's imports, which the composition is written in, and with `admins` what a Worker's policy
|
|
74
74
|
* over its `ADMINS` reads the host's tokens with.
|
|
75
75
|
*/
|
|
76
|
-
const effectImports = (choices, admins = false) => lines(admins && "import * as Context from 'effect/Context';", admins && "import * as Effect from 'effect/Effect';", choices.serve === "github" && "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';",
|
|
76
|
+
const effectImports = (choices, admins = false) => lines(admins && "import * as Context from 'effect/Context';", admins && "import * as Effect from 'effect/Effect';", choices.serve === "github" && "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", admins && "import * as Option from 'effect/Option';", "import * as Redacted from 'effect/Redacted';");
|
|
77
77
|
/** Who `ADMIN_TOKEN` signs in as. */
|
|
78
78
|
const adminLines = lines("/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */", "const admin = { id: '_admin' };", "");
|
|
79
79
|
/** How the queue writes an entry onto `main`, when there's a queue. */
|
|
@@ -88,7 +88,7 @@ const mergeLines = (choices) => choices.queue === "on" && lines("/** How the que
|
|
|
88
88
|
*/
|
|
89
89
|
const policyLines = lines("/**", " * Who may do what: a visitor signs in first, and the admin makes repos and tokens but never", " * pushes.", " */", "const policy = Policy.make(({ caller: { actor }, operation }) => {", " if (actor.anonymous === true) return Policy.reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return Policy.reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return Policy.accept();", "});", "");
|
|
90
90
|
/** What one push may carry into `Objects.layerRecords()`, as `@ref0/git` holds it. */
|
|
91
|
-
const looseSays = `up to ${looseLimits.objects.toLocaleString("en-US")} objects and ${looseLimits.bytes / 1024 / 1024} MiB a push`;
|
|
91
|
+
const looseSays = `up to ${looseLimits.objects.toLocaleString("en-US")} objects and ${looseLimits.bytes / 1024 / 1024} MiB a push, and ${looseLimits.fileBytes / 1024 / 1024} MiB a file`;
|
|
92
92
|
/** What a Worker `init` writes its config whole for: `workerCpuMs`, in `wrangler.jsonc`. */
|
|
93
93
|
const writtenCpu = {
|
|
94
94
|
ms: workerCpuMs,
|
|
@@ -137,5 +137,5 @@ const gitOptions = (choices, maxDuration) => {
|
|
|
137
137
|
* The admin's sign-in, then `export const runtime`: the whole host, Git with its features over the
|
|
138
138
|
* adapter, one runtime that every entry, object and job runner takes.
|
|
139
139
|
*/
|
|
140
|
-
const runtimeLines = (choices, parts) => lines(parts.bootstrap === true ? lines("/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */", "const auth =", ` ${parts.token} === undefined || ${parts.token} === ''`, " ? Layer.empty", ` : Auth.layer(Auth.bearer({ token: Redacted.make(${parts.token}), actor: bootstrap }));`) : lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`), "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", ` * adapter, deciding with \`policy\`, and the ${parts.bootstrap === true ? "bootstrap" : "admin"} signing in with \`auth\`.`, parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime =
|
|
140
|
+
const runtimeLines = (choices, parts) => lines(parts.bootstrap === true ? lines("/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */", "const auth =", ` ${parts.token} === undefined || ${parts.token} === ''`, " ? Layer.empty", ` : Auth.layer(Auth.bearer({ token: Redacted.make(${parts.token}), actor: bootstrap }));`) : lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`), "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", ` * adapter, deciding with \`policy\`, and the ${parts.bootstrap === true ? "bootstrap" : "admin"} signing in with \`auth\`.`, parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime = Git.runtime(", parts.maxDuration !== void 0 && lines(" // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first,", " // with Git's own message."), ` Git.layer(${gitOptions(choices, parts.maxDuration)}, ${choices.serve === "github" ? "github" : "features"}).pipe(`, " Layer.provide(Policy.layer(policy)),", parts.bootstrap === true ? " Layer.provide(auth)," : " Layer.provide(Auth.layer(auth)),", choices.objects === "packs" ? " Layer.provide(Objects.layer())," : ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n Layer.provide(Objects.layerRecords()),`, ` Layer.provideMerge(${parts.adapter}),`, " ),", ");", "");
|
|
141
141
|
export { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, lfsLines, looseSays, mergeLines, policyLines, queueLine, repoHint, runtimeLines, writtenCpu };
|
package/dist/init/metadata.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/init/metadata.ts
|
|
2
2
|
/** The version `ref0-git`, `create-ref0-git` and Git's packages release at, all at once (Q738). */
|
|
3
|
-
const release = "0.
|
|
3
|
+
const release = "0.20.0";
|
|
4
4
|
/** The packages the app depends on, by their folder in a checkout's `packages/`. */
|
|
5
5
|
const appPackages = [
|
|
6
6
|
"infra",
|
package/dist/init/node.mjs
CHANGED
|
@@ -88,7 +88,7 @@ const nodeModule = (choices, jobs) => {
|
|
|
88
88
|
/** A stop waits this long for the responses still open, such as one a reader stopped reading. */
|
|
89
89
|
const stopGrace = 1e4;
|
|
90
90
|
/** The lines in `src/main.ts` that start the jobs and serve Git. */
|
|
91
|
-
const serveLines = lines("const stop = Node.toJobRunner(runtime);", "", "const handler = toNodeHandler(runtime);");
|
|
91
|
+
const serveLines = lines("const stop = Node.toJobRunner(runtime);", "", "// Behind a proxy that ends TLS, set ORIGIN to the origin it serves, such as", "// https://git.example.com, which Git's links are built from. Unset, each request's connection's.", "const handler = toNodeHandler(runtime, { origin: process.env.ORIGIN });");
|
|
92
92
|
/** Where `src/main.ts` serves Git when `PORT` is unset. */
|
|
93
93
|
const mainOrigin = "http://localhost:8080";
|
|
94
94
|
const mainPort = new URL(mainOrigin).port;
|
package/dist/init/templates.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var templates_default = {
|
|
|
3
3
|
appGit: [
|
|
4
4
|
{
|
|
5
5
|
"slot": "gitImport",
|
|
6
|
-
"text": "import {
|
|
6
|
+
"text": "import { Git, Lfs, Merges, MergeQueue, Objects, Repos, Rest, SignIn, Tokens } from '@ref0/git';"
|
|
7
7
|
},
|
|
8
8
|
"\n",
|
|
9
9
|
{
|
|
@@ -12,7 +12,7 @@ var templates_default = {
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"slot": "githubImport",
|
|
15
|
-
"text": "import {\n Apps,\n Deployments,\n GitHub,\n Inbox,\n Releases,\n RepoGrants,\n Search,\n Streams,\n Webhooks,\n} from '@ref0/github';"
|
|
15
|
+
"text": "import {\n Apps,\n Deployments,\n GitHub,\n Inbox,\n IssueLists,\n Releases,\n RepoGrants,\n Search,\n Streams,\n Webhooks,\n} from '@ref0/github';"
|
|
16
16
|
},
|
|
17
17
|
"\nimport * as Collaborators from '@ref0/github/collaborators';\nimport * as Languages from '@ref0/github/languages';\n",
|
|
18
18
|
{
|
|
@@ -24,7 +24,7 @@ var templates_default = {
|
|
|
24
24
|
"slot": "effectImport",
|
|
25
25
|
"text": "import * as Effect from 'effect/Effect';\n"
|
|
26
26
|
},
|
|
27
|
-
"import * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\
|
|
27
|
+
"import * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\n\nimport {\n hostLayer,\n onHost,\n type OnHost,\n peopleOver,\n repoRecordsOn,\n tokensOn,\n} from './context/host.ts';\nimport { repoGrantsDropped } from './context/repo-grants.ts';\nimport { repoIcons } from './context/repo-icons.ts';\nimport type { Env } from './env.ts';\nimport {\n admin,\n approvalPage,\n type GrantsPolicy,\n hostPolicy,\n hostRules,\n type Identify,\n} from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { grantsOver } from './signin/repo-grants.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` ",
|
|
28
28
|
{
|
|
29
29
|
"slot": "safety",
|
|
30
30
|
"text": "binds the objects, the bucket and D1"
|
|
@@ -38,7 +38,7 @@ var templates_default = {
|
|
|
38
38
|
"slot": "queueMerge",
|
|
39
39
|
"text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry, at }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at, offset: 0 },\n };\n};\n\n"
|
|
40
40
|
},
|
|
41
|
-
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\n/** Each repo's grants to people, its collaborators, in Better Auth's database, as `directory` reads it. */\nexport const grants = grantsOver(async () => readyAdapter(await auth()));\n\nexport const policy: GrantsPolicy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos:
|
|
41
|
+
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\n/** Each repo's grants to people, its collaborators, in Better Auth's database, as `directory` reads it. */\nexport const grants = grantsOver(async () => readyAdapter(await auth()));\n\n/**\n * Git's services on the runtime below, in the caller's fiber: the policy reads its repos' records\n * through it within the request it decides, its store calls counted on that request's.\n */\nexport const host: OnHost = onHost(() => runtime);\n\nconst { repoName, repoId } = repoRecordsOn(host);\n\nexport const policy: GrantsPolicy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: privateReposOf(host),\n repoName,\n // Who else may do what on a repo, by its grants, and which repo a token over one names now.\n grants,\n repoId,\n});\n\n",
|
|
42
42
|
{
|
|
43
43
|
"slot": "adapter",
|
|
44
44
|
"text": "/** The records and job objects, and the bucket. */\nconst adapter = Layer.merge(layer({ records: env.RECORDS, jobs: env.JOBS }), bucket);"
|
|
@@ -53,7 +53,7 @@ var templates_default = {
|
|
|
53
53
|
"slot": "releases",
|
|
54
54
|
"text": " // A release's assets, in the bucket beside the packs.\n Releases.layer(),\n"
|
|
55
55
|
},
|
|
56
|
-
" // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n // A repo's collaborators and teams, which its settings list and change.\n Collaborators.layer(),\n // A deleted repo's collaborators, removed however the repo was deleted.\n repoGrantsDropped(grants),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n // The directory, and a repo's collaborators, which its settings list and change: the drop-in\n // takes both as it's built.\n Layer.provideMerge(Layer.merge(peopleOver(policy.people), RepoGrants.layer(policy.repoGrants))),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
|
|
56
|
+
" // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Each person's index of the issues and pull requests they take part in, across every repo:\n // `/issues`, an org's issues, and a search that names no repo read it.\n IssueLists.layer(),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n // A repo's collaborators and teams, which its settings list and change.\n Collaborators.layer(),\n // A deleted repo's collaborators, removed however the repo was deleted.\n repoGrantsDropped(grants),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n // The directory, and a repo's collaborators, which its settings list and change: the drop-in\n // takes both as it's built.\n Layer.provideMerge(Layer.merge(peopleOver(policy.people), RepoGrants.layer(policy.repoGrants))),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
|
|
57
57
|
{
|
|
58
58
|
"slot": "lfs",
|
|
59
59
|
"text": " // Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use\n // `limits.cpu_ms` from wrangler.jsonc: raise both together.\n Lfs.layer({ cpuMs: 300_000 }),\n"
|
|
@@ -66,18 +66,18 @@ var templates_default = {
|
|
|
66
66
|
"slot": "queue",
|
|
67
67
|
"text": " // Each repo's `main` has a merge queue, beside the merge button: its protection still takes\n // a direct merge, as GitHub's does on a branch whose rules don't ask for the queue.\n MergeQueue.layer({ target: 'refs/heads/main', keys: 'once', merge: queueMerge }),\n"
|
|
68
68
|
},
|
|
69
|
-
" // The device flow's sign-in for `gh` and `ref0-git login`, which the page decides in the\n // person's session, from the Better Auth below and Git's own `identify`.\n SignIn.layer({\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request): ReturnType<Identify> =>
|
|
69
|
+
" // The device flow's sign-in for `gh` and `ref0-git login`, which the page decides in the\n // person's session, from the Better Auth below and Git's own `identify`.\n SignIn.layer({\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request): ReturnType<Identify> => host(Git.identify(request)),\n origin: env.APP_ORIGIN,\n }),\n }),\n ),\n ),\n Layer.provideMerge(Tokens.layer()),\n Layer.provideMerge(Merges.layer({ xdiff })),\n);\n\n/**\n * The whole host, one runtime a process: Git and its features over the records, the jobs and the\n * bucket, as the policy decides, with `hostRules` its push rules.\n */\nexport const runtime = Git.runtime(\n hostLayer(adapter, objects, features, {\n authorize: policy.authorize,\n auth: appAuth({ adminToken: env.ADMIN_TOKEN, admin, key: sessionKey }),\n authorizeGitHub: policy.authorizeGitHub,\n rules: hostRules.map((each) => each.rule),\n }),\n);\n\n/**\n * Better Auth, made at a request that needs it, not the isolate's start: who signs up and in, in\n * `AUTH_DB`, each session with a Git token of its own. It's kept once a request's check settles.\n */\nexport const auth = readyAuth(() =>\n starterAuth({\n database: env.AUTH_DB,\n secret: env.SESSION_SECRET,\n origin: env.APP_ORIGIN,\n signUp: env.SIGN_UP !== 'closed',\n key: sessionKey,\n tokens: tokensOn(host),\n // Cloudflare's own, which it sets on every request in place of any the caller sent.\n ipHeader: 'cf-connecting-ip',\n ownsRepos: (login) =>\n Effect.match(host(Repos.list({ actor: admin, prefix: `${login}/`, page: { limit: 1 } })), {\n onFailure: () => true,\n onSuccess: (listed) => listed.items.length > 0,\n }),\n }),\n);\n\n/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = toRecordsObject(runtime);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = toJobObject(runtime);\n"
|
|
70
70
|
],
|
|
71
71
|
appGitNode: [
|
|
72
72
|
{
|
|
73
73
|
"slot": "head",
|
|
74
|
-
"text": "import {
|
|
74
|
+
"text": "import { Git, Lfs, Merges, MergeQueue, Objects, Repos, Rest, SignIn, Tokens } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport {\n Apps,\n Deployments,\n GitHub,\n Inbox,\n IssueLists,\n Releases,\n RepoGrants,\n Search,\n Streams,\n Webhooks,\n} from '@ref0/github';\nimport * as Collaborators from '@ref0/github/collaborators';\nimport * as Languages from '@ref0/github/languages';\nimport {\n layer,\n layerR2,\n layerR2Signed,\n toJobObject,\n toRecordsObject,\n} from '@ref0/infra/cloudflare';\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\nimport * as Effect from 'effect/Effect';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\n\nimport {\n hostLayer,\n onHost,\n type OnHost,\n peopleOver,\n repoRecordsOn,\n tokensOn,\n} from './context/host.ts';\nimport { repoGrantsDropped } from './context/repo-grants.ts';\nimport { repoIcons } from './context/repo-icons.ts';\nimport type { Env } from './env.ts';\nimport {\n admin,\n approvalPage,\n type GrantsPolicy,\n hostPolicy,\n hostRules,\n type Identify,\n} from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { grantsOver } from './signin/repo-grants.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` binds the objects, the bucket and D1 and sets `APP_ORIGIN`; the\n// secrets come from `wrangler secret put`, or `.dev.vars` locally.\nexport const env = bindings as Env;\n\nconst {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, the bucket signs parts, and a push's pack past 64 MiB may upload to\n// it in parts, past Workers' 100 MB body.\nconst signed =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? undefined\n : layerR2Signed(env.PACKS, {\n accountId,\n bucket: env.PACKS_BUCKET,\n accessKeyId,\n secretAccessKey,\n });\n\n// With none, Git LFS's bytes go through the Worker, under its CPU and body limits: a warning\n// says so once an isolate, as the runtime builds the bucket.\nconst unsigned = Layer.effectDiscard(\n Effect.logWarning(\n \"LFS: through the Worker (no signing key). Run `ref0-git keys` in the Worker's folder to sign its links straight to R2\",\n ),\n);\n\nconst bucket = signed ?? Layer.merge(layerR2(env.PACKS), unsigned);\n\nconst uploads =\n signed === undefined\n ? Layer.empty\n : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed);\n\n"
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
"slot": "queueMerge",
|
|
78
78
|
"text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry, at }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at, offset: 0 },\n };\n};\n\n"
|
|
79
79
|
},
|
|
80
|
-
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\n/** Each repo's grants to people, its collaborators, in Better Auth's database, as `directory` reads it. */\nexport const grants = grantsOver(async () => readyAdapter(await auth()));\n\nexport const policy: GrantsPolicy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos:
|
|
80
|
+
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\n/** Each repo's grants to people, its collaborators, in Better Auth's database, as `directory` reads it. */\nexport const grants = grantsOver(async () => readyAdapter(await auth()));\n\n/**\n * Git's services on the runtime below, in the caller's fiber: the policy reads its repos' records\n * through it within the request it decides, its store calls counted on that request's.\n */\nexport const host: OnHost = onHost(() => runtime);\n\nconst { repoName, repoId } = repoRecordsOn(host);\n\nexport const policy: GrantsPolicy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: privateReposOf(host),\n repoName,\n // Who else may do what on a repo, by its grants, and which repo a token over one names now.\n grants,\n repoId,\n});\n\n",
|
|
81
81
|
{
|
|
82
82
|
"slot": "adapter",
|
|
83
83
|
"text": "/** The records and job objects, and the bucket. */\nconst adapter = Layer.merge(layer({ records: env.RECORDS, jobs: env.JOBS }), bucket);"
|
|
@@ -92,7 +92,7 @@ var templates_default = {
|
|
|
92
92
|
"slot": "releases",
|
|
93
93
|
"text": " // A release's assets, in the bucket beside the packs.\n Releases.layer(),\n"
|
|
94
94
|
},
|
|
95
|
-
" // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n // A repo's collaborators and teams, which its settings list and change.\n Collaborators.layer(),\n // A deleted repo's collaborators, removed however the repo was deleted.\n repoGrantsDropped(grants),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n // The directory, and a repo's collaborators, which its settings list and change: the drop-in\n // takes both as it's built.\n Layer.provideMerge(Layer.merge(peopleOver(policy.people), RepoGrants.layer(policy.repoGrants))),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
|
|
95
|
+
" // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Each person's index of the issues and pull requests they take part in, across every repo:\n // `/issues`, an org's issues, and a search that names no repo read it.\n IssueLists.layer(),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n // A repo's collaborators and teams, which its settings list and change.\n Collaborators.layer(),\n // A deleted repo's collaborators, removed however the repo was deleted.\n repoGrantsDropped(grants),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n // The directory, and a repo's collaborators, which its settings list and change: the drop-in\n // takes both as it's built.\n Layer.provideMerge(Layer.merge(peopleOver(policy.people), RepoGrants.layer(policy.repoGrants))),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
|
|
96
96
|
{
|
|
97
97
|
"slot": "lfs",
|
|
98
98
|
"text": " // Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use\n // `limits.cpu_ms` from wrangler.jsonc: raise both together.\n Lfs.layer({ cpuMs: 300_000 }),\n"
|
|
@@ -105,22 +105,22 @@ var templates_default = {
|
|
|
105
105
|
"slot": "queue",
|
|
106
106
|
"text": " // Each repo's `main` has a merge queue, beside the merge button: its protection still takes\n // a direct merge, as GitHub's does on a branch whose rules don't ask for the queue.\n MergeQueue.layer({ target: 'refs/heads/main', keys: 'once', merge: queueMerge }),\n"
|
|
107
107
|
},
|
|
108
|
-
" // The device flow's sign-in for `gh` and `ref0-git login`, which the page decides in the\n // person's session, from the Better Auth below and Git's own `identify`.\n SignIn.layer({\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request): ReturnType<Identify> =>
|
|
108
|
+
" // The device flow's sign-in for `gh` and `ref0-git login`, which the page decides in the\n // person's session, from the Better Auth below and Git's own `identify`.\n SignIn.layer({\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request): ReturnType<Identify> => host(Git.identify(request)),\n origin: env.APP_ORIGIN,\n }),\n }),\n ),\n ),\n Layer.provideMerge(Tokens.layer()),\n",
|
|
109
109
|
{
|
|
110
110
|
"slot": "xdiff",
|
|
111
111
|
"text": " Layer.provideMerge(Merges.layer({ xdiff })),"
|
|
112
112
|
},
|
|
113
|
-
"\n);\n\n/**\n * The whole host, one runtime a process: Git and its features over the records, the jobs and the\n * bucket, as the policy decides, with `hostRules` its push rules.\n */\nexport const runtime =
|
|
113
|
+
"\n);\n\n/**\n * The whole host, one runtime a process: Git and its features over the records, the jobs and the\n * bucket, as the policy decides, with `hostRules` its push rules.\n */\nexport const runtime = Git.runtime(\n hostLayer(adapter, objects, features, {\n authorize: policy.authorize,\n auth: appAuth({ adminToken: env.ADMIN_TOKEN, admin, key: sessionKey }),\n authorizeGitHub: policy.authorizeGitHub,\n rules: hostRules.map((each) => each.rule),\n }),\n);\n\n/**\n * Better Auth, made at a request that needs it, not the isolate's start: who signs up and in, in\n * `AUTH_DB`, each session with a Git token of its own. It's kept once a request's check settles.\n */\nexport const auth = readyAuth(() =>\n starterAuth({\n",
|
|
114
114
|
{
|
|
115
115
|
"slot": "database",
|
|
116
116
|
"text": " database: env.AUTH_DB,"
|
|
117
117
|
},
|
|
118
|
-
"\n secret: env.SESSION_SECRET,\n origin: env.APP_ORIGIN,\n signUp: env.SIGN_UP !== 'closed',\n key: sessionKey,\n tokens:
|
|
118
|
+
"\n secret: env.SESSION_SECRET,\n origin: env.APP_ORIGIN,\n signUp: env.SIGN_UP !== 'closed',\n key: sessionKey,\n tokens: tokensOn(host),\n",
|
|
119
119
|
{
|
|
120
120
|
"slot": "ipHeader",
|
|
121
121
|
"text": " // Cloudflare's own, which it sets on every request in place of any the caller sent.\n ipHeader: 'cf-connecting-ip',\n"
|
|
122
122
|
},
|
|
123
|
-
" ownsRepos:
|
|
123
|
+
" ownsRepos: (login) =>\n Effect.match(host(Repos.list({ actor: admin, prefix: `${login}/`, page: { limit: 1 } })), {\n onFailure: () => true,\n onSuccess: (listed) => listed.items.length > 0,\n }),\n }),\n);\n",
|
|
124
124
|
{
|
|
125
125
|
"slot": "classes",
|
|
126
126
|
"text": "\n/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = toRecordsObject(runtime);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = toJobObject(runtime);\n"
|
|
@@ -185,7 +185,7 @@ var templates_default = {
|
|
|
185
185
|
"tsconfig.json": "// The app's pages, routes, clients and sign-in: DOM, as a browser runs them, and Start's server\n// functions beside them. The Worker's entry and Git are `tsconfig.worker.json`'s, typed by\n// workers-types with no DOM, and the tests `tsconfig.test.json`'s, in Node. Each file is in the\n// one whose globals it runs with, and the root's `tsconfig.json` references all three.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"jsx\": \"react-jsx\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.tsbuildinfo\",\n \"types\": [\"vite-plus/client\"]\n },\n \"include\": [\"src/**/*.ts\", \"src/**/*.tsx\", \"generated/**/*.ts\"],\n \"exclude\": [\n \"src/**/*.test.ts\",\n \"src/**/testing/**\",\n \"src/seed/**\",\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/signin/approval.ts\",\n \"src/camo/lookup.ts\",\n \"src/camo/node.ts\",\n \"src/markdown/words-plugin.ts\"\n ]\n}\n",
|
|
186
186
|
"tsconfig.worker.json": "// The Worker, typed as Cloudflare types one: workers-types' globals and no DOM, so `Request` and\n// `Response` are a Worker's. The pages are `tsconfig.app.json`'s, and the files both run, sealing\n// and names, are in each.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"lib\": [\"ES2023\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.worker.tsbuildinfo\",\n \"types\": [\"@cloudflare/workers-types\", \"vite-plus/client\"]\n },\n \"include\": [\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/context/**/*.ts\",\n \"src/names/**/*.ts\",\n \"src/seed/**/*.ts\",\n \"src/signin/approval.ts\",\n \"src/signin/seal.ts\"\n ],\n \"exclude\": [\"src/**/*.test.ts\", \"src/seed/testing/built-app.ts\"]\n}\n"
|
|
187
187
|
},
|
|
188
|
-
nodeServer: "import { Git } from '@ref0/git';\nimport { Records } from '@ref0/infra';\nimport handler, { createServerEntry } from '@tanstack/react-start/server-entry';\nimport * as Effect from 'effect/Effect';\n\nimport { nodeFetch } from './camo/node.ts';\nimport { imageProxy } from './camo/proxy.ts';\nimport type { AppContext } from './context/context.ts';\nimport { auth, directory, env, pictures, policy,
|
|
188
|
+
nodeServer: "import { Git, Repos } from '@ref0/git';\nimport { Records } from '@ref0/infra';\nimport handler, { createServerEntry } from '@tanstack/react-start/server-entry';\nimport * as Effect from 'effect/Effect';\n\nimport { nodeFetch } from './camo/node.ts';\nimport { imageProxy } from './camo/proxy.ts';\nimport type { AppContext, HostGit } from './context/context.ts';\nimport { auth, directory, env, host, pictures, policy, runtime, sessionKey } from './git.ts';\nimport { routeOn, tokensOn } from './context/host.ts';\nimport { ingressOf } from './ingress.ts';\nimport { hostRules } from './policy.ts';\nimport { shownRules } from './settings/rules.ts';\nimport { deviceAttemptAnswer, deviceAttemptGate } from './signin/attempts.ts';\nimport { sessionCookieOf, sessionEnder, sessionFrom, sessionIdFrom } from './signin/auth.ts';\nimport { clientIpHeader, withClientIp } from './signin/client-ip.ts';\nimport { withoutHostSession } from './signin/host-session.ts';\n\n/**\n * The device page's attempts (#1962), counted in Git's records, by the address the platform sets\n * and the session Better Auth checks, before Git reads a code.\n */\nconst gate = deviceAttemptGate({\n answer: (who) => runtime.runPromise(deviceAttemptAnswer(who)),\n addressHeader: clientIpHeader,\n session: async (request) => sessionIdFrom(await auth())(request),\n});\n\n/** The front door, then Git's routes, the drop-in's among them, for outside and the app alike. */\nconst { owned, api } = ingressOf({ gate, git: routeOn(runtime) });\n\n/** Git's own calls, as host calls read them, each an Effect, which the server function runs. */\nconst git = {\n repos: { list: (input) => host(Repos.list(input)) },\n tokens: tokensOn(host),\n} satisfies HostGit;\n\n/**\n * The image proxy (Q860): a text's remote images load through `/_camo/`, and the pages' CSP loads\n * no other. Without it, and with `IMAGE_PROXY=off`, they load from their own origin.\n */\nconst images = imageProxy({\n secret: env.SESSION_SECRET,\n appOrigin: env.APP_ORIGIN,\n setting: env.IMAGE_PROXY,\n fetch: nodeFetch,\n});\n\n/** The host's push rules, as a repo's settings show them. */\nconst rules = shownRules(hostRules);\n\n/** Whether the dev seed runs: `vite.config.ts` sets it true only under the dev server. */\ndeclare const __DEV_SEED__: boolean;\n\nlet seeding: Promise<void> | undefined;\n\n/**\n * In dev only, the seed, once an isolate, before its first answer: Pip and Mo sign up with\n * `DEMO_PASSWORD` and make the demo org `acme`, a host with no repos gets its repos, and a seed cut\n * off finishes. It signs them up in whatever database `AUTH_DB` points at under the dev server,\n * the local D1 unless the host sets `\"remote\": true` on it, so `.dev.vars.example`'s known\n * `DEMO_PASSWORD` is changed before the dev server points at a remote database.\n */\nconst seeded = () => {\n seeding ??= Promise.all([import('./signin/seed-people.ts'), import('./seed/seed.ts')])\n .then(async ([{ seedPeople }, { seed }]) => {\n if (env.DEMO_PASSWORD === undefined) throw new Error('Set DEMO_PASSWORD in .env');\n\n await seedPeople(await auth(), { origin: env.APP_ORIGIN, password: env.DEMO_PASSWORD });\n\n return seed({\n fetch: api,\n origin: env.APP_ORIGIN,\n adminToken: env.ADMIN_TOKEN,\n // Git's records, on its runtime, keep the seed's progress beside Git's own.\n store: {\n read: (scope, reads) => runtime.runPromise(Records.read(scope, reads)),\n commit: (scope, change) => runtime.runPromise(Records.commit(scope, change)),\n },\n });\n })\n .then(\n () => undefined,\n (cause: unknown) =>\n runtime.runPromise(\n Effect.logError('The seed stopped, and goes on at the next start', cause),\n ),\n );\n\n return seeding;\n};\n\n/** Q8's order: the drop-in, then Git, then the app. A URL one owns never falls through. */\nexport default createServerEntry({\n fetch: images.around(async (incoming) => {\n // A host session is the app's server's to set in this Worker, never a caller's to send\n // (Q520): every route, the APIs, the app and any upgrade, sees the request without one.\n // The caller's address, for the rate limit, set by this server in place of any the caller sent.\n const request = withoutHostSession(withClientIp(incoming, env.CLIENT_IP_HEADER));\n if (__DEV_SEED__) await seeded();\n\n const answered = await owned(request);\n if (answered !== undefined) return answered;\n\n const context: AppContext = {\n api,\n sealKey: await sessionKey,\n // Better Auth is made only for a request that reads it, and checked in that request (#480).\n auth: async (each) => (await auth()).handler(each),\n session: async (each) => sessionFrom(await auth(), sessionKey)(each),\n endSession: async (each) => sessionEnder(await auth())(each),\n sessionCookie: async () => sessionCookieOf(await auth())(),\n // The server functions' own edge: who a credential names, as their Promise reads it.\n identify: (each) =>\n runtime.runPromise(\n Effect.match(Git.identify(each), {\n onFailure: (error) => ({ kind: 'error', error }) as const,\n onSuccess: (value) => ({ kind: 'success', value }) as const,\n }),\n ),\n authorize: policy.authorize,\n authorizeGitHub: policy.authorizeGitHub,\n rules,\n avatars: pictures,\n accounts: directory,\n git,\n images,\n };\n\n return handler.fetch(request, { context });\n }),\n});\n",
|
|
189
189
|
nodeConfigs: { "tsconfig.json": "// The app's pages, routes, clients and sign-in: DOM, as a browser runs them, and Start's server\n// functions beside them. The server and Git are `tsconfig.server.json`'s, typed by\n// Node's types with no DOM, and the tests `tsconfig.test.json`'s, in Node. Each file is in the\n// one whose globals it runs with, and the root's `tsconfig.json` references all three.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"jsx\": \"react-jsx\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.tsbuildinfo\",\n \"types\": [\"vite-plus/client\"]\n },\n \"include\": [\"src/**/*.ts\", \"src/**/*.tsx\", \"generated/**/*.ts\"],\n \"exclude\": [\n \"src/**/*.test.ts\",\n \"src/**/testing/**\",\n \"src/seed/**\",\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/signin/approval.ts\",\n \"src/camo/lookup.ts\",\n \"src/camo/node.ts\",\n \"src/markdown/words-plugin.ts\"\n ]\n}\n" },
|
|
190
190
|
nodeServerConfig: "// The server, typed as Node runs it: Node's globals and no DOM. The pages are `tsconfig.json`'s,\n// and the files both run, sealing and names, are in each.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"lib\": [\"ES2023\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.server.tsbuildinfo\",\n \"types\": [\"node\", \"vite-plus/client\"]\n },\n \"include\": [\n \"src/server.ts\",\n \"src/camo/lookup.ts\",\n \"src/camo/node.ts\",\n \"server/**/*.ts\",\n \"scripts/**/*.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/context/**/*.ts\",\n \"src/names/**/*.ts\",\n \"src/seed/**/*.ts\",\n \"src/signin/approval.ts\",\n \"src/signin/seal.ts\"\n ],\n \"exclude\": [\"src/**/*.test.ts\", \"src/seed/testing/built-app.ts\"]\n}\n",
|
|
191
191
|
nodeVite: "import tailwindcss from '@tailwindcss/vite';\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite';\nimport viteReact from '@vitejs/plugin-react';\nimport { nitro } from 'nitro/vite';\nimport { defineConfig } from 'vite-plus';\n\nimport { wordsMemoryMax } from './src/markdown/words-plugin.ts';\n\n// Start's server build runs in Node through Nitro, which scans `server/` for the jobs' plugin.\nexport default defineConfig(({ command }) => ({\n // The dev seed is on only under the dev server, `vp dev`: every build drops it and its imports,\n // whatever its mode or `NODE_ENV`.\n define: { __DEV_SEED__: JSON.stringify(command === 'serve') },\n // The diff and highlight Workers are modules: `@pierre/diffs`' loads its highlighter lazily.\n worker: { format: 'es' },\n plugins: [\n // Words' WebAssembly under the drop-in's most on its memory (#1098): in Node, the module is\n // compiled at load from words' own bytes, edited.\n wordsMemoryMax(),\n tanstackStart({\n // NodeNext, as the repo types it, resolves only imports that name their extension.\n router: { generatedRouteTree: '../generated/routeTree.gen.ts', addExtensions: true },\n }),\n nitro({ serverDir: './server' }),\n viteReact(),\n tailwindcss(),\n ],\n}));\n",
|
|
@@ -205,7 +205,7 @@ var templates_default = {
|
|
|
205
205
|
"\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\n",
|
|
206
206
|
{
|
|
207
207
|
"slot": "effectImports",
|
|
208
|
-
"text": "import * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as
|
|
208
|
+
"text": "import * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Redacted from 'effect/Redacted';\n"
|
|
209
209
|
},
|
|
210
210
|
"\nimport type { Env } from ",
|
|
211
211
|
{
|
|
@@ -233,7 +233,7 @@ var templates_default = {
|
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
"slot": "runtime",
|
|
236
|
-
"text": "/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */\nconst auth =\n env.ADMIN_TOKEN === undefined || env.ADMIN_TOKEN === ''\n ? Layer.empty\n : Auth.layer(Auth.bearer({ token: Redacted.make(env.ADMIN_TOKEN), actor: bootstrap }));\n\n/**\n * The whole host, one runtime that every request and job shares: Git and its features over the\n * adapter, deciding with `policy`, and the bootstrap signing in with `auth`.\n */\nexport const runtime =
|
|
236
|
+
"text": "/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */\nconst auth =\n env.ADMIN_TOKEN === undefined || env.ADMIN_TOKEN === ''\n ? Layer.empty\n : Auth.layer(Auth.bearer({ token: Redacted.make(env.ADMIN_TOKEN), actor: bootstrap }));\n\n/**\n * The whole host, one runtime that every request and job shares: Git and its features over the\n * adapter, deciding with `policy`, and the bootstrap signing in with `auth`.\n */\nexport const runtime = Git.runtime(\n Git.layer({}, features).pipe(\n Layer.provide(Policy.layer(policy)),\n Layer.provide(auth),\n Layer.provide(Objects.layer()),\n Layer.provideMerge(adapter),\n ),\n);\n\n"
|
|
237
237
|
},
|
|
238
238
|
"/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = toRecordsObject(runtime);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = toJobObject(runtime);\n"
|
|
239
239
|
],
|
package/dist/init/versions.mjs
CHANGED
|
@@ -56,5 +56,5 @@ const initPacked = (name, at) => {
|
|
|
56
56
|
* the release, or the tarball `--from-checkout` names for that package. One it wrote moves to this
|
|
57
57
|
* run's spec; any other is the person's, a tarball of their own in `vendor/` too, and stays.
|
|
58
58
|
*/
|
|
59
|
-
const initWrote = (name, spec) => spec === "0.
|
|
59
|
+
const initWrote = (name, spec) => spec === "0.20.0" || spec !== void 0 && packedPath(name).test(spec);
|
|
60
60
|
export { catalog, contentNamed, frameworkPackages, initPacked, initWrote, nodeAppPackages, nodePackages, peerPackages, published, release, specOf, storePackages, unpacked, vercelPackages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ref0-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "ref0-git, the CLI for a Git host built on @ref0/git, and git-remote-ref0, its remote helper",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@effect/platform-node-shared": "4.1.7",
|
|
27
|
-
"@ref0/git": "0.
|
|
28
|
-
"@ref0/infra": "0.
|
|
27
|
+
"@ref0/git": "0.20.0",
|
|
28
|
+
"@ref0/infra": "0.20.0",
|
|
29
29
|
"diff": "9.0.0",
|
|
30
30
|
"effect": "^4.1.7"
|
|
31
31
|
},
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@effect/vitest": "4.1.7",
|
|
35
35
|
"@libsql/client": "0.18.0",
|
|
36
36
|
"@libsql/kysely-libsql": "0.4.1",
|
|
37
|
-
"@ref0/github": "0.
|
|
38
|
-
"@ref0/xdiff-wasm": "0.
|
|
37
|
+
"@ref0/github": "0.20.0",
|
|
38
|
+
"@ref0/xdiff-wasm": "0.20.0",
|
|
39
39
|
"@tanstack/react-start": "1.169.7",
|
|
40
40
|
"@types/node": "24.19.4",
|
|
41
41
|
"@types/pg": "8.23.1",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
-
|
|
3
|
-
import { AcrossRepos } from '../../../components/states/states.tsx';
|
|
4
|
-
|
|
5
|
-
/** An owner's releases across its repos, which waits on one read across them. */
|
|
6
|
-
export const Route = createFileRoute('/orgs/$owner/releases')({
|
|
7
|
-
component: () => <AcrossRepos what="releases" />,
|
|
8
|
-
});
|