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
@@ -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.26.0";
3
+ const release = "0.29.0";
4
4
  /** The packages the app depends on, by their folder in a checkout's `packages/`. */
5
5
  const appPackages = [
6
6
  "infra",
@@ -18,25 +18,13 @@ const catalog = {
18
18
  const vercelPackages = {
19
19
  "@types/node": "24.19.4",
20
20
  "@vercel/blob": "2.9.0",
21
- "@vercel/queue": "0.11.0",
22
21
  typescript: "7.0.2"
23
22
  };
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.4" };
26
23
  /**
27
- * What the app on Node builds and reads its people with, beside the store's client (Q-IN14). At the
28
- * root workspace's catalog.
29
- */
30
- const nodeAppPackages = {
31
- "@libsql/kysely-libsql": "0.4.1",
32
- nitro: "3.0.261103-rc"
33
- };
34
- /**
35
- * The clients of the stores more than one platform offers, as `init/stores.ts` names them. At the
36
- * root workspace's catalog.
24
+ * Postgres's client and its types, which Git on Vercel installs, as `init/stores.ts` names them. At
25
+ * the root workspace's catalog.
37
26
  */
38
27
  const storePackages = {
39
- "@libsql/client": "0.18.0",
40
28
  "@types/pg": "8.23.1",
41
29
  pg: "8.23.1"
42
30
  };
@@ -46,14 +34,8 @@ const storePackages = {
46
34
  */
47
35
  const peerPackages = { effect: "4.1.7" };
48
36
  /**
49
- * What a framework's Node server needs that its create command doesn't write: SvelteKit's
50
- * adapter-node, in place of `sv create`'s adapter-auto. At the framework fixtures' own catalog,
51
- * which differs from the root's.
52
- */
53
- const frameworkPackages = { "@sveltejs/adapter-node": "6.0.5" };
54
- /**
55
37
  * The CPU a Worker's request may use, in ms: the app's and the example's `limits.cpu_ms`, which
56
38
  * their `Lfs.layer` takes too.
57
39
  */
58
40
  const workerCpuMs = 3e5;
59
- export { appPackages, catalog, frameworkPackages, nodeAppPackages, nodePackages, peerPackages, release, storePackages, vercelPackages, workerCpuMs };
41
+ export { appPackages, catalog, peerPackages, release, storePackages, vercelPackages, workerCpuMs };
@@ -3,22 +3,12 @@ import { nextConfigs } from "./frameworks.mjs";
3
3
  import { gitRoutes, rootGitPattern } from "./routes.mjs";
4
4
  // src/init/next.ts
5
5
  /**
6
- * What `init` writes in a Next.js project: a route file for Git's URLs under the base path, one
7
- * for each of the drop-in's paths at the root, and on Vercel the two job routes `vercel.json`
8
- * names. Each route loads the server module on its first request: `next build` loads every route
9
- * to read its options, and one that imported the module at its top would open the database and
10
- * want `ADMIN_TOKEN` at build time.
6
+ * What `init` writes in a Next.js project on Vercel: a route file for Git's URLs under the base
7
+ * path, and one for each of the drop-in's paths at the root. No route runs a job: the Daemon runs
8
+ * every one. Each route loads the server module on its first request: `next build` loads every
9
+ * route to read its options, and one that imported the module at its top would open the database
10
+ * and want `ADMIN_TOKEN` at build time.
11
11
  */
12
- /** The job routes on Vercel: the queue's deliveries, which `vercel.json`'s trigger names, and the cron's. */
13
- const nextJobRoutes = (framework) => {
14
- const app = framework.appDir ?? "app";
15
- return {
16
- jobs: `${app}/api/git-jobs/route.ts`,
17
- sweep: `${app}/api/git-jobs/sweep/route.ts`
18
- };
19
- };
20
- /** The cron's path, which `app/api/git-jobs/sweep/route.ts` answers. */
21
- const nextSweepPath = "/api/git-jobs/sweep";
22
12
  /** `to`'s import specifier from the file at `from`, as Next.js takes it: relative, with no `.ts`. */
23
13
  const importOf = (from, to) => {
24
14
  const ups = from.split("/").length - 1;
@@ -37,28 +27,17 @@ const nextTails = {
37
27
  segment: "[id]/",
38
28
  none: ""
39
29
  };
40
- /** One route file: the lazy handler over its export, and on Vercel the plan's `maxDuration`. */
30
+ /** One route file: the lazy handler over its export, and Pro's `maxDuration`. */
41
31
  const routeFile = (route, app, module, maxDuration) => {
42
32
  const path = `${app}/${route.at}/${nextTails[route.tail]}route.ts`;
43
33
  return {
44
34
  path,
45
35
  kind: "whole",
46
- text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import { Git } from '@ref0/git';", "", ...loaded, handlerLine(`Git.toFetch((await import('${importOf(path, module)}')).runtime)(request);`), "", maxDuration !== void 0 && `export const maxDuration = ${maxDuration};\n`, `export { ${route.methods.map((method) => `git as ${method}`).join(", ")} };`, "")
36
+ text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import { Git } from '@ref0/git';", "", ...loaded, handlerLine(`Git.toFetch((await import('${importOf(path, module)}')).runtime)(request);`), "", `export const maxDuration = ${maxDuration};\n`, `export { ${route.methods.map((method) => `git as ${method}`).join(", ")} };`, "")
47
37
  };
48
38
  };
49
- /** A job route on Vercel: `jobs`, the queue's handler, for the queue's message or the cron's call. */
50
- const jobFile = (path, method, says, module, maxDuration) => ({
51
- path,
52
- kind: "whole",
53
- text: lines(...says, "// Written by `ref0-git init`.", `export const maxDuration = ${maxDuration};`, "", `export const ${method} = async (request: Request) => {`, ` const { jobs } = await import('${importOf(path, module)}');`, "", " return jobs(request);", "};", "")
54
- });
55
- /** Next.js's route files for `choices`, over `framework`'s server module; on Vercel, at `maxDuration`. */
39
+ /** Next.js's route files for `choices`, over `framework`'s server module, at `maxDuration`. */
56
40
  const nextRouteFiles = (choices, framework, maxDuration) => gitRoutes(choices).map((route) => routeFile(route, framework.appDir ?? "app", framework.serverModule, maxDuration));
57
- /** The two job routes on Vercel, at the plan's `maxDuration`. */
58
- const nextJobFiles = (framework, maxDuration) => {
59
- const { jobs, sweep } = nextJobRoutes(framework);
60
- return [jobFile(jobs, "POST", ["// Vercel Queues' deliveries: `vercel.json` gives this route the trigger, which makes it private."], framework.serverModule, maxDuration), jobFile(sweep, "GET", ["// The cron's sweep, refused without `CRON_SECRET`: a message for each scope with work due."], framework.serverModule, maxDuration)];
61
- };
62
41
  /**
63
42
  * `gh` builds a repo's Git URL from the host, `/<owner>/<repo>.git/…` at the root, whatever
64
43
  * `clone_url` says, and git-lfs keeps it for every batch. This rewrite sends only those endings,
@@ -92,43 +71,16 @@ const rewritesLines = (choices) => {
92
71
  };
93
72
  /** `init`'s own `next.config.ts`, with the rewrite in it: what it writes where there's none. */
94
73
  const nextConfigText = (choices) => lines("import type { NextConfig } from \"next\";", "", "const nextConfig: NextConfig = {", ...rewritesLines(choices), "};", "", "export default nextConfig;", "");
95
- /**
96
- * The line of `create-next-app`'s `next.config.ts` the rewrite goes after: `init` edits the file the
97
- * create command actually wrote there, when the line is in it exactly once.
98
- */
99
- const nextConfigAnchor = "const nextConfig: NextConfig = {\n";
100
- /**
101
- * The rewrite after `path`'s one anchor line, as an edit of `text`, or `undefined` where the line
102
- * isn't there exactly once.
103
- */
104
- const withRewrite = (path, text, choices) => {
105
- const at = text.indexOf(nextConfigAnchor);
106
- if (at === -1 || text.includes("const nextConfig: NextConfig = {\n", at + 1)) return void 0;
107
- const after = at + 33;
108
- const adds = rewritesLines(choices);
109
- return {
110
- path,
111
- kind: "edit",
112
- from: text,
113
- text: `${text.slice(0, after)}${adds.join("\n")}\n${text.slice(after)}`,
114
- edit: {
115
- anchor: nextConfigAnchor.trimEnd(),
116
- adds,
117
- swaps: []
118
- }
119
- };
120
- };
121
74
  /** Whether a `next.config`'s text has the rewrite, as `init` writes it. */
122
75
  const rewrites = (text, choices) => {
123
76
  const { source, destination } = nextRewrite(choices);
124
77
  return text.includes(source) && text.includes(destination);
125
78
  };
126
79
  /**
127
- * The rewrite under `--serve github`: a `next.config.ts` where the project has none, or, in the one
128
- * a create command wrote in this same run, after its anchor line; else, in the person's own
129
- * `next.config`, or one whose anchor isn't there exactly once, a printed step.
80
+ * The rewrite under `--serve github`: a `next.config.ts` where the project has none, else, in the
81
+ * person's own `next.config`, a printed step.
130
82
  */
131
- const nextConfigOutput = (choices, framework, created) => {
83
+ const nextConfigOutput = (choices, framework) => {
132
84
  const { config } = framework;
133
85
  if (choices.serve !== "github" || config !== void 0 && rewrites(config.text, choices)) return {
134
86
  files: [],
@@ -142,17 +94,12 @@ const nextConfigOutput = (choices, framework, created) => {
142
94
  }],
143
95
  manual: []
144
96
  };
145
- const edited = created ? withRewrite(config.path, config.text, choices) : void 0;
146
- if (edited !== void 0) return {
147
- files: [edited],
148
- manual: []
149
- };
150
97
  return {
151
98
  files: [],
152
99
  manual: [{
153
100
  path: config.path,
154
101
  says: "Rewrite gh's root Git URLs to Git's route, in nextConfig",
155
- why: created ? "template_changed" : "yours",
102
+ why: "yours",
156
103
  lines: rewritesLines(choices)
157
104
  }]
158
105
  };
@@ -200,4 +147,4 @@ const nextFindings = (read, choices) => {
200
147
  says: "Next.js answers /api/v3/ with a 308 to /api/v3, which gh follows for a GET"
201
148
  }] : []];
202
149
  };
203
- export { nextConfigAnchor, nextConfigOutput, nextFindings, nextJobFiles, nextJobRoutes, nextRewrite, nextRouteFiles, nextSweepPath };
150
+ export { nextConfigOutput, nextFindings, nextRewrite, nextRouteFiles };
@@ -1,18 +1,15 @@
1
1
  import { cloudflareOutput, secretFiles as secretFiles$1 } from "./cloudflare.mjs";
2
- import { nodeOutput, secretFiles as secretFiles$2 } from "./node.mjs";
3
- import { secretFiles as secretFiles$3, vercelOutput } from "./vercel.mjs";
2
+ import { secretFiles as secretFiles$2, vercelOutput } from "./vercel.mjs";
4
3
  // src/init/output.ts
5
4
  /** The output of each platform `init` sets Git up on. */
6
5
  const outputs = {
7
6
  cloudflare: cloudflareOutput,
8
- vercel: vercelOutput,
9
- node: nodeOutput
7
+ vercel: vercelOutput
10
8
  };
11
9
  /** The files that hold secrets on each platform. */
12
10
  const secretFiles = {
13
11
  cloudflare: secretFiles$1,
14
- vercel: secretFiles$3,
15
- node: secretFiles$2
12
+ vercel: secretFiles$2
16
13
  };
17
14
  /** Everything `init` writes for `choices` in `project`, on its platform, with `secret` making each new secret. */
18
15
  const outputOf = (choices, project, secret, vendor) => outputs[choices.platform](choices, project, secret, vendor);
@@ -1,25 +1,5 @@
1
- import { parseJsonc } from "./jsonc.mjs";
2
1
  import { createTwoFilesPatch } from "diff";
3
2
  // src/init/plan.ts
4
- /** `node`'s text as written, compact, so the same value reads the same wherever it's indented. */
5
- const compact = (text, node) => node === void 0 ? void 0 : text.slice(node.start, node.end).replace(/\s+/g, "");
6
- /**
7
- * What `to` adds to `from` or changes in it, two JSON documents' texts, as each value it sets under
8
- * an object's keys: what a create command's dry run says `init` adds to the `package.json` it
9
- * hasn't written yet.
10
- */
11
- const addedTo = (from, to) => {
12
- const walk = (before, after, at) => {
13
- if (after === void 0) return [];
14
- if (after.kind !== "object") return compact(from, before) === compact(to, after) ? [] : [{
15
- at,
16
- raw: to.slice(after.start, after.end)
17
- }];
18
- const held = before?.kind === "object" ? before.members : [];
19
- return after.members.flatMap(({ key, value }) => walk(held.find((member) => member.key === key)?.value, value, [...at, key]));
20
- };
21
- return walk(parseJsonc(from), parseJsonc(to), []);
22
- };
23
3
  /** The change from `from` to `to` of `path`, as a person applies it. */
24
4
  const patchOf = (path, from, to) => createTwoFilesPatch(path, `${path} (init)`, from, to, void 0, void 0, { context: 3 }).replace(/^=+\n/, "");
25
5
  /**
@@ -45,7 +25,6 @@ const plan = (files, held, read) => files.map((file) => {
45
25
  path: file.path,
46
26
  action: "merge",
47
27
  text,
48
- from: current,
49
28
  patch: secrets === void 0 ? patchOf(file.path, current, text) : void 0,
50
29
  secrets
51
30
  };
@@ -59,13 +38,6 @@ const plan = (files, held, read) => files.map((file) => {
59
38
  path: file.path,
60
39
  action: "unchanged"
61
40
  };
62
- if (file.kind === "edit" && current === file.from) return {
63
- path: file.path,
64
- action: "edit",
65
- text: file.text,
66
- from: current,
67
- edit: file.edit
68
- };
69
41
  const was = held?.find((each) => each.path === file.path);
70
42
  if (was?.kind === "whole" && was.text === current) return {
71
43
  path: file.path,
@@ -79,4 +51,4 @@ const plan = (files, held, read) => files.map((file) => {
79
51
  patch: patchOf(file.path, current, file.text)
80
52
  };
81
53
  });
82
- export { addedTo, patchOf, plan };
54
+ export { patchOf, plan };
@@ -59,81 +59,4 @@ const gitRoutes = (choices) => {
59
59
  methods: route.methods
60
60
  }))];
61
61
  };
62
- /**
63
- * The matcher a mount beside an app calls for each `--serve`, and its package: the path Git, or
64
- * the drop-in, answers a URL at, or `undefined` for the app's.
65
- */
66
- const pathMatchers = {
67
- github: {
68
- name: "githubPathOf",
69
- from: "@ref0/github"
70
- },
71
- api: {
72
- name: "gitPathOf",
73
- from: "@ref0/git"
74
- },
75
- git: {
76
- name: "gitPathOf",
77
- from: "@ref0/git"
78
- }
79
- };
80
- /** The base path as a matcher takes it, with no trailing slash: `''` for the root. */
81
- const matcherBase = (choices) => choices.basePath.replace(/\/$/, "");
82
- /**
83
- * A mount's call of its matcher over the URL `url`, as printed source: the path Git, or the
84
- * drop-in, answers it at, or `undefined` for the app's.
85
- */
86
- const matcherCall = (choices) => `${pathMatchers[choices.serve].name}(url, '${matcherBase(choices)}')`;
87
- /**
88
- * Git's routes in a framework that routes by its files, Astro or React Router, which have no
89
- * rewrite of Next.js's or reroute of SvelteKit's: with `--serve github`, `gh`'s root Git URLs too,
90
- * `/<owner>/<repo>.git/` then Smart HTTP's or LFS's ending, as `@ref0/github`'s `urls.ts` matches
91
- * them, which Git answers at its own URL under the base path. A server's other paths under `.git/`
92
- * stay its own. `:repo.git` is the parameter `repo`, then `.git`.
93
- */
94
- const fileRoutes = (choices) => {
95
- if (choices.serve !== "github") return gitRoutes(choices);
96
- return [...gitRoutes(choices), ...rootGitEndings.map((ending) => ({
97
- at: ending.path,
98
- tail: ending.tail,
99
- says: `gh's Git URLs at the root, which Git answers as its own under \`${choices.basePath}\`.`,
100
- methods: ending.methods
101
- }))];
102
- };
103
- /** `to`'s import specifier from the file at `from`, both from the project's root: relative, with no `.ts`. */
104
- const importOf = (from, to) => {
105
- const here = from.split("/").slice(0, -1);
106
- const there = to.replace(/\.ts$/, "").split("/");
107
- const differs = here.findIndex((part, at) => part !== there[at]);
108
- const shared = differs === -1 ? here.length : differs;
109
- const ups = here.length - shared;
110
- return `${ups === 0 ? "./" : "../".repeat(ups)}${there.slice(shared).join("/")}`;
111
- };
112
- /**
113
- * A route file's handler, `git`, over the server module at `module`, as printed source. The
114
- * matcher names the path Git answers the URL the framework parsed at, its dot segments resolved,
115
- * so a route's own pattern never decides, and Git answers in place there: no 308 for `gh`'s root
116
- * URLs. A path the matcher names no Git path for gets a 404. The module loads on the first
117
- * request, since a framework's build loads each route module, and one that imported the server
118
- * module at its top would open the database and want `ADMIN_TOKEN` then.
119
- */
120
- const routeHandler = (choices, file, module) => [
121
- "const git = async (request: Request) => {",
122
- " const url = new URL(request.url);",
123
- ` const path = ${matcherCall(choices)};`,
124
- " if (path === undefined) return new Response(null, { status: 404 });",
125
- "",
126
- " url.pathname = path;",
127
- ` const { runtime } = await import('${importOf(file, module)}');`,
128
- "",
129
- " return Git.toFetch(runtime)(new Request(url, request));",
130
- "};"
131
- ];
132
- /** The matcher's import, for a route file or a mount beside an app. */
133
- const matcherImport = (choices) => `import { ${pathMatchers[choices.serve].name} } from '${pathMatchers[choices.serve].from}';`;
134
- /**
135
- * A route file's import lines: Git, whose `toFetch` answers on the module's runtime, and the
136
- * matcher.
137
- */
138
- const routeImports = (choices) => choices.serve === "github" ? ["import { Git } from '@ref0/git';", matcherImport(choices)] : [`import { Git, ${pathMatchers[choices.serve].name} } from '@ref0/git';`];
139
- export { dropInPrefixes, fileRoutes, gitRoutes, importOf, matcherCall, matcherImport, pathMatchers, rootGitEndings, rootGitPattern, routeHandler, routeImports };
62
+ export { dropInPrefixes, gitRoutes, rootGitEndings, rootGitPattern };
@@ -1,42 +1,14 @@
1
1
  import { fitted, lines } from "./files.mjs";
2
2
  import { storePackages } from "./metadata.mjs";
3
3
  // src/init/stores.ts
4
- /** The records store's Layer, woken by the wake's Layer the platform's file declares as `wake`. */
5
- const recordsPart = (records) => records === "postgres" ? {
4
+ /** Postgres's Layer for the Functions, which run no job: the Daemon builds its own. */
5
+ const postgresPart = {
6
6
  external: ["import pg from 'pg';"],
7
7
  infra: "import * as Postgres from '@ref0/infra/postgres';",
8
- code: lines("const store = Postgres.layer({", " // A call waits at most 10 s for one of the pool's connections, then fails, never hangs.", " pool: new pg.Pool({ connectionString: need('DATABASE_URL'), connectionTimeoutMillis: 10_000 }),", " wake,", "});"),
8
+ code: lines("/** The Functions' store: its commits save jobs and wake the Daemon, and it runs none itself. */", "const serving = Postgres.layerServing({", " // A call waits at most 10 s for one of the pool's connections, then fails, never hangs.", " pool: new pg.Pool({ connectionString: need('DATABASE_URL'), connectionTimeoutMillis: 10_000 }),", "});"),
9
9
  variables: ["DATABASE_URL"],
10
10
  dependencies: [["pg", storePackages.pg]],
11
11
  devDependencies: [["@types/pg", storePackages["@types/pg"]]]
12
- } : {
13
- external: ["import { createClient } from '@libsql/client';"],
14
- infra: "import * as Turso from '@ref0/infra/turso';",
15
- code: lines("// A database per repo in one Turso group, made at its first write over Turso's Platform API.", "const group = need('TURSO_GROUP');", "", "const databases = Turso.platform({", " organization: need('TURSO_ORGANIZATION'),", " group,", " region: need('TURSO_REGION'),", " apiToken: need('TURSO_API_TOKEN'),", "});", "", "const store = Turso.layer({", " group,", " databases,", " groupToken: need('TURSO_GROUP_TOKEN'),", " createClient,", " wake,", "});"),
16
- variables: [
17
- "TURSO_ORGANIZATION",
18
- "TURSO_GROUP",
19
- "TURSO_REGION",
20
- "TURSO_API_TOKEN",
21
- "TURSO_GROUP_TOKEN"
22
- ],
23
- dependencies: [["@libsql/client", storePackages["@libsql/client"]]],
24
- devDependencies: []
25
- };
26
- /** An S3 bucket, whose keys `S3.layer()` reads from the environment itself. */
27
- const s3Part = {
28
- external: [],
29
- infra: "import * as S3 from '@ref0/infra/s3';",
30
- code: lines("// S3.layer() reads AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY itself.", "const bucket = S3.layer({", " endpoint: need('S3_ENDPOINT'),", " region: need('S3_REGION'),", " bucket: need('S3_BUCKET'),", "});"),
31
- variables: [
32
- "S3_ENDPOINT",
33
- "S3_REGION",
34
- "S3_BUCKET",
35
- "AWS_ACCESS_KEY_ID",
36
- "AWS_SECRET_ACCESS_KEY"
37
- ],
38
- dependencies: [],
39
- devDependencies: []
40
12
  };
41
13
  /**
42
14
  * The server module's `need()`, which every part reads its variables through: an empty value, as
@@ -46,12 +18,11 @@ const s3Part = {
46
18
  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
19
  /**
48
20
  * 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,
50
- * and what Turso's Platform API token must be allowed, since a deleted repo's purge deletes its database.
21
+ * since `pg` then checks the server's certificate and name, which `require` will stop doing in `pg` 9.
51
22
  */
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";
23
+ const noteOf = (name) => name === "DATABASE_URL" && "# Postgres's URL. Over a network, end it ?sslmode=verify-full, so pg checks the server's certificate";
53
24
  /** `.env.example`: `header`'s comment lines, then each of `variables` with an empty value. */
54
25
  const envExample = (header, variables) => lines(...header.map((line) => `# ${line}`), ...variables.flatMap((name) => [noteOf(name), `${name}=`]), "");
55
26
  /** The variables `parts` read, in order, which the person sets: an Output's `needs`. */
56
27
  const needsOf = (parts) => parts.flatMap((part) => part.variables);
57
- export { envExample, needHelper, needsOf, recordsPart, s3Part };
28
+ export { envExample, needHelper, needsOf, postgresPart };
@@ -24,21 +24,6 @@ const appGitSlots = [
24
24
  "adapter",
25
25
  "objects"
26
26
  ];
27
- /** The slots of the app's `src/git.ts` on Node: Node's head and parts, the store's and the queue's. */
28
- const appGitNodeSlots = [
29
- "head",
30
- "queueMerge",
31
- "releases",
32
- "lfs",
33
- "uploads",
34
- "queue",
35
- "adapter",
36
- "objects",
37
- "xdiff",
38
- "database",
39
- "ipHeader",
40
- "classes"
41
- ];
42
27
  /** The slots of the app's `src/env.ts`, and the example Worker's. */
43
28
  const appEnvSlots = [
44
29
  "types",
@@ -89,44 +74,24 @@ const workerWranglerSlots = [
89
74
  "vars"
90
75
  ];
91
76
  const Names = /* @__PURE__ */ Schema.Array(Schema.String);
92
- /** What the app needs on each platform, as `apps/github/src/platform.ts` says: `doctor` checks it. */
93
- const Platforms = /* @__PURE__ */ Schema.Struct({
94
- cloudflare: Schema.Struct({
95
- secrets: Names,
96
- bound: Names,
97
- optional: Names,
98
- signing: Names,
99
- dev: Names,
100
- secretFile: Schema.String,
101
- database: Schema.Struct({
102
- binding: Schema.String,
103
- migrations: Schema.String
104
- })
105
- }),
106
- node: Schema.Struct({
107
- required: Names,
108
- secrets: Names,
109
- optional: Names,
110
- dev: Names,
111
- secretFile: Schema.String,
112
- database: Schema.Struct({
113
- file: Schema.String,
114
- migrations: Schema.String
115
- }),
116
- entry: Schema.String,
117
- jobs: Schema.String
77
+ /** What the app needs on Cloudflare, as `apps/github/src/platform.ts` says: `doctor` checks it. */
78
+ const Platforms = /* @__PURE__ */ Schema.Struct({ cloudflare: Schema.Struct({
79
+ secrets: Names,
80
+ bound: Names,
81
+ optional: Names,
82
+ signing: Names,
83
+ dev: Names,
84
+ secretFile: Schema.String,
85
+ database: Schema.Struct({
86
+ binding: Schema.String,
87
+ migrations: Schema.String
118
88
  })
119
- });
89
+ }) });
120
90
  const Templates = Schema.Struct({
121
91
  appGit: templateOf(appGitSlots),
122
- appGitNode: templateOf(appGitNodeSlots),
123
92
  appEnv: templateOf(appEnvSlots),
124
93
  appWrangler: templateOf(appWranglerSlots),
125
94
  appConfigs: Schema.Record(Schema.String, Schema.String),
126
- nodeServer: Schema.String,
127
- nodeConfigs: Schema.Record(Schema.String, Schema.String),
128
- nodeServerConfig: Schema.String,
129
- nodeVite: Schema.String,
130
95
  workerGit: templateOf(workerGitSlots),
131
96
  workerEntry: templateOf(workerEntrySlots),
132
97
  workerEnv: templateOf(workerEnvSlots),
@@ -136,7 +101,7 @@ const Templates = Schema.Struct({
136
101
  });
137
102
  /** The templates, as the pack wrote them. */
138
103
  const templates = Schema.decodeUnknownSync(Templates)(templates_default);
139
- /** What the app needs on each platform, which `doctor` checks a setup for. */
104
+ /** What the app needs on Cloudflare, which `doctor` checks a setup for. */
140
105
  const { platforms } = templates;
141
106
  /**
142
107
  * `template`'s text, each slot `slots` gives a text filled with it, and each it leaves `undefined`
@@ -145,4 +110,4 @@ const { platforms } = templates;
145
110
  const filled = (template, slots) => template.map((piece) => Predicate.isString(piece) ? piece : slots[piece.slot] ?? piece.text).join("");
146
111
  /** What a slot holds for a choice the source didn't make: `text`, else `undefined`, the source's own. */
147
112
  const unless = (made, text) => made ? void 0 : text;
148
- export { appEnvSlots, appGitNodeSlots, appGitSlots, appWranglerSlots, filled, platforms, templates, unless, workerEntrySlots, workerEnvSlots, workerGitSlots, workerWranglerSlots };
113
+ export { appEnvSlots, appGitSlots, appWranglerSlots, filled, platforms, templates, unless, workerEntrySlots, workerEnvSlots, workerGitSlots, workerWranglerSlots };