ref0-git 0.6.0 → 0.7.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/README.md +3 -7
- package/app/apps/github/generated/git-rest.ts +12 -12
- package/app/apps/github/src/clients/allowed.ts +7 -9
- package/app/apps/github/src/clients/avatars.ts +5 -3
- package/app/apps/github/src/clients/graphql.ts +12 -2
- package/app/apps/github/src/clients/host-calls.ts +2 -1
- package/app/apps/github/src/clients/transfers.ts +56 -19
- package/app/apps/github/src/context/context.ts +5 -5
- package/app/apps/github/src/context/host.ts +115 -0
- package/app/apps/github/src/ingress.ts +28 -0
- package/app/apps/github/src/policy.ts +113 -78
- package/app/apps/github/src/private-repos.ts +7 -7
- package/app/apps/github/src/pulls/review.ts +2 -1
- package/app/apps/github/src/releases/release-form.tsx +40 -4
- package/app/apps/github/src/releases/releases.ts +148 -22
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +9 -2
- package/app/apps/github/src/seed/seed.ts +9 -2
- package/app/apps/github/src/server.ts +28 -11
- package/app/apps/github/src/signin/approval.ts +20 -15
- package/app/apps/github/src/signin/attempts.ts +306 -0
- package/app/apps/github/src/signin/auth.ts +9 -0
- package/app/apps/github/src/signin/host-session.ts +30 -18
- package/app/apps/github/src/signin/limits.ts +35 -0
- package/app/pnpm-workspace.yaml +37 -36
- package/dist/cli/setup.mjs +1 -1
- package/dist/init/app.mjs +43 -23
- package/dist/init/cloudflare.mjs +8 -4
- package/dist/init/create.mjs +1 -1
- package/dist/init/detect.mjs +5 -3
- package/dist/init/files.mjs +6 -1
- package/dist/init/git-module.mjs +4 -6
- package/dist/init/metadata.mjs +6 -6
- package/dist/init/node-app.mjs +5 -2
- package/dist/init/stores.mjs +3 -2
- package/dist/init/template.mjs +13 -7
- package/dist/init/templates.mjs +51 -39
- package/dist/init/vercel.mjs +1 -1
- package/dist/init/versions.mjs +1 -1
- package/package.json +13 -13
package/dist/init/app.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { bucketLine, bucketName, devVars,
|
|
2
|
-
import { ignoring, lines, listed, withCli } from "./files.mjs";
|
|
1
|
+
import { bucketLine, bucketName, devVars, looseInfraImport, mergePackage, secretFiles } from "./cloudflare.mjs";
|
|
2
|
+
import { ignoring, importLine, lines, listed, withCli } from "./files.mjs";
|
|
3
3
|
import { bucketLines, firstImports, infraImports, partsOf, storeLines } from "./node.mjs";
|
|
4
4
|
import { specOf } from "./versions.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { looseSays } from "./git-module.mjs";
|
|
6
6
|
import { jsonString, manifestText } from "./jsonc.mjs";
|
|
7
7
|
import { filled, platforms, templates, unless } from "./template.mjs";
|
|
8
8
|
import { blockOf, catalogOf } from "./workspace.mjs";
|
|
@@ -86,37 +86,56 @@ const appManifest = (source, name, vendor, platform = {}) => {
|
|
|
86
86
|
};
|
|
87
87
|
return withCli(`${manifestText(made)}\n`, vendor);
|
|
88
88
|
};
|
|
89
|
-
/** The `@ref0/git` import of the app's `src/git.ts`, naming
|
|
90
|
-
const
|
|
91
|
-
"
|
|
92
|
-
choices.objects === "packs" && "
|
|
93
|
-
|
|
94
|
-
choices.queue === "on" && "
|
|
95
|
-
|
|
96
|
-
"RepoRecords"
|
|
97
|
-
|
|
89
|
+
/** The `@ref0/git` import of the app's `src/git.ts`, naming the Layers the store and the queue use. */
|
|
90
|
+
const gitImport = (choices) => importLine([
|
|
91
|
+
"Git",
|
|
92
|
+
choices.objects === "packs" && "Lfs",
|
|
93
|
+
"Merges",
|
|
94
|
+
choices.queue === "on" && "MergeQueue",
|
|
95
|
+
"Objects",
|
|
96
|
+
"RepoRecords",
|
|
97
|
+
"Rest",
|
|
98
|
+
"SignIn",
|
|
99
|
+
"Tokens"
|
|
100
|
+
].filter(Predicate.isString), "@ref0/git");
|
|
101
|
+
/** The `@ref0/github` import of the app's `src/git.ts`: `Releases` only beside a bucket. */
|
|
102
|
+
const githubImport = (choices) => importLine([
|
|
103
|
+
"Apps",
|
|
104
|
+
"Deployments",
|
|
105
|
+
"GitHub",
|
|
106
|
+
"Inbox",
|
|
107
|
+
choices.objects === "packs" && "Releases",
|
|
108
|
+
"Search",
|
|
109
|
+
"Streams",
|
|
110
|
+
"Webhooks"
|
|
111
|
+
].filter(Predicate.isString), "@ref0/github");
|
|
112
|
+
/** Git's objects with no bucket: each a row in its push's commit, and what a push may carry. */
|
|
113
|
+
const looseObjects = `/** Git's objects, each a row in its push's commit: no bucket, ${looseSays}. */\nconst objects = Objects.layerRecords();`;
|
|
98
114
|
/** The slots both platforms' `src/git.ts` fill alike: the queue's, and the store's past the head. */
|
|
99
|
-
const bodySlots = (choices
|
|
115
|
+
const bodySlots = (choices) => {
|
|
100
116
|
const queue = choices.queue === "on";
|
|
117
|
+
const packs = choices.objects === "packs";
|
|
101
118
|
return {
|
|
102
119
|
queueMerge: unless(queue, ""),
|
|
103
120
|
queue: unless(queue, ""),
|
|
104
|
-
objects: unless(
|
|
105
|
-
|
|
106
|
-
|
|
121
|
+
objects: unless(packs, looseObjects),
|
|
122
|
+
releases: unless(packs, ""),
|
|
123
|
+
lfs: unless(packs, "")
|
|
107
124
|
};
|
|
108
125
|
};
|
|
109
126
|
/** The app's `src/git.ts` on Cloudflare: `apps/github`'s own, its store's and queue's slots filled. */
|
|
110
127
|
const cloudflareGit = (choices) => {
|
|
111
128
|
const packs = choices.objects === "packs";
|
|
112
129
|
return filled(templates.appGit, {
|
|
113
|
-
gitImport:
|
|
130
|
+
gitImport: gitImport(choices),
|
|
114
131
|
queueTypes: unless(choices.queue === "on", ""),
|
|
132
|
+
githubImport: githubImport(choices),
|
|
115
133
|
infraImport: unless(packs, looseInfraImport),
|
|
116
134
|
safety: unless(packs, "binds the objects, and D1"),
|
|
117
135
|
bucket: unless(packs, ""),
|
|
118
|
-
adapter: unless(packs,
|
|
119
|
-
|
|
136
|
+
adapter: unless(packs, "/** The records and job objects. */\nconst adapter = layer({ records: env.RECORDS, jobs: env.JOBS });"),
|
|
137
|
+
uploads: unless(packs, ""),
|
|
138
|
+
...bodySlots(choices)
|
|
120
139
|
});
|
|
121
140
|
};
|
|
122
141
|
/** Better Auth's database on Node, beside the records `--records` chose (init.md's table). */
|
|
@@ -137,17 +156,18 @@ const dialectOn = {
|
|
|
137
156
|
const nodeHead = (choices) => {
|
|
138
157
|
const queue = choices.queue === "on";
|
|
139
158
|
const dialect = dialectOn[choices.records];
|
|
140
|
-
return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`,
|
|
159
|
+
return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", "", "import { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import { admin, approvalPage, 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 { 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], "");
|
|
141
160
|
};
|
|
142
161
|
/** The app's `src/git.ts` on Node: `apps/github`'s own past its head, Node's head and parts in Cloudflare's place. */
|
|
143
162
|
const nodeGit = (choices) => filled(templates.appGitNode, {
|
|
144
163
|
head: `${nodeHead(choices)}\n`,
|
|
145
|
-
adapter:
|
|
146
|
-
|
|
164
|
+
adapter: choices.objects === "packs" ? "/** The records, the jobs and the bucket. */\nconst adapter = Layer.merge(store, bucket);" : "/** The records and the jobs. */\nconst adapter = store;",
|
|
165
|
+
uploads: choices.bucket === "s3" ? lines(" // A push past 64 MiB may upload its pack, once the bucket signs parts.", " Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), bucket),", "") : "",
|
|
166
|
+
xdiff: " Layer.provideMerge(Merges.layer({ xdiff: await xdiff() })),",
|
|
147
167
|
database: " database: people,",
|
|
148
168
|
ipHeader: lines(" // The server's own, which `src/server.ts` sets from the caller's address on every request.", " ipHeader: clientIpHeader,", ""),
|
|
149
169
|
classes: "",
|
|
150
|
-
...bodySlots(choices
|
|
170
|
+
...bodySlots(choices)
|
|
151
171
|
});
|
|
152
172
|
/** The app's `src/git.ts`: Git, the drop-in and Better Auth over the host's policy. */
|
|
153
173
|
const appGitModule = (choices) => choices.platform === "node" ? nodeGit(choices) : cloudflareGit(choices);
|
package/dist/init/cloudflare.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fitted, ignoring, lines, withCli, withDependencies, withLines } from "./files.mjs";
|
|
2
|
-
import { basePathLines,
|
|
2
|
+
import { basePathLines, gitDependencies, gitImports, gitPackages, githubHandler, header, looseObjects, queueLine } from "./git-module.mjs";
|
|
3
3
|
import { itemsAt, jsonString, manifestText, parseJsonc, stringAt, withEntries, withValue } from "./jsonc.mjs";
|
|
4
4
|
import { filled, templates, unless } from "./template.mjs";
|
|
5
5
|
import { catalog } from "./metadata.mjs";
|
|
@@ -62,7 +62,6 @@ const gitModule = (choices, envFile) => {
|
|
|
62
62
|
uploads: unless(packs, ""),
|
|
63
63
|
basePath: basePath === false ? void 0 : `${basePath}\n`,
|
|
64
64
|
queue: queue ? `${queueLine(github)}\n` : "",
|
|
65
|
-
events: github ? `${eventsLines}\n` : void 0,
|
|
66
65
|
github: github ? `${githubHandler}\n` : void 0,
|
|
67
66
|
rest: choices.serve === "git" ? "" : void 0
|
|
68
67
|
});
|
|
@@ -70,12 +69,17 @@ const gitModule = (choices, envFile) => {
|
|
|
70
69
|
/** `src/worker.ts`'s default export, for what it serves past the example's REST. */
|
|
71
70
|
const workerExports = {
|
|
72
71
|
github: lines("/** The drop-in's URLs, then Git's REST and protocol, then a JSON `404`. */", "export default {", " fetch: async (request) => (await github.route(request)) ?? rest.fetch(request),", "} satisfies ExportedHandler<Env>;", ""),
|
|
72
|
+
api: "/** Git's REST and protocol, then a JSON `404`. */\nexport default { fetch: rest.fetch } satisfies ExportedHandler<Env>;\n",
|
|
73
73
|
git: "/** Git's protocol and sign-in, then a JSON `404`. */\nexport default { fetch: git.fetch } satisfies ExportedHandler<Env>;\n"
|
|
74
74
|
};
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* `src/worker.ts`, the entry of a Worker `init` writes whole: `examples/git-worker`'s own, without
|
|
77
|
+
* the device page's front door, as a Worker `init` writes serves no sign-in.
|
|
78
|
+
*/
|
|
76
79
|
const workerEntry = (choices) => filled(templates.workerEntry, {
|
|
80
|
+
gate: "",
|
|
77
81
|
names: `import { ${routing[choices.serve].names} } from './git.ts';`,
|
|
78
|
-
exports:
|
|
82
|
+
exports: workerExports[choices.serve]
|
|
79
83
|
});
|
|
80
84
|
/** `main`'s path as `src/git-entry.ts` imports it. */
|
|
81
85
|
const fromEntry = (main) => {
|
package/dist/init/create.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import * as Schema from "effect/Schema";
|
|
|
10
10
|
const creators = {
|
|
11
11
|
next: "create-next-app@16.4.6",
|
|
12
12
|
sveltekit: "sv@1.7.1",
|
|
13
|
-
nuxt: "create-nuxt@4.1.
|
|
13
|
+
nuxt: "create-nuxt@4.1.1"
|
|
14
14
|
};
|
|
15
15
|
/** The values `--framework` takes, in the table's order. */
|
|
16
16
|
const creatable = Object.keys(creators);
|
package/dist/init/detect.mjs
CHANGED
|
@@ -53,11 +53,13 @@ const readBack = (text) => {
|
|
|
53
53
|
const vercel = imports("vercel");
|
|
54
54
|
const onNode = !vercel && (imports("node") || imports("sqlite"));
|
|
55
55
|
if (!vercel && !onNode && !imports("cloudflare")) return void 0;
|
|
56
|
-
const
|
|
56
|
+
const app = text.includes("from './signin/auth.ts'");
|
|
57
|
+
const loose = app ? text.includes("\nconst objects = Objects.layerRecords();") : /\bloose\(\)/.test(text);
|
|
58
|
+
const queue = app ? text.includes("MergeQueue.layer({ target: 'refs/heads/main', keys: 'once', merge: queueMerge })") : text.includes("mergeQueue(");
|
|
57
59
|
const shared = {
|
|
58
60
|
serve: text.includes("from '@ref0/github'") ? "github" : text.includes("from '@ref0/git/rest'") ? "api" : "git",
|
|
59
|
-
app:
|
|
60
|
-
queue:
|
|
61
|
+
app: app ? "ref0" : "none",
|
|
62
|
+
queue: queue ? "on" : "off",
|
|
61
63
|
basePath: /^ {2}basePath: '([^']*)',$/m.exec(text)?.[1] ?? "/"
|
|
62
64
|
};
|
|
63
65
|
if (vercel) return {
|
package/dist/init/files.mjs
CHANGED
|
@@ -5,6 +5,11 @@ import * as Predicate from "effect/Predicate";
|
|
|
5
5
|
// src/init/files.ts
|
|
6
6
|
/** The parts that are strings, one a line: a part that's `false` is left out. */
|
|
7
7
|
const lines = (...parts) => parts.filter(Predicate.isString).join("\n");
|
|
8
|
+
/** An import of `names` from `from`, on one line, or one name a line past the formatter's width. */
|
|
9
|
+
const importLine = (names, from) => {
|
|
10
|
+
const line = `import { ${names.join(", ")} } from '${from}';`;
|
|
11
|
+
return line.length <= 100 ? line : lines("import {", ...names.map((name) => ` ${name},`), `} from '${from}';`);
|
|
12
|
+
};
|
|
8
13
|
/** `names` as a sentence lists them: `a, b and c`. */
|
|
9
14
|
const listed = (names) => names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1] ?? ""}`;
|
|
10
15
|
/**
|
|
@@ -184,4 +189,4 @@ const withCreatedTypes = (created) => (text) => {
|
|
|
184
189
|
if (created !== true || major >= 22) return text;
|
|
185
190
|
return withValue(text, ["devDependencies", "@types/node"], nodePackages["@types/node"]);
|
|
186
191
|
};
|
|
187
|
-
export { fitted, ignoring, lines, listed, pnpmEntries, pnpmManual, pnpmOverridesOf, served, withCli, withCreatedTypes, withDependencies, withLines, withPnpmOverrides, wroteOf };
|
|
192
|
+
export { fitted, ignoring, importLine, lines, listed, pnpmEntries, pnpmManual, pnpmOverridesOf, served, withCli, withCreatedTypes, withDependencies, withLines, withPnpmOverrides, wroteOf };
|
package/dist/init/git-module.mjs
CHANGED
|
@@ -43,22 +43,20 @@ const lfsLines = " // Git LFS, its objects in the bucket beside the packs.\n l
|
|
|
43
43
|
const looseObjects = ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n objects: loose(),`;
|
|
44
44
|
/** `createGitServer`'s `basePath`, when Git's URLs are under one. */
|
|
45
45
|
const basePathLines = (choices) => choices.basePath !== "/" && ` // Git's URLs, Smart HTTP, sign-in and REST, under this path.\n basePath: '${choices.basePath.replace(/\/$/, "")}',`;
|
|
46
|
-
/** `createGitServer`'s events, under `--serve github`. */
|
|
47
|
-
const eventsLines = " // Git's events go to the drop-in, which follows each push: a pull request's head, its queue.\n events: (input) => github.events(input),";
|
|
48
46
|
/**
|
|
49
47
|
* The queue's line: under the drop-in, a pull request's key merges once, so a push to it after its
|
|
50
48
|
* merge isn't queued again before the drop-in sees the merge.
|
|
51
49
|
*/
|
|
52
50
|
const queueLine = (github) => ` queue: mergeQueue({ target: 'refs/heads/main', keys: '${github ? "once" : "reusable"}', merge }),`;
|
|
53
51
|
/** The drop-in's handler, under `--serve github`. */
|
|
54
|
-
const githubHandler = "
|
|
52
|
+
const githubHandler = "/**\n * GitHub's REST, GraphQL, webhooks and Event Streams, so `gh` and Octokit work, with the owner\n * index, so repo and user search answer, and `org:` and `user:` search an owner's public repos.\n */\nexport const github = createGitHubHandler(git, { ownerIndex: {} });\n";
|
|
55
53
|
/** `export const git = createGitServer({ … });`, as chosen. */
|
|
56
|
-
const serverLines = (choices, parts) => lines("export const git = createGitServer({", parts.adapter, choices.objects === "packs" ? " objects: packs()," : looseObjects, parts.xdiff, " tokens: tokens(),", choices.objects === "packs" && " // Git LFS, its objects in the bucket beside the packs.\n lfs: lfs(),", parts.uploads && " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },", basePathLines(choices), ` auth: bearer({ token: ${parts.token}, actor: admin }),`, " authorize: ({ actor, operation }) => {", " if (actor.anonymous === true) return reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return accept();", " },", choices.queue === "on" && queueLine(choices.serve === "github"),
|
|
54
|
+
const serverLines = (choices, parts) => lines("export const git = createGitServer({", parts.adapter, choices.objects === "packs" ? " objects: packs()," : looseObjects, parts.xdiff, " tokens: tokens(),", choices.objects === "packs" && " // Git LFS, its objects in the bucket beside the packs.\n lfs: lfs(),", parts.uploads && " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },", basePathLines(choices), ` auth: bearer({ token: ${parts.token}, actor: admin }),`, " authorize: ({ actor, operation }) => {", " if (actor.anonymous === true) return reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return accept();", " },", choices.queue === "on" && queueLine(choices.serve === "github"), "});", "");
|
|
57
55
|
/** The drop-in's and the REST's handlers, as served: none for Git's protocol alone. */
|
|
58
|
-
const handlerLines = (choices) => choices.serve !== "git" && lines(choices.serve === "github" && "
|
|
56
|
+
const handlerLines = (choices) => choices.serve !== "git" && lines(choices.serve === "github" && "/**\n * GitHub's REST, GraphQL, webhooks and Event Streams, so `gh` and Octokit work, with the owner\n * index, so repo and user search answer, and `org:` and `user:` search an owner's public repos.\n */\nexport const github = createGitHubHandler(git, { ownerIndex: {} });\n", "/** Git's REST, whose `route` and `fetch` serve Git's protocol and sign-in too. */\nexport const rest = createRestHandler(git);\n");
|
|
59
57
|
/**
|
|
60
58
|
* A framework's `serve` under `--serve github`, which its Git route calls: the drop-in's links
|
|
61
59
|
* under the base path first, then REST and Git's protocol.
|
|
62
60
|
*/
|
|
63
61
|
const serveExport = (choices) => choices.serve === "github" && lines(`/** What \`${choices.basePath.replace(/\/$/, "")}\` serves: the drop-in's links first, then REST and Git's protocol. */`, "export const serve = {", " fetch: async (request: Request) => (await github.route(request)) ?? rest.fetch(request),", "};", "");
|
|
64
|
-
export { adminLines, basePathLines,
|
|
62
|
+
export { adminLines, basePathLines, gitDependencies, gitImports, gitPackages, githubHandler, handlerLines, header, lfsLines, looseObjects, looseSays, mergeLines, queueLine, serveExport, serverLines, uploads };
|
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.7.0";
|
|
4
4
|
/** The packages the app depends on, by their folder in a checkout's `packages/`. */
|
|
5
5
|
const appPackages = [
|
|
6
6
|
"infra",
|
|
@@ -10,19 +10,19 @@ const appPackages = [
|
|
|
10
10
|
];
|
|
11
11
|
/** What every platform's project builds and types with. At the root workspace's catalog. */
|
|
12
12
|
const catalog = {
|
|
13
|
-
"@cloudflare/workers-types": "5.
|
|
13
|
+
"@cloudflare/workers-types": "5.20261123.1",
|
|
14
14
|
typescript: "7.0.2",
|
|
15
|
-
wrangler: "4.
|
|
15
|
+
wrangler: "4.168.0"
|
|
16
16
|
};
|
|
17
17
|
/** What Git on Vercel installs beside Git's packages. At the root workspace's catalog. */
|
|
18
18
|
const vercelPackages = {
|
|
19
|
-
"@types/node": "24.19.
|
|
19
|
+
"@types/node": "24.19.4",
|
|
20
20
|
"@vercel/blob": "2.9.0",
|
|
21
21
|
"@vercel/queue": "0.11.0",
|
|
22
22
|
typescript: "7.0.2"
|
|
23
23
|
};
|
|
24
24
|
/** What Git on Node type-checks with beside the store's client. At the root workspace's catalog. */
|
|
25
|
-
const nodePackages = { "@types/node": "24.19.
|
|
25
|
+
const nodePackages = { "@types/node": "24.19.4" };
|
|
26
26
|
/**
|
|
27
27
|
* What the app on Node builds and reads its people with, beside the store's client (Q-IN14). At the
|
|
28
28
|
* root workspace's catalog.
|
|
@@ -44,7 +44,7 @@ const storePackages = {
|
|
|
44
44
|
* What Git's packages take as peers, which every project installs beside them (Q1086). At the root
|
|
45
45
|
* workspace's catalog.
|
|
46
46
|
*/
|
|
47
|
-
const peerPackages = { effect: "4.1.
|
|
47
|
+
const peerPackages = { effect: "4.1.7" };
|
|
48
48
|
/**
|
|
49
49
|
* What a framework's Node server needs that its create command doesn't write: SvelteKit's
|
|
50
50
|
* adapter-node, in place of `sv create`'s adapter-auto. At the framework fixtures' own catalog,
|
package/dist/init/node-app.mjs
CHANGED
|
@@ -41,8 +41,11 @@ const readme = (choices) => lines("# The starter", "", "Git, a GitHub-compatible
|
|
|
41
41
|
const migrationsOf = (records) => records === "postgres" ? "migrations/postgres/" : "migrations/sql/";
|
|
42
42
|
/** `src/env.ts` on Node: what the app reads from `.env`, each through `need()`. */
|
|
43
43
|
const envModule = lines("// What the app reads from `.env`: `npm start` passes it to Node, and `vite dev` reads it.", needHelper(".env").replace("const need =", "export const need ="), "", "/** The secrets `ref0-git init` made, where the app is served, and whether anyone may sign up. */", "export const env = {", " ADMIN_TOKEN: need('ADMIN_TOKEN'),", " SESSION_SECRET: need('SESSION_SECRET'),", " APP_ORIGIN: need('APP_ORIGIN'),", " SIGN_UP: process.env['SIGN_UP'],", " // `off` loads a text's remote images from their own origin, not through the image proxy.", " IMAGE_PROXY: process.env['IMAGE_PROXY'],", " // The header the proxy in front sets with the caller's address, such as `x-real-ip`: set it", " // only when that proxy overwrites the header. Unset, the caller's address is the socket's.", " CLIENT_IP_HEADER: process.env['CLIENT_IP_HEADER'],", " /** In dev only, at least 15 characters: the password the seed signs Pip and Mo up with. */", " DEMO_PASSWORD: process.env['DEMO_PASSWORD'],", "};", "");
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* `server/plugins/jobs.ts`: Git's jobs, started once a process. When Nitro closes, the runner stops,
|
|
46
|
+
* then the runtime is disposed, closing what its Layers opened.
|
|
47
|
+
*/
|
|
48
|
+
const jobsPlugin = lines("// Starts Git's jobs once this process, as Nitro loads its plugins. On close, it stops them, then", "// disposes the runtime, so what its Layers opened closes.", "import { definePlugin } from 'nitro';", "", "import * as Node from '@ref0/infra/node';", "", "import { runtime } from '../../src/git.ts';", "", "export default definePlugin((nitro) => {", " const stop = Node.toJobRunner(runtime);", " nitro.hooks.hook('close', async () => {", " await stop();", " await runtime.dispose();", " });", "});", "");
|
|
46
49
|
/** What `npm run migrate` opens, for each records store, and how it runs one file's SQL. */
|
|
47
50
|
const migrateParts = {
|
|
48
51
|
sqlite: lines("import { mkdirSync, readdirSync, readFileSync } from 'node:fs';", "import { DatabaseSync } from 'node:sqlite';", "", "mkdirSync('.data', { recursive: true });", "", "const database = new DatabaseSync('.data/auth.db');", "", "const run = async (sql: string) => {", " database.exec(sql);", "};", "", "/** The file and its record, bound, in one transaction, which a failure rolls back. */", "const apply = async (name: string, sql: string) => {", " database.exec('begin');", "", " try {", " database.exec(sql);", " database.prepare('insert into \"_migrations\" (\"name\") values (?)').run(name);", " database.exec('commit');", " } catch (cause) {", " if (database.isTransaction) database.exec('rollback');", "", " throw cause;", " }", "};", "", "const done = async () => {", " const rows = database.prepare('select \"name\" from \"_migrations\"').all();", "", " return new Set(rows.map((row) => String(row.name)));", "};"),
|
package/dist/init/stores.mjs
CHANGED
|
@@ -46,9 +46,10 @@ const s3Part = {
|
|
|
46
46
|
const needHelper = (where) => lines(`/** A variable the project sets, in ${where}. */`, "const need = (name: string) => {", " const value = process.env[name];", fitted(" if (value === undefined || value === '')", `throw new Error(\`Set \${name} in ${where}\`);`), "", " return value;", "};");
|
|
47
47
|
/**
|
|
48
48
|
* What `.env.example` says above a variable, if anything: Postgres's URL with `sslmode=verify-full`,
|
|
49
|
-
* since `pg` then checks the server's certificate and name, which `require` will stop doing in `pg` 9
|
|
49
|
+
* since `pg` then checks the server's certificate and name, which `require` will stop doing in `pg` 9,
|
|
50
|
+
* and what Turso's Platform API token must be allowed, since a deleted repo's purge deletes its database.
|
|
50
51
|
*/
|
|
51
|
-
const noteOf = (name) => name === "DATABASE_URL" && "# Postgres's URL. Over a network, end it ?sslmode=verify-full, so pg checks the server's certificate";
|
|
52
|
+
const noteOf = (name) => name === "DATABASE_URL" && "# Postgres's URL. Over a network, end it ?sslmode=verify-full, so pg checks the server's certificate" || name === "TURSO_API_TOKEN" && "# Turso's Platform API token: it must create and delete the group's databases, as a repo's purge deletes its own";
|
|
52
53
|
/** `.env.example`: `header`'s comment lines, then each of `variables` with an empty value. */
|
|
53
54
|
const envExample = (header, variables) => lines(...header.map((line) => `# ${line}`), ...variables.flatMap((name) => [noteOf(name), `${name}=`]), "");
|
|
54
55
|
/** The variables `parts` read, in order, which the person sets: an Output's `needs`. */
|
package/dist/init/template.mjs
CHANGED
|
@@ -11,25 +11,28 @@ const templateOf = (names) => Schema.Array(Schema.Union([Schema.String, Schema.S
|
|
|
11
11
|
const appGitSlots = [
|
|
12
12
|
"gitImport",
|
|
13
13
|
"queueTypes",
|
|
14
|
+
"githubImport",
|
|
14
15
|
"infraImport",
|
|
15
16
|
"safety",
|
|
16
17
|
"bucket",
|
|
17
18
|
"queueMerge",
|
|
18
|
-
"
|
|
19
|
-
"objects",
|
|
19
|
+
"releases",
|
|
20
20
|
"lfs",
|
|
21
21
|
"uploads",
|
|
22
|
-
"queue"
|
|
22
|
+
"queue",
|
|
23
|
+
"adapter",
|
|
24
|
+
"objects"
|
|
23
25
|
];
|
|
24
26
|
/** The slots of the app's `src/git.ts` on Node: Node's head and parts, the store's and the queue's. */
|
|
25
27
|
const appGitNodeSlots = [
|
|
26
28
|
"head",
|
|
27
29
|
"queueMerge",
|
|
28
|
-
"
|
|
29
|
-
"objects",
|
|
30
|
+
"releases",
|
|
30
31
|
"lfs",
|
|
31
32
|
"uploads",
|
|
32
33
|
"queue",
|
|
34
|
+
"adapter",
|
|
35
|
+
"objects",
|
|
33
36
|
"xdiff",
|
|
34
37
|
"database",
|
|
35
38
|
"ipHeader",
|
|
@@ -65,12 +68,15 @@ const workerGitSlots = [
|
|
|
65
68
|
"uploads",
|
|
66
69
|
"basePath",
|
|
67
70
|
"queue",
|
|
68
|
-
"events",
|
|
69
71
|
"github",
|
|
70
72
|
"rest"
|
|
71
73
|
];
|
|
72
74
|
/** The slots of the example Worker's `src/worker.ts`: what it serves. */
|
|
73
|
-
const workerEntrySlots = [
|
|
75
|
+
const workerEntrySlots = [
|
|
76
|
+
"gate",
|
|
77
|
+
"names",
|
|
78
|
+
"exports"
|
|
79
|
+
];
|
|
74
80
|
/** The slots of the example Worker's `src/env.ts`. */
|
|
75
81
|
const workerEnvSlots = [
|
|
76
82
|
"types",
|