ref0-git 0.26.0 → 0.29.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.
Files changed (49) hide show
  1. package/app/apps/github/README.md +1 -5
  2. package/app/apps/github/package.json +0 -1
  3. package/app/apps/github/src/signin/auth.ts +17 -89
  4. package/app/apps/github/src/signin/credentials.ts +10 -14
  5. package/app/apps/github/src/signin/guarded-write.ts +19 -0
  6. package/app/apps/github/src/signin/owner-names.ts +11 -41
  7. package/app/apps/github/src/signin/unborn.ts +20 -30
  8. package/app/apps/github/tsconfig.json +0 -2
  9. package/app/pnpm-workspace.yaml +14 -34
  10. package/dist/cli/documents.mjs +39 -25
  11. package/dist/cli/keys.mjs +9 -3
  12. package/dist/cli/node.mjs +1 -2
  13. package/dist/cli/runtime.mjs +3 -4
  14. package/dist/cli/setup.mjs +216 -468
  15. package/dist/cli/tools-node.mjs +8 -7
  16. package/dist/cli/tools.mjs +3 -3
  17. package/dist/cli/vercel-stores.mjs +287 -0
  18. package/dist/init/app.mjs +4 -37
  19. package/dist/init/choices.mjs +62 -209
  20. package/dist/init/cloudflare.mjs +1 -2
  21. package/dist/init/detect.mjs +77 -167
  22. package/dist/init/files.mjs +2 -12
  23. package/dist/init/frameworks.mjs +50 -174
  24. package/dist/init/git-module.mjs +5 -1
  25. package/dist/init/metadata.mjs +4 -22
  26. package/dist/init/next.mjs +13 -66
  27. package/dist/init/output.mjs +3 -6
  28. package/dist/init/plan.mjs +1 -29
  29. package/dist/init/routes.mjs +1 -78
  30. package/dist/init/stores.mjs +6 -35
  31. package/dist/init/template.mjs +14 -49
  32. package/dist/init/templates.mjs +30 -115
  33. package/dist/init/vercel-regions.mjs +87 -0
  34. package/dist/init/vercel.mjs +313 -212
  35. package/dist/init/versions.mjs +3 -3
  36. package/package.json +5 -11
  37. package/app/apps/github/migrations/postgres/0001_auth.sql +0 -53
  38. package/app/apps/github/src/camo/lookup.ts +0 -23
  39. package/app/apps/github/src/camo/node.ts +0 -50
  40. package/app/apps/github/src/signin/person-lock.ts +0 -104
  41. package/dist/cli/sqlite.mjs +0 -28
  42. package/dist/init/astro.mjs +0 -49
  43. package/dist/init/create.mjs +0 -152
  44. package/dist/init/mounts.mjs +0 -104
  45. package/dist/init/node-app.mjs +0 -196
  46. package/dist/init/node.mjs +0 -446
  47. package/dist/init/nuxt.mjs +0 -240
  48. package/dist/init/react-router.mjs +0 -59
  49. package/dist/init/sveltekit.mjs +0 -141
@@ -3,18 +3,19 @@ import * as Effect from "effect/Effect";
3
3
  import * as FileSystem from "effect/FileSystem";
4
4
  import * as Path from "effect/Path";
5
5
  // src/cli/tools-node.ts
6
- /** The project's own `wrangler`, which its install puts in `node_modules/.bin`, else `PATH`'s. */
7
- const wranglerOf = /* @__PURE__ */ Effect.fnUntraced(function* (folder) {
6
+ /** The project's own `program`, which its install puts in `node_modules/.bin`, else `PATH`'s. */
7
+ const ownOf = /* @__PURE__ */ Effect.fnUntraced(function* (folder, program) {
8
8
  const fs = yield* FileSystem.FileSystem;
9
- const own = (yield* Path.Path).join(folder, "node_modules", ".bin", "wrangler");
10
- return (yield* fs.exists(own).pipe(Effect.orElseSucceed(() => false))) ? own : "wrangler";
9
+ const own = (yield* Path.Path).join(folder, "node_modules", ".bin", program);
10
+ return (yield* fs.exists(own).pipe(Effect.orElseSucceed(() => false))) ? own : program;
11
11
  });
12
12
  /**
13
- * The real `cf` and `wrangler`, which carry the host's login: `cf` from `PATH`, and the project's
14
- * own `wrangler` before `PATH`'s. Only the `ref0-git` bin gives this runner.
13
+ * The real `cf`, `wrangler` and `vercel`, which carry the host's login: `cf` from `PATH`, and the
14
+ * project's own `wrangler` or `vercel` before `PATH`'s. Never `npx`, which logs a command's
15
+ * arguments to npm's cache. Only the `ref0-git` bin gives this runner.
15
16
  */
16
17
  const nodeTools = { run: /* @__PURE__ */ Effect.fnUntraced(function* (tool, args, cwd, options) {
17
- const program = tool === "wrangler" ? yield* wranglerOf(cwd) : tool;
18
+ const program = tool === "cf" ? tool : yield* ownOf(cwd, tool);
18
19
  return yield* runPiped([program, ...args], cwd, options);
19
20
  }) };
20
21
  export { nodeTools };
@@ -3,10 +3,10 @@ import * as Context from "effect/Context";
3
3
  import * as Effect from "effect/Effect";
4
4
  // src/cli/tools.ts
5
5
  /** The runner a run was given: one that spawns nothing, unless its entry point gives another. */
6
- const refusing = { run: (tool) => Effect.fail(failure("tools_not_given", `This ref0-git was given no way to run ${tool}, so it ran none of Cloudflare's CLIs`, "Run it as `npx ref0-git`")) };
6
+ const refusing = { run: (tool) => Effect.fail(failure("tools_not_given", `This ref0-git was given no way to run ${tool}, so it ran no platform's CLI`, "Run it as `npx ref0-git`")) };
7
7
  /**
8
- * The runner for `cf` and `wrangler`. Only the `ref0-git` bin gives the real one, so the commands
9
- * run as a library, by a test or a script, can't reach anyone's Cloudflare login.
8
+ * The runner for `cf`, `wrangler` and `vercel`. Only the `ref0-git` bin gives the real one, so the
9
+ * commands run as a library, by a test or a script, can't reach anyone's Cloudflare or Vercel login.
10
10
  */
11
11
  const Tools = Context.Reference("ref0-git/Tools", { defaultValue: () => refusing });
12
12
  export { Tools, refusing };
@@ -0,0 +1,287 @@
1
+ import { blobStoreArgs, blobStoreOf, neonArgs, neonDatabaseOf, unpooled, vercelCommand } from "../init/vercel.mjs";
2
+ import { failure } from "./failure.mjs";
3
+ import { saidBy } from "./keys.mjs";
4
+ import { CliModes, printable, say } from "./output.mjs";
5
+ import { select } from "./prompt.mjs";
6
+ import { Tools } from "./tools.mjs";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Option from "effect/Option";
9
+ import * as Schema from "effect/Schema";
10
+ import * as FileSystem from "effect/FileSystem";
11
+ import * as Path from "effect/Path";
12
+ import * as Result from "effect/Result";
13
+ // src/cli/vercel-stores.ts
14
+ /** The variables a project's Production holds, as `vercel env ls production --json` lists them. */
15
+ const Listed = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({ envs: Schema.Array(Schema.Struct({ key: Schema.String })) }));
16
+ const readListed = /* @__PURE__ */ Schema.decodeUnknownOption(Listed);
17
+ /** The Blob stores connected to the linked project, as `vercel blob list-stores --json` lists them. */
18
+ const BlobStores = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({ stores: Schema.Array(Schema.Struct({
19
+ name: Schema.String,
20
+ region: Schema.String
21
+ })) }));
22
+ const readBlobStores = /* @__PURE__ */ Schema.decodeUnknownOption(BlobStores);
23
+ /** Why each kind of skip makes nothing, as the receipt says it. */
24
+ const skippedWhy = {
25
+ dry_run: "a dry run makes nothing",
26
+ not_asked: "init makes stores only when a person at a terminal says yes, or with --stores, since Neon bills the team",
27
+ declined: "you chose not to",
28
+ not_linked: "the folder isn't linked to a Vercel project: run `vercel link` in it first"
29
+ };
30
+ const skip = (skipped, linked, present) => ({
31
+ kind: "skipped",
32
+ skipped,
33
+ why: skippedWhy[skipped],
34
+ linked,
35
+ ...present !== void 0 && { present }
36
+ });
37
+ /**
38
+ * `init`'s refusal of a Production that holds one of its Postgres's two URLs, `missing` the other:
39
+ * its next step sets that one, then runs `again`, the run as it was.
40
+ */
41
+ const halfSet = (plan, missing, again) => Effect.fail(failure("postgres_half_set", `The project's Production has ${missing === "DATABASE_URL_UNPOOLED" ? "DATABASE_URL" : unpooled} but not ${missing}, so init makes no Neon beside it`, {
42
+ says: `Set ${missing} for Production and Development to the same Postgres, with ${vercelCommand([
43
+ "env",
44
+ "add",
45
+ missing,
46
+ "production"
47
+ ], plan.dir)}, then run init again`,
48
+ run: [again]
49
+ }));
50
+ /** `vercel` with `args`, run by the run's `Tools` in the project's folder. */
51
+ const vercel = /* @__PURE__ */ Effect.fnUntraced(function* (folder, args) {
52
+ return yield* (yield* Tools).run("vercel", args, folder, {});
53
+ });
54
+ /** Whether `folder` is linked to a Vercel project, as `vercel link` leaves `.vercel/project.json`. */
55
+ const linkedIn = /* @__PURE__ */ Effect.fnUntraced(function* (folder) {
56
+ const fs = yield* FileSystem.FileSystem;
57
+ const path = yield* Path.Path;
58
+ return yield* fs.exists(path.join(folder, ".vercel", "project.json")).pipe(Effect.orElseSucceed(() => false));
59
+ });
60
+ /**
61
+ * The names of the variables the linked project's Production holds, its values never kept, or why
62
+ * `vercel` didn't list them.
63
+ */
64
+ const variablesOf = /* @__PURE__ */ Effect.fnUntraced(function* (folder) {
65
+ const result = yield* Effect.result(vercel(folder, [
66
+ "env",
67
+ "ls",
68
+ "production",
69
+ "--json"
70
+ ]));
71
+ if (Result.isFailure(result)) return { why: result.failure.headline };
72
+ const ran = result.success;
73
+ const listed = ran.exit === 0 ? Option.getOrUndefined(readListed(ran.stdout)) : void 0;
74
+ if (listed === void 0) return { why: `vercel env ls didn't list the project's variables: ${saidBy(ran, "vercel")}` };
75
+ return { names: new Set(listed.envs.map((env) => env.key)) };
76
+ });
77
+ /**
78
+ * What `init` makes, settled before it writes, so it asks its one question with the rest: none in
79
+ * a dry run, with `--no-stores`, in a folder linked to no project, or, without `--stores`, in a run
80
+ * no person answers or that takes `--yes`; else each store the project's Production lacks, after a
81
+ * person at a terminal says yes to the list, or with `--stores`. Neon bills the team for its
82
+ * database, so nothing makes one unasked. Past a dry run, a linked folder's Production is read
83
+ * even when `init` makes nothing, so its next step names only what's missing: a Postgres whose two
84
+ * URLs it holds is used as it is, and one with only one of them stops the run before it writes.
85
+ */
86
+ const storesAsked = /* @__PURE__ */ Effect.fnUntraced(function* (plan, flags) {
87
+ const mode = yield* CliModes;
88
+ const linked = yield* linkedIn(plan.folder);
89
+ if (flags.dryRun) return skip("dry_run", linked);
90
+ const declined = Option.isSome(flags.stores) && !flags.stores.value;
91
+ const asking = Option.isNone(flags.stores);
92
+ const unasked = asking && (!mode.interactive || flags.yes);
93
+ if (!linked) return skip(declined ? "declined" : unasked ? "not_asked" : "not_linked", false);
94
+ const read = yield* variablesOf(plan.folder);
95
+ const pooled = read.names?.has("DATABASE_URL") ?? false;
96
+ if (read.names !== void 0 && pooled !== read.names.has("DATABASE_URL_UNPOOLED")) return yield* halfSet(plan, pooled ? unpooled : "DATABASE_URL", flags.again);
97
+ const held = read.names === void 0 ? void 0 : {
98
+ blob: read.names.has("BLOB_READ_WRITE_TOKEN"),
99
+ postgres: pooled
100
+ };
101
+ if (declined) return skip("declined", true, held);
102
+ if (unasked) return skip("not_asked", true, held);
103
+ if (read.names === void 0) return {
104
+ kind: "skipped",
105
+ skipped: "unread",
106
+ why: read.why,
107
+ linked: true
108
+ };
109
+ const present = {
110
+ blob: read.names.has("BLOB_READ_WRITE_TOKEN"),
111
+ postgres: pooled
112
+ };
113
+ const made = {
114
+ kind: "make",
115
+ blobPresent: present.blob,
116
+ postgresPresent: present.postgres
117
+ };
118
+ const making = [...present.blob ? [] : [`a private Blob store, ${blobStoreOf(plan.name)}`], ...present.postgres ? [] : [`Neon's Postgres, ${neonDatabaseOf(plan.name)}, which Neon bills the project's team for`]];
119
+ if (!asking || making.length === 0) return made;
120
+ yield* say(` init can make, in ${plan.region}, for the project this folder is linked to:`, ...making.map((each) => ` ${each}`));
121
+ const one = making.length === 1;
122
+ return (yield* select("Stores", `Make ${one ? "it" : "them"}?`, [{
123
+ value: false,
124
+ label: `Don't: init prints the command${one ? " that makes it" : "s that make them"}`
125
+ }, {
126
+ value: true,
127
+ label: `Make ${one ? "it" : "them"}`
128
+ }])) ? made : skip("declined", true, present);
129
+ });
130
+ /** `args`' run of `vercel`, as the store it makes reads after it: made, or failed with why. */
131
+ const making = /* @__PURE__ */ Effect.fnUntraced(function* (plan, says, args) {
132
+ if (!(yield* CliModes).json) yield* say(` Making ${says} in ${plan.region}...`);
133
+ const result = yield* Effect.result(vercel(plan.folder, args));
134
+ if (Result.isFailure(result)) return {
135
+ state: "failed",
136
+ why: result.failure.headline
137
+ };
138
+ const ran = result.success;
139
+ if (ran.exit !== 0) return {
140
+ state: "failed",
141
+ why: saidBy(ran, "vercel")
142
+ };
143
+ return { state: "made" };
144
+ });
145
+ /**
146
+ * The stores `asked` settled, made once `init` has written the project's files: the Blob store,
147
+ * then Neon's database, each only where the project lacks it. One that fails leaves the other to
148
+ * be made, and its next step names the command.
149
+ */
150
+ const storesMade = /* @__PURE__ */ Effect.fnUntraced(function* (plan, asked) {
151
+ if (asked.kind === "skipped") return {
152
+ plan,
153
+ linked: asked.linked,
154
+ skipped: asked.skipped,
155
+ blob: asked.present?.blob === true ? { state: "present" } : {
156
+ state: "left",
157
+ why: asked.why
158
+ },
159
+ postgres: asked.present?.postgres === true ? { state: "present" } : {
160
+ state: "left",
161
+ why: asked.why
162
+ }
163
+ };
164
+ return {
165
+ plan,
166
+ linked: true,
167
+ blob: asked.blobPresent ? { state: "present" } : yield* making(plan, `the private Blob store ${blobStoreOf(plan.name)}`, blobStoreArgs(plan.name, plan.region)),
168
+ postgres: asked.postgresPresent ? { state: "present" } : yield* making(plan, `Neon's Postgres ${neonDatabaseOf(plan.name)}`, neonArgs(plan.name, plan.region))
169
+ };
170
+ });
171
+ /** What's left of the stores after `init`, for its next step's words. */
172
+ const storesLeftOf = (stores) => {
173
+ const done = (store) => store.state === "made" || store.state === "present";
174
+ return {
175
+ linked: stores.linked,
176
+ blob: !done(stores.blob),
177
+ postgres: !done(stores.postgres)
178
+ };
179
+ };
180
+ /** What a store's field in the receipt says. */
181
+ const stateSaid = (store) => {
182
+ if (store.state === "made") return "made";
183
+ if (store.state === "present") return "there already, so left as it is";
184
+ return `${store.state === "failed" ? "not made" : "left"}: ${store.why ?? ""}`;
185
+ };
186
+ /** What `init`'s receipt says of the stores. */
187
+ const storesFields = (stores) => [["Blob store", `${blobStoreOf(stores.plan.name)} in ${stores.plan.region}, ${stateSaid(stores.blob)}`], ["Postgres", stores.postgres.state === "present" ? `DATABASE_URL and ${unpooled}, there already, so init made no Neon` : `Neon's ${neonDatabaseOf(stores.plan.name)} in ${stores.plan.region}, ${stateSaid(stores.postgres)}`]];
188
+ /** What `init`'s document says of the stores. */
189
+ const storesDocument = (stores) => ({
190
+ region: stores.plan.region,
191
+ skipped: stores.skipped ?? null,
192
+ blob: {
193
+ name: blobStoreOf(stores.plan.name),
194
+ ...stores.blob
195
+ },
196
+ postgres: {
197
+ name: neonDatabaseOf(stores.plan.name),
198
+ ...stores.postgres
199
+ }
200
+ });
201
+ /**
202
+ * What `doctor` reads of the stores of the project `folder` is linked to, under the host's own
203
+ * `vercel` login: Production's variables, by name, and the Blob stores connected to it. None in a
204
+ * folder linked to no project, or where `vercel` lists no variables, as with no login; the
205
+ * variables alone where it lists no stores.
206
+ */
207
+ const storesFound = /* @__PURE__ */ Effect.fnUntraced(function* (folder) {
208
+ if (!(yield* linkedIn(folder))) return {
209
+ kind: "skipped",
210
+ why: skippedWhy.not_linked
211
+ };
212
+ const read = yield* variablesOf(folder);
213
+ if (read.names === void 0) return {
214
+ kind: "skipped",
215
+ why: read.why
216
+ };
217
+ const result = yield* Effect.result(vercel(folder, [
218
+ "blob",
219
+ "list-stores",
220
+ "--json"
221
+ ]));
222
+ const listed = Result.isSuccess(result) && result.success.exit === 0 ? Option.getOrUndefined(readBlobStores(result.success.stdout)) : void 0;
223
+ const blob = listed !== void 0 ? listed.stores : { why: Result.isFailure(result) ? result.failure.headline : `vercel blob list-stores didn't list the project's stores: ${saidBy(result.success, "vercel")}` };
224
+ return {
225
+ kind: "read",
226
+ production: read.names,
227
+ blob
228
+ };
229
+ });
230
+ /** The variables Git's deploy reads from Production, which its Blob store and Postgres set. */
231
+ const storeVariables = [
232
+ "BLOB_READ_WRITE_TOKEN",
233
+ "DATABASE_URL",
234
+ unpooled
235
+ ];
236
+ /**
237
+ * What `doctor` finds of a Vercel project's stores in `found`: whether Production holds each
238
+ * store's variables and a Blob store is connected, which blocks deploying, and whether each Blob
239
+ * store is in `functions`, the Functions' region, which never blocks, since a store far away still
240
+ * answers. Skipped, never passed, when `doctor` couldn't read them. A `vercel` command its words
241
+ * quote runs in `dir`, the folder `doctor` was given.
242
+ */
243
+ const storesFindings = (found, functions, dir) => {
244
+ if (found.kind === "skipped") return [{
245
+ check: "Stores",
246
+ ok: false,
247
+ skipped: true,
248
+ says: `Not checked: ${found.why}`
249
+ }];
250
+ const has = (name) => found.production.has(name);
251
+ const unlisted = "why" in found.blob ? found.blob.why : void 0;
252
+ const stores = "why" in found.blob ? void 0 : found.blob.map((store) => ({
253
+ name: printable(store.name),
254
+ region: printable(store.region)
255
+ }));
256
+ const half = has("DATABASE_URL") !== has(unpooled);
257
+ const missing = has("DATABASE_URL") ? unpooled : "DATABASE_URL";
258
+ const problems = [...has("BLOB_READ_WRITE_TOKEN") ? stores?.length === 0 ? ["Production has BLOB_READ_WRITE_TOKEN, but no Blob store is connected to the project: connect the one it's from, or remove it and run init's --stores to make one"] : [] : stores !== void 0 && stores.length > 0 ? ["Production lacks BLOB_READ_WRITE_TOKEN, though a Blob store is connected to the project: connect it for Production too"] : ["Production lacks BLOB_READ_WRITE_TOKEN: init's --stores makes a Blob store, which sets it"], ...half ? [`Production has ${missing === "DATABASE_URL_UNPOOLED" ? "DATABASE_URL" : unpooled} but not ${missing}: set it to the same Postgres with ${vercelCommand([
259
+ "env",
260
+ "add",
261
+ missing,
262
+ "production"
263
+ ], dir)}`] : has("DATABASE_URL") ? [] : [`Production lacks DATABASE_URL and ${unpooled}: init's --stores makes Neon's Postgres, which sets them, or set both to your own`]];
264
+ const one = stores?.length === 1;
265
+ const names = (stores ?? []).map((store) => store.name).join(", ");
266
+ const connected = {
267
+ check: "Stores",
268
+ ok: problems.length === 0,
269
+ says: problems.length > 0 ? problems.join(". ") : stores === void 0 ? `Production has ${storeVariables.join(", ")}` : `Production has ${storeVariables.join(", ")}, and the Blob store${one ? "" : "s"} ${names} ${one ? "is" : "are"} connected to the project`,
270
+ blocks: "deploying: Git keeps its packs in Blob and its records in Postgres"
271
+ };
272
+ if (stores === void 0) return [connected, {
273
+ check: "Blob stores",
274
+ ok: false,
275
+ skipped: true,
276
+ says: `Not checked: ${unlisted ?? ""}`
277
+ }];
278
+ if (functions === void 0 || stores.length === 0) return [connected];
279
+ const where = stores.map((store) => `${store.name} in ${store.region}`).join(", ");
280
+ const apart = stores.filter((store) => store.region !== functions);
281
+ return [connected, {
282
+ check: "Blob region",
283
+ ok: true,
284
+ says: apart.length === 0 ? `${where}, beside the Functions and the Daemon in ${functions}` : `${where}: ${apart.map((store) => store.name).join(", ")} apart from the Functions and the Daemon in ${functions}, so each pack crosses to it. A store's region is fixed when it's made: make one in ${functions} and connect it instead`
285
+ }];
286
+ };
287
+ export { storesAsked, storesDocument, storesFields, storesFindings, storesFound, storesLeftOf, storesMade };
package/dist/init/app.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { bucketLine, bucketName, devVars, limitsLine, looseInfraImport, mergePackage, secretFiles } from "./cloudflare.mjs";
2
- import { ignoring, importLine, lines, listed, withCli } from "./files.mjs";
3
- import { bucketLines, firstImports, infraImports, partsOf, storeLines } from "./node.mjs";
2
+ import { ignoring, importLine, listed, withCli } from "./files.mjs";
4
3
  import { specOf } from "./versions.mjs";
5
4
  import { lfsLines, looseSays, workerStoreLines, writtenCpu } from "./git-module.mjs";
6
5
  import { jsonString, manifestText } from "./jsonc.mjs";
@@ -113,7 +112,7 @@ const githubImport = (choices) => importLine([
113
112
  ].filter(Predicate.isString), "@ref0/github");
114
113
  /** Git's objects with no bucket: each a row in its push's commit, and what a push may carry. */
115
114
  const looseObjects = `/** Git's objects, each a row in its push's commit: no bucket, ${looseSays}. */\nconst objects = Objects.layerRecords();`;
116
- /** The slots both platforms' `src/git.ts` fill alike: the queue's, and the store's past the head. */
115
+ /** The slots of `src/git.ts` past its head: the queue's, and the store's. */
117
116
  const bodySlots = (choices) => {
118
117
  const queue = choices.queue === "on";
119
118
  const packs = choices.objects === "packs";
@@ -124,7 +123,7 @@ const bodySlots = (choices) => {
124
123
  releases: unless(packs, "")
125
124
  };
126
125
  };
127
- /** The app's `src/git.ts` on Cloudflare: `apps/github`'s own, its store's and queue's slots filled. */
126
+ /** The app's `src/git.ts`: `apps/github`'s own, its store's and queue's slots filled. */
128
127
  const cloudflareGit = (choices) => {
129
128
  const packs = choices.objects === "packs";
130
129
  return filled(templates.appGit, {
@@ -141,40 +140,8 @@ const cloudflareGit = (choices) => {
141
140
  ...bodySlots(choices)
142
141
  });
143
142
  };
144
- /** Better Auth's database on Node, beside the records `--records` chose (init.md's table). */
145
- const peopleOn = {
146
- postgres: lines("// Better Auth's own pool, never Git's: a sign-up holds one of its connections while the session's", "// Git token is minted through Git, and on one shared pool that mint would wait on itself. Its", "// transactions are on, so a sign-up that fails partway leaves no person behind.", "const people = {", " dialect: new PostgresDialect({ pool: new pg.Pool({ connectionString: need('DATABASE_URL') }) }),", " type: 'postgres' as const,", " transaction: true,", "};"),
147
- turso: lines("/** People and their sessions, in `git-auth`, one more database in the group: `npm run migrate` makes it. */", "const people = {", " dialect: new LibsqlDialect({", " url: databases.url('git-auth'),", " authToken: need('TURSO_GROUP_TOKEN'),", " }),", " type: 'sqlite' as const,", "};"),
148
- sqlite: lines("/** People and their sessions: Better Auth's tables in a file of their own, which `npm run migrate` makes. */", "const people = new DatabaseSync('.data/auth.db');"),
149
- "durable-objects": ""
150
- };
151
- /** The Kysely dialect Better Auth's database is read through on Node, when it takes one. */
152
- const dialectOn = {
153
- postgres: "import { PostgresDialect } from 'kysely';",
154
- turso: "import { LibsqlDialect } from '@libsql/kysely-libsql';",
155
- sqlite: false,
156
- "durable-objects": false
157
- };
158
- /** The app's `src/git.ts` on Node: its imports, the store, the bucket and Better Auth's database. */
159
- const nodeHead = (choices) => {
160
- const queue = choices.queue === "on";
161
- const dialect = dialectOn[choices.records];
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], "");
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. */
165
- const nodeGit = (choices) => filled(templates.appGitNode, {
166
- head: `${nodeHead(choices)}\n`,
167
- lfs: choices.objects === "packs" ? `${lfsLines(" ", void 0)}\n` : "",
168
- 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;",
169
- 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),", "") : "",
170
- xdiff: " Layer.provideMerge(Merges.layer({ xdiff: await xdiff() })),",
171
- database: " database: people,",
172
- ipHeader: lines(" // The server's own, which `src/server.ts` sets from the caller's address on every request.", " ipHeader: clientIpHeader,", ""),
173
- classes: "",
174
- ...bodySlots(choices)
175
- });
176
143
  /** The app's `src/git.ts`: Git, the drop-in and Better Auth over the host's policy. */
177
- const appGitModule = (choices) => choices.platform === "node" ? nodeGit(choices) : cloudflareGit(choices);
144
+ const appGitModule = cloudflareGit;
178
145
  /** The app's `src/env.ts`: `apps/github`'s own, its bucket's bindings and secrets as the store has them. */
179
146
  const appEnvModule = (choices) => {
180
147
  const packs = choices.objects === "packs";