ref0-git 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { ignoring, lines, withCli, withCreatedTypes, withDependencies, withLines } from "./files.mjs";
2
- import { adminLines, gitDependencies, gitImports, gitPackages, handlerLines, header, mergeLines, serveExport, serverLines } from "./git-module.mjs";
2
+ import { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, mergeLines, policyLines, runtimeLines } from "./git-module.mjs";
3
3
  import { manifestText, parseJsonc, stringAt, withEntries } from "./jsonc.mjs";
4
4
  import { astroRouteFiles, astroSteps } from "./astro.mjs";
5
5
  import { mountManual } from "./mounts.mjs";
@@ -53,58 +53,47 @@ const storeLines = (choices) => {
53
53
  };
54
54
  /** The bucket, as chosen, after a blank line: none for loose objects. */
55
55
  const bucketLines = (choices) => choices.bucket === "s3" ? `\n${s3Part.code}` : choices.bucket === "disk" && "\nconst bucket = Disk.layer('.data/packs');";
56
- /** Git's comment in the server module, for what runs its jobs. */
56
+ /** The runtime's comment in the server module, on what runs its jobs. */
57
57
  const jobsSays = {
58
- main: "/** Git, whose jobs `src/main.ts` runs in this process. */",
59
- server: "/** Git, whose jobs your server runs in its process. */",
60
- hook: "/** Git, whose jobs the framework's startup hook runs in each server process. */",
61
- "on-import": "/** Git, whose jobs this module starts on its first import. */"
58
+ main: "`src/main.ts` runs its jobs in this process.",
59
+ server: "Your server runs its jobs in its process.",
60
+ hook: "The framework's startup hook runs its jobs in each server process.",
61
+ "on-import": "This module starts its jobs on its first import."
62
62
  };
63
+ /** A push's pack upload, to a bucket that signs parts: S3's. */
64
+ const uploads = lines(" // A push past 64 MiB may upload its pack, once the bucket signs parts.", " Git.layerUploads({ above: 64 * 1024 * 1024 }),");
63
65
  /**
64
66
  * A framework's `.env`, loaded before any `need()`: a Vite dev server gives `process.env` none of
65
67
  * it, and adapter-node's server loads none. A variable the environment sets stays as it is.
66
68
  */
67
69
  const loadEnvLines = lines("// `.env` from the folder the server runs in, `process.cwd()`, as `node --env-file` reads it: a", "// host that runs it from another folder sets the environment itself. A variable already set", "// stays as it is.", "if (existsSync('.env')) process.loadEnvFile('.env');", "");
68
70
  /** The jobs' start on the module's first import, once a process: a dev reload imports it again. */
69
- const startedOnImport = lines("// Started once a process, on this module's first import, after the drop-in joins Git: the", "// runner starts Git's build, which refuses a join. A dev reload imports the module again.", "// SAFETY: only this module sets `gitJobs` on the global, to the stop `toJobRunner` returns.", "const started = globalThis as { gitJobs?: () => Promise<void> };", "", "started.gitJobs ??= Node.toJobRunner(git.runtime);", "");
71
+ const startedOnImport = lines("// Started once a process, on this module's first import. A dev reload imports the module again.", "// SAFETY: only this module sets `gitJobs` on the global, to the stop `toJobRunner` returns.", "const started = globalThis as { gitJobs?: () => Promise<void> };", "", "started.gitJobs ??= Node.toJobRunner(runtime);", "");
70
72
  /**
71
- * The server module, `src/git.ts` or a framework's: the store, the bucket and the queue, then
72
- * Git, its REST and the drop-in, and, but for `src/main.ts`'s, the `serve` its routes call.
73
+ * The server module, `src/git.ts` or a framework's: the store, the bucket and the queue, then Git's
74
+ * features and the drop-in's, and the runtime that its entry, routes or mount take.
73
75
  */
74
76
  const nodeModule = (choices, jobs) => {
75
77
  const packs = choices.objects === "packs";
76
78
  const framework = jobs === "hook" || jobs === "on-import";
77
- return lines(header(choices, "Node"), firstImports(choices, framework), gitImports(choices), infraImports(choices, jobs === "on-import"), "import { xdiff } from '@ref0/xdiff-wasm/node';", "", framework && loadEnvLines, needHelper(".env"), "", adminLines, storeLines(choices), bucketLines(choices), "", mergeLines(choices), jobsSays[jobs], serverLines(choices, {
78
- adapter: ` adapter: ${packs ? "[store, bucket]" : "store"},`,
79
- xdiff: " xdiff: await xdiff(),",
80
- uploads: choices.bucket === "s3",
81
- token: "need('ADMIN_TOKEN')"
82
- }), handlerLines(choices), jobs === "on-import" && startedOnImport, jobs !== "main" && serveExport(choices));
83
- };
84
- /** What the process serves, as `toNodeHandler` takes it. */
85
- const handled = {
86
- github: {
87
- names: "git, github, rest",
88
- handler: "{\n fetch: async (request) => (await github.route(request)) ?? rest.fetch(request),\n}"
89
- },
90
- api: {
91
- names: "git, rest",
92
- handler: "rest"
93
- },
94
- git: {
95
- names: "git",
96
- handler: "git"
97
- }
79
+ return lines(header(choices, "Node"), firstImports(choices, framework), gitImports(choices), infraImports(choices, jobs === "on-import"), "import { xdiff } from '@ref0/xdiff-wasm/node';", effectImports(choices), "", framework && loadEnvLines, needHelper(".env"), "", adminLines, storeLines(choices), bucketLines(choices), "", mergeLines(choices), policyLines, featuresLines(choices, {
80
+ merges: "{ xdiff: await xdiff() }",
81
+ uploads: choices.bucket === "s3" && uploads
82
+ }), runtimeLines(choices, {
83
+ token: "need('ADMIN_TOKEN')",
84
+ adapter: packs ? "Layer.merge(store, bucket)" : "store",
85
+ jobs: jobsSays[jobs]
86
+ }), jobs === "on-import" && startedOnImport);
98
87
  };
99
88
  /** A stop waits this long for the responses still open, such as one a reader stopped reading. */
100
89
  const stopGrace = 1e4;
101
90
  /** The lines in `src/main.ts` that start the jobs and serve Git. */
102
- const serveLines = (choices) => lines("const stop = Node.toJobRunner(git.runtime);", "", `const handler = toNodeHandler(${handled[choices.serve].handler});`);
91
+ const serveLines = lines("const stop = Node.toJobRunner(runtime);", "", "const handler = toNodeHandler(runtime);");
103
92
  /** Where `src/main.ts` serves Git when `PORT` is unset. */
104
93
  const mainOrigin = "http://localhost:8080";
105
94
  const mainPort = new URL(mainOrigin).port;
106
95
  /** `src/main.ts`: Git on `PORT`, its jobs in this process, stopped on `SIGTERM`. */
107
- const mainModule = (choices) => lines(`// Serves Git on PORT, ${mainPort} when unset, and runs its jobs in this process. Written by`, "// `ref0-git init`, and yours to change.", "import { createServer } from 'node:http';", "", "import { toNodeHandler } from '@ref0/git/node';", "import * as Node from '@ref0/infra/node';", "", `import { ${handled[choices.serve].names} } from './git.ts';`, "", serveLines(choices), "", "const server = createServer(handler);", "", "// Node cuts a request off at 300 s, which a large push over a slow link outlasts: an hour.", "server.requestTimeout = 60 * 60 * 1000;", "", `server.listen(Number(process.env.PORT ?? '${mainPort}'));`, "", "process.on('SIGTERM', () => {", " server.close();", " void stop();", "", ` // A response still open after ${stopGrace / 1e3} s, such as to a reader that stopped reading, is cut off.`, ` setTimeout(() => server.closeAllConnections(), ${stopGrace / 1e3} * 1000).unref();`, "});", "");
96
+ const mainModule = () => lines(`// Serves Git on PORT, ${mainPort} when unset, and runs its jobs in this process. Written by`, "// `ref0-git init`, and yours to change.", "import { createServer } from 'node:http';", "", "import { toNodeHandler } from '@ref0/git/node';", "import * as Node from '@ref0/infra/node';", "", "import { runtime } from './git.ts';", "", serveLines, "", "const server = createServer(handler);", "", "// Node cuts a request off at 300 s, which a large push over a slow link outlasts: an hour.", "server.requestTimeout = 60 * 60 * 1000;", "", `server.listen(Number(process.env.PORT ?? '${mainPort}'));`, "", "process.on('SIGTERM', () => {", " server.close();", " void stop();", "", ` // A response still open after ${stopGrace / 1e3} s, such as to a reader that stopped reading, is cut off.`, ` setTimeout(() => server.closeAllConnections(), ${stopGrace / 1e3} * 1000).unref();`, "});", "");
108
97
  /** The packages a Node setup runs with, beside Git's, and the tools it type-checks with. */
109
98
  const dependenciesOf = (choices, vendor) => {
110
99
  const parts = partsOf(choices);
@@ -167,10 +156,10 @@ const instrumentationOf = (framework) => `${framework.appDir === "src/app" ? "sr
167
156
  const registerLines = [
168
157
  "export async function register() {",
169
158
  " if (process.env.NEXT_RUNTIME === 'nodejs') {",
170
- " const { git } = await import('./lib/git');",
159
+ " const { runtime } = await import('./lib/git');",
171
160
  " const Node = await import('@ref0/infra/node');",
172
161
  "",
173
- " Node.toJobRunner(git.runtime);",
162
+ " Node.toJobRunner(runtime);",
174
163
  " }",
175
164
  "}"
176
165
  ];
@@ -425,7 +414,7 @@ const serverNodeOutput = (choices, project, secret, vendor) => {
425
414
  ...own ? [{
426
415
  path: "src/main.ts",
427
416
  kind: "whole",
428
- text: mainModule(choices)
417
+ text: mainModule()
429
418
  }] : [],
430
419
  ...localFiles(choices, secret)
431
420
  ],
@@ -1,5 +1,5 @@
1
1
  import { lines } from "./files.mjs";
2
- import { gitRoutes, pathMatchers } from "./routes.mjs";
2
+ import { pathMatchers, routeImports } from "./routes.mjs";
3
3
  // src/init/nuxt.ts
4
4
  /**
5
5
  * What `init` writes in a Nuxt project on Node, under Nitro's Node preset: one server middleware
@@ -21,10 +21,10 @@ const nuxtJobsPlugin = "server/plugins/git-jobs.ts";
21
21
  /** The plugin's lines, which a step in the person's own file at that path names too. */
22
22
  const pluginLines = (framework) => [
23
23
  "export default defineNitroPlugin(async (nitroApp) => {",
24
- ` const { git } = await import('${importOf(nuxtJobsPlugin, framework.serverModule)}');`,
24
+ ` const { runtime } = await import('${importOf(nuxtJobsPlugin, framework.serverModule)}');`,
25
25
  " const Node = await import('@ref0/infra/node');",
26
26
  "",
27
- " const stop = Node.toJobRunner(git.runtime);",
27
+ " const stop = Node.toJobRunner(runtime);",
28
28
  " nitroApp.hooks.hook('close', () => void stop());",
29
29
  "});"
30
30
  ];
@@ -37,10 +37,9 @@ const nuxtGitMiddleware = "server/middleware/git.ts";
37
37
  * segments resolved, never the raw path Nitro routes by.
38
38
  */
39
39
  const middlewareLines = (choices, framework) => {
40
- const calls = gitRoutes(choices)[0]?.calls ?? "serve";
41
40
  const matcher = pathMatchers[choices.serve];
42
41
  return [
43
- `import { ${matcher.name} } from '${matcher.from}';`,
42
+ ...routeImports(choices),
44
43
  "",
45
44
  "export default defineEventHandler(async (event) => {",
46
45
  " // The URL Git is handed, dot segments resolved, under the Host's origin: an absolute target",
@@ -55,10 +54,10 @@ const middlewareLines = (choices, framework) => {
55
54
  "",
56
55
  " // Loaded on Git's first request. toWebRequest reads a body without backpressure, so a fast",
57
56
  " // push waits in memory while Git reads it.",
58
- ` const { ${calls} } = await import('${importOf(nuxtGitMiddleware, framework.serverModule)}');`,
57
+ ` const { runtime } = await import('${importOf(nuxtGitMiddleware, framework.serverModule)}');`,
59
58
  " url.pathname = path;",
60
59
  "",
61
- ` return ${calls}.fetch(new Request(url, toWebRequest(event)));`,
60
+ " return Git.toFetch(runtime)(new Request(url, toWebRequest(event)));",
62
61
  "});"
63
62
  ];
64
63
  };
@@ -1,5 +1,5 @@
1
1
  import { lines } from "./files.mjs";
2
- import { fileRoutes, matcherImport, routeHandler } from "./routes.mjs";
2
+ import { fileRoutes, routeHandler, routeImports } from "./routes.mjs";
3
3
  // src/init/react-router.ts
4
4
  /**
5
5
  * What `init` writes in a React Router project on Node: a resource route for each route, whose
@@ -35,7 +35,7 @@ const resourceRoute = (choices, route, module) => {
35
35
  return {
36
36
  path,
37
37
  kind: "whole",
38
- text: lines(`// ${route.says} Written by \`ref0-git init\`.`, `import type { Route } from './+types/${file.replace(/\.ts$/, "")}';`, "", matcherImport(choices), "", "// Loaded on the first request, so `react-router build` opens no database and needs no secret.", ...routeHandler(choices, path, module), "", "export const loader = ({ request }: Route.LoaderArgs) => git(request);", "", "export const action = ({ request }: Route.ActionArgs) => git(request);", "")
38
+ text: lines(`// ${route.says} Written by \`ref0-git init\`.`, `import type { Route } from './+types/${file.replace(/\.ts$/, "")}';`, "", ...routeImports(choices), "", "// Loaded on the first request, so `react-router build` opens no database and needs no secret.", ...routeHandler(choices, path, module), "", "export const loader = ({ request }: Route.LoaderArgs) => git(request);", "", "export const action = ({ request }: Route.ActionArgs) => git(request);", "")
39
39
  };
40
40
  };
41
41
  /** React Router's resource routes for `choices`, over `framework`'s server module. */
@@ -8,20 +8,11 @@ const all = [
8
8
  "POST",
9
9
  "PUT"
10
10
  ];
11
- /** The server module's export Git's route calls, and the words for what it serves, by `--serve`. */
11
+ /** The words for what Git's route serves, by `--serve`. */
12
12
  const served = {
13
- github: {
14
- calls: "serve",
15
- says: "the drop-in's links, REST, then Git's protocol and sign-in"
16
- },
17
- api: {
18
- calls: "rest",
19
- says: "REST, then Git's protocol and sign-in"
20
- },
21
- git: {
22
- calls: "git",
23
- says: "Git's protocol and sign-in"
24
- }
13
+ github: "the drop-in's links, REST, then Git's protocol and sign-in",
14
+ api: "REST, then Git's protocol and sign-in",
15
+ git: "Git's protocol and sign-in"
25
16
  };
26
17
  /** Whether `route` is a root `.git` URL, `gh repo clone`'s, rather than one of the drop-in's prefixes. */
27
18
  const rootGit = (route) => route.path.startsWith(":owner/:repo.git/");
@@ -57,8 +48,7 @@ const gitRoutes = (choices) => {
57
48
  const git = {
58
49
  at: base,
59
50
  tail: "rest",
60
- says: `Git's URLs under \`/${base}\`: ${served[choices.serve].says}.`,
61
- calls: served[choices.serve].calls,
51
+ says: `Git's URLs under \`/${base}\`: ${served[choices.serve]}.`,
62
52
  methods: all
63
53
  };
64
54
  if (choices.serve !== "github") return [git];
@@ -66,7 +56,6 @@ const gitRoutes = (choices) => {
66
56
  at: route.path,
67
57
  tail: route.tail,
68
58
  says: dropInSays.get(route.path) ?? "The drop-in's own URL, as GitHub serves it.",
69
- calls: "github",
70
59
  methods: route.methods
71
60
  }))];
72
61
  };
@@ -95,8 +84,6 @@ const matcherBase = (choices) => choices.basePath.replace(/\/$/, "");
95
84
  * drop-in, answers it at, or `undefined` for the app's.
96
85
  */
97
86
  const matcherCall = (choices) => `${pathMatchers[choices.serve].name}(url, '${matcherBase(choices)}')`;
98
- /** The server module's export a mount beside an app hands Git's URLs to, by `--serve`. */
99
- const servedBy = (choices) => served[choices.serve].calls;
100
87
  /**
101
88
  * Git's routes in a framework that routes by its files, Astro or React Router, which have no
102
89
  * rewrite of Next.js's or reroute of SvelteKit's: with `--serve github`, `gh`'s root Git URLs too,
@@ -110,7 +97,6 @@ const fileRoutes = (choices) => {
110
97
  at: ending.path,
111
98
  tail: ending.tail,
112
99
  says: `gh's Git URLs at the root, which Git answers as its own under \`${choices.basePath}\`.`,
113
- calls: "serve",
114
100
  methods: ending.methods
115
101
  }))];
116
102
  };
@@ -138,11 +124,16 @@ const routeHandler = (choices, file, module) => [
138
124
  " if (path === undefined) return new Response(null, { status: 404 });",
139
125
  "",
140
126
  " url.pathname = path;",
141
- ` const { ${servedBy(choices)} } = await import('${importOf(file, module)}');`,
127
+ ` const { runtime } = await import('${importOf(file, module)}');`,
142
128
  "",
143
- ` return ${servedBy(choices)}.fetch(new Request(url, request));`,
129
+ " return Git.toFetch(runtime)(new Request(url, request));",
144
130
  "};"
145
131
  ];
146
132
  /** The matcher's import, for a route file or a mount beside an app. */
147
133
  const matcherImport = (choices) => `import { ${pathMatchers[choices.serve].name} } from '${pathMatchers[choices.serve].from}';`;
148
- export { dropInPrefixes, fileRoutes, gitRoutes, importOf, matcherCall, matcherImport, pathMatchers, rootGitEndings, rootGitPattern, routeHandler, servedBy };
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 };
@@ -26,7 +26,7 @@ const svelteRouteFiles = (choices, framework) => gitRoutes(choices).map((route)
26
26
  return {
27
27
  path,
28
28
  kind: "whole",
29
- text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import type { RequestHandler } from './$types';", "", "// Loaded on the first request, so `vite build`, which loads each route to read its options, opens", "// no database and needs no secret.", "const git: RequestHandler = async ({ request }) => {", ` const { ${route.calls} } = await import('${importOf(path, framework.serverModule)}');`, "", ` return ${route.calls}.fetch(request);`, "};", "", `export { ${route.methods.map((method) => `git as ${method}`).join(", ")} };`, "")
29
+ text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import { Git } from '@ref0/git';", "", "import type { RequestHandler } from './$types';", "", "// Loaded on the first request, so `vite build`, which loads each route to read its options, opens", "// no database and needs no secret.", "const git: RequestHandler = async ({ request }) => {", ` const { runtime } = await import('${importOf(path, framework.serverModule)}');`, "", " return Git.toFetch(runtime)(request);", "};", "", `export { ${route.methods.map((method) => `git as ${method}`).join(", ")} };`, "")
30
30
  };
31
31
  });
32
32
  /** What the `init` hook names: Kit's type and `building`, which keeps it out of a build. */
@@ -36,10 +36,10 @@ const initLines = (framework) => [
36
36
  "export const init: ServerInit = async () => {",
37
37
  " if (building) return;",
38
38
  "",
39
- ` const { git } = await import('${importOf("src/hooks.server.ts", framework.serverModule)}');`,
39
+ ` const { runtime } = await import('${importOf("src/hooks.server.ts", framework.serverModule)}');`,
40
40
  " const Node = await import('@ref0/infra/node');",
41
41
  "",
42
- " Node.toJobRunner(git.runtime);",
42
+ " Node.toJobRunner(runtime);",
43
43
  "};"
44
44
  ];
45
45
  /** `src/hooks.server.ts`, where the project has none. */
@@ -49,6 +49,7 @@ const appWranglerSlots = [
49
49
  "about",
50
50
  "signing",
51
51
  "name",
52
+ "limits",
52
53
  "vars",
53
54
  "bucket",
54
55
  "database"
@@ -58,25 +59,16 @@ const workerGitSlots = [
58
59
  "header",
59
60
  "gitImports",
60
61
  "infraImport",
62
+ "effectImports",
61
63
  "envFile",
62
64
  "safety",
63
65
  "bucket",
64
66
  "merge",
65
- "adapter",
66
- "objects",
67
- "lfs",
68
- "uploads",
69
- "basePath",
70
- "queue",
71
- "github",
72
- "rest"
67
+ "features",
68
+ "runtime"
73
69
  ];
74
70
  /** The slots of the example Worker's `src/worker.ts`: what it serves. */
75
- const workerEntrySlots = [
76
- "gate",
77
- "names",
78
- "exports"
79
- ];
71
+ const workerEntrySlots = ["gate", "exports"];
80
72
  /** The slots of the example Worker's `src/env.ts`. */
81
73
  const workerEnvSlots = [
82
74
  "types",
@@ -88,6 +80,7 @@ const workerWranglerSlots = [
88
80
  "about",
89
81
  "signing",
90
82
  "name",
83
+ "limits",
91
84
  "bucket",
92
85
  "vars"
93
86
  ];
@@ -51,7 +51,7 @@ var templates_default = {
51
51
  " // `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).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
52
52
  {
53
53
  "slot": "lfs",
54
- "text": " // Git LFS, its objects in the bucket beside the packs.\n Lfs.layer(),\n"
54
+ "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"
55
55
  },
56
56
  {
57
57
  "slot": "uploads",
@@ -90,7 +90,7 @@ var templates_default = {
90
90
  " // `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).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
91
91
  {
92
92
  "slot": "lfs",
93
- "text": " // Git LFS, its objects in the bucket beside the packs.\n Lfs.layer(),\n"
93
+ "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"
94
94
  },
95
95
  {
96
96
  "slot": "uploads",
@@ -154,7 +154,12 @@ var templates_default = {
154
154
  "slot": "name",
155
155
  "text": " \"name\": \"git-app\","
156
156
  },
157
- "\n \"main\": \"src/server.ts\",\n \"limits\": { \"cpu_ms\": 300000 },\n \"compatibility_date\": \"2026-11-01\",\n",
157
+ "\n \"main\": \"src/server.ts\",\n",
158
+ {
159
+ "slot": "limits",
160
+ "text": " \"limits\": { \"cpu_ms\": 300000 },"
161
+ },
162
+ "\n \"compatibility_date\": \"2026-11-01\",\n",
158
163
  {
159
164
  "slot": "vars",
160
165
  "text": " \"vars\": { \"APP_ORIGIN\": \"http://localhost:5173\", \"PACKS_BUCKET\": \"git-app-packs\" },"
@@ -186,13 +191,18 @@ var templates_default = {
186
191
  },
187
192
  {
188
193
  "slot": "gitImports",
189
- "text": "import { accept, createGitServer, lfs, mergeQueue, packs, reject } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport { bearer, tokens } from '@ref0/git/auth';\nimport { createRestHandler } from '@ref0/git/rest';\n"
194
+ "text": "import { Auth, Git, Lfs, MergeQueue, Merges, Objects, Policy, Rest, Tokens } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\n"
190
195
  },
191
196
  {
192
197
  "slot": "infraImport",
193
198
  "text": "import {\n layer,\n layerR2,\n layerR2Signed,\n toJobObject,\n toRecordsObject,\n} from '@ref0/infra/cloudflare';"
194
199
  },
195
- "\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\n\nimport type { Env } from ",
200
+ "\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\n",
201
+ {
202
+ "slot": "effectImports",
203
+ "text": "import * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Redacted from 'effect/Redacted';\n"
204
+ },
205
+ "\nimport type { Env } from ",
196
206
  {
197
207
  "slot": "envFile",
198
208
  "text": "'./env.ts'"
@@ -205,65 +215,33 @@ var templates_default = {
205
215
  ", and `ADMIN_TOKEN` is its secret.\nconst env = bindings as Env;\n\n/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */\nconst admin = { id: '_admin' };\n\n",
206
216
  {
207
217
  "slot": "bucket",
208
- "text": "const {\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, a push's pack uploads to the bucket in parts, past Workers' 100 MB body.\nconst bucket =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? layerR2(env.PACKS)\n : layerR2Signed(env.PACKS, {\n accountId,\n bucket: env.PACKS_BUCKET,\n accessKeyId,\n secretAccessKey,\n });\n\n"
218
+ "text": "const {\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/** The records and job objects, and the packs' bucket. */\nconst adapter = Layer.merge(\n layer({ records: env.RECORDS, jobs: env.JOBS }),\n signed ?? layerR2(env.PACKS),\n);\n\n"
209
219
  },
210
220
  {
211
221
  "slot": "merge",
212
222
  "text": "/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */\nconst merge = ({ entry }: MergeInput): MergePlan => ({\n method: 'merge',\n message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,\n author: {\n name: entry.actor.id,\n email: `${entry.actor.id}@users.noreply.git`,\n at: Date.now(),\n offset: 0,\n },\n});\n\n"
213
223
  },
214
- "export const git = createGitServer({\n",
215
- {
216
- "slot": "adapter",
217
- "text": " adapter: [layer({ records: env.RECORDS, jobs: env.JOBS }), bucket],"
218
- },
219
- "\n",
220
- {
221
- "slot": "objects",
222
- "text": " objects: packs(),"
223
- },
224
- "\n xdiff,\n tokens: tokens(),\n",
225
- {
226
- "slot": "lfs",
227
- "text": " // Git LFS, its objects in the bucket beside the packs.\n lfs: lfs(),\n"
228
- },
229
- {
230
- "slot": "uploads",
231
- "text": " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },\n"
232
- },
224
+ "/**\n * Who may do what: a visitor signs in first, and the admin makes repos and tokens but never\n * pushes.\n */\nconst policy = Policy.make(({ caller: { actor }, operation }) => {\n if (actor.anonymous === true) return Policy.reject({ message: 'Sign in first' });\n\n if (actor.id === admin.id && operation.kind === 'push') {\n return Policy.reject({\n message: \"The admin token can't push\",\n hint: 'Make a write token for yourself: npx ref0-git tokens create --help',\n });\n }\n\n return Policy.accept();\n});\n\n",
233
225
  {
234
- "slot": "basePath",
235
- "text": ""
236
- },
237
- " auth: bearer({ token: env.ADMIN_TOKEN, actor: admin }),\n authorize: ({ actor, operation }) => {\n if (actor.anonymous === true) return reject({ message: 'Sign in first' });\n\n if (actor.id === admin.id && operation.kind === 'push') {\n return reject({\n message: \"The admin token can't push\",\n hint: 'Make a write token for yourself: npx ref0-git tokens create --help',\n });\n }\n\n return accept();\n },\n",
238
- {
239
- "slot": "queue",
240
- "text": " queue: mergeQueue({ target: 'refs/heads/main', keys: 'reusable', merge }),\n"
226
+ "slot": "features",
227
+ "text": "/** Git's features, each a line: delete one to turn it off. */\nconst features = Layer.mergeAll(\n // Git's REST, beside Git's protocol and sign-in.\n Rest.layer(),\n // 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 // A push past 64 MiB may upload its pack, once the bucket signs parts.\n signed === undefined\n ? Layer.empty\n : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed),\n MergeQueue.layer({ target: 'refs/heads/main', keys: 'reusable', merge }),\n).pipe(Layer.provideMerge(Tokens.layer()), Layer.provideMerge(Merges.layer({ xdiff })));\n\n"
241
228
  },
242
- "});\n\n",
243
229
  {
244
- "slot": "github",
245
- "text": ""
230
+ "slot": "runtime",
231
+ "text": "/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */\nconst auth = Auth.bearer({ token: Redacted.make(env.ADMIN_TOKEN), actor: admin });\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 admin signing in with `auth`.\n */\nexport const runtime = ManagedRuntime.make(\n Git.layer({}, features).pipe(\n Layer.provide(Policy.layer(policy)),\n Layer.provide(Auth.layer(auth)),\n Layer.provide(Objects.layer()),\n Layer.provideMerge(adapter),\n ),\n);\n\n"
246
232
  },
247
- {
248
- "slot": "rest",
249
- "text": "/** Git's REST, whose `route` and `fetch` serve Git's protocol and sign-in too. */\nexport const rest = createRestHandler(git);\n\n"
250
- },
251
- "/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = toRecordsObject(git.runtime);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = toJobObject(git.runtime);\n"
233
+ "/** 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"
252
234
  ],
253
235
  workerEntry: [
236
+ "import { Git } from '@ref0/git';\n\n",
254
237
  {
255
238
  "slot": "gate",
256
239
  "text": "import { deviceAttemptAnswer, deviceAttemptGate } from './device-attempts/attempts.ts';\n"
257
240
  },
258
- "import type { Env } from './env.ts';\n",
259
- {
260
- "slot": "names",
261
- "text": "import { git, rest } from './git.ts';"
262
- },
263
- "\n\nexport { Jobs, Records } from './git.ts';\n\n",
241
+ "import type { Env } from './env.ts';\nimport { runtime } from './git.ts';\n\nexport { Jobs, Records } from './git.ts';\n\n",
264
242
  {
265
243
  "slot": "exports",
266
- "text": "/** The device page's front door, which spends an attempt of the caller's Cloudflare address. */\nconst gate = deviceAttemptGate({\n answer: (who) => git.runtime.runPromise(deviceAttemptAnswer(who)),\n addressHeader: 'cf-connecting-ip',\n});\n\n/** The front door, then Git's REST and protocol, then a JSON `404`. */\nexport default {\n fetch: async (request) => (await gate(request)) ?? rest.fetch(request),\n} satisfies ExportedHandler<Env>;\n"
244
+ "text": "/** The device page's front door, which spends an attempt of the caller's Cloudflare address. */\nconst gate = deviceAttemptGate({\n answer: (who) => runtime.runPromise(deviceAttemptAnswer(who)),\n addressHeader: 'cf-connecting-ip',\n});\n\n/** Git's routes: its protocol, sign-in and REST, then a JSON `404`. */\nconst git = Git.toFetch(runtime);\n\n/** The front door, then Git's routes. */\nexport default {\n fetch: async (request) => (await gate(request)) ?? git(request),\n} satisfies ExportedHandler<Env>;\n"
267
245
  }
268
246
  ],
269
247
  workerEnv: [
@@ -299,7 +277,12 @@ var templates_default = {
299
277
  "slot": "name",
300
278
  "text": " \"name\": \"git\","
301
279
  },
302
- "\n \"main\": \"src/worker.ts\",\n \"limits\": { \"cpu_ms\": 300000 },\n \"compatibility_date\": \"2026-11-01\",\n \"durable_objects\": {\n \"bindings\": [\n { \"name\": \"RECORDS\", \"class_name\": \"Records\" },\n { \"name\": \"JOBS\", \"class_name\": \"Jobs\" },\n ],\n },\n",
280
+ "\n \"main\": \"src/worker.ts\",\n",
281
+ {
282
+ "slot": "limits",
283
+ "text": " \"limits\": { \"cpu_ms\": 300000 },"
284
+ },
285
+ "\n \"compatibility_date\": \"2026-11-01\",\n \"durable_objects\": {\n \"bindings\": [\n { \"name\": \"RECORDS\", \"class_name\": \"Records\" },\n { \"name\": \"JOBS\", \"class_name\": \"Jobs\" },\n ],\n },\n",
303
286
  {
304
287
  "slot": "bucket",
305
288
  "text": " \"r2_buckets\": [{ \"binding\": \"PACKS\", \"bucket_name\": \"git-packs\" }],\n"
@@ -1,4 +1,4 @@
1
- import { gitDependencies, gitPackages, lfsLines, queueLine, serveExport } from "./git-module.mjs";
1
+ import { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, mergeLines, policyLines, repoHint, runtimeLines } from "./git-module.mjs";
2
2
  import { dropInPrefixes } from "./routes.mjs";
3
3
  import { ignoring, lines, listed, served, withCli, withCreatedTypes, withDependencies, withLines } from "./files.mjs";
4
4
  import { envExample, needHelper, needsOf, recordsPart, s3Part } from "./stores.mjs";
@@ -50,40 +50,36 @@ const variablesOf = (choices) => [
50
50
  ...unsetOf(choices)
51
51
  ];
52
52
  /**
53
- * `src/git.ts` on Vercel: Git, its REST and the drop-in, as chosen, and the job queue. In Next.js,
54
- * the server module, whose jobs a route of its own takes, and which exports `serve` for Git's route.
53
+ * `src/git.ts` on Vercel: Git's features and the drop-in's, as chosen, its runtime, and the job
54
+ * queue's handler, which a route of its own takes, in Next.js too.
55
55
  */
56
56
  const vercelGitModule = (choices, next) => {
57
57
  const jobsRoute = next === void 0 ? routes.jobs : nextJobRoutes(next).jobs;
58
58
  const postgres = choices.records === "postgres";
59
59
  const blob = choices.bucket === "vercel-blob";
60
60
  const { records, bucket } = partsOf(choices);
61
- const github = choices.serve === "github";
62
61
  const queue = choices.queue === "on";
63
- const { maxDuration } = limitsOf(choices);
64
- return lines(`// Git on Vercel's functions, ${served[choices.serve]}${queue ? ", with a merge queue on `main`" : ""}: records and jobs`, `// in ${postgres ? "Postgres" : "Turso"}, packs in ${blob ? "Vercel Blob" : "S3"}, and jobs woken by Vercel Queues. Written by \`ref0-git init\`, and`, "// yours to change: `init` rewrites it only while it reads as written, and `ref0-git doctor`", "// checks it.", choices.serve === "git" && "// Nothing here makes a repo over HTTP: make one from code, as `git.repos.create({ name: 'acme/app' })`.", ...records.external, "", `import { accept, createGitServer, lfs, ${queue ? "mergeQueue, " : ""}packs, reject } from '@ref0/git';`, queue && "import type { MergeInput, MergePlan } from '@ref0/git';", "import { bearer, tokens } from '@ref0/git/auth';", choices.serve !== "git" && "import { createRestHandler } from '@ref0/git/rest';", github && "import { createGitHubHandler } from '@ref0/github';", ...[
62
+ return lines(`// Git on Vercel's functions, ${served[choices.serve]}${queue ? ", with a merge queue on `main`" : ""}: records and jobs`, `// in ${postgres ? "Postgres" : "Turso"}, packs in ${blob ? "Vercel Blob" : "S3"}, and jobs woken by Vercel Queues. Written by \`ref0-git init\`, and`, "// yours to change: `init` rewrites it only while it reads as written, and `ref0-git doctor`", "// checks it.", choices.serve === "git" && repoHint, ...records.external, "", gitImports(choices), ...[
65
63
  records.infra,
66
64
  bucket?.infra,
67
65
  "import * as Vercel from '@ref0/infra/vercel';"
68
- ].filter(Predicate.isString).toSorted(), "import { xdiff } from '@ref0/xdiff-wasm/node';", "", needHelper("the project's Environment Variables"), "", "/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */", "const admin = { id: '_admin' };", "", "// Functions don't run between requests: a commit that saves a job sends a queue message, and the", "// cron in `vercel.json` sweeps for any message that was lost.", `const wake = Vercel.layerQueues({ topic: '${topic}' });`, "", records.code, "", lines(bucket === void 0 ? "const bucket = Vercel.layerBlob();" : bucket.code, ""), queue && lines("/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */", "const merge = ({ entry }: MergeInput): MergePlan => ({", " method: 'merge',", " message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,", " author: {", " name: entry.actor.id,", " email: `${entry.actor.id}@users.noreply.git`,", " at: Date.now(),", " offset: 0,", " },", "});", ""), "export const git = createGitServer({", " adapter: [store, bucket],", " // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first, with", " // Git's own message.", ` maxDuration: '${maxDuration} seconds',`, " objects: packs(),", " xdiff: await xdiff(),", " tokens: tokens(),", lfsLines, ` // Vercel refuses a body over 4.5 MB, so a larger push uploads its pack to ${blob ? "Blob" : "the bucket"}.`, " pushes: { upload: { above: 4 * 1024 * 1024 } },", choices.basePath !== "/" && ` // Git's URLs, Smart HTTP, sign-in and REST, under this path.\n basePath: '${choices.basePath.replace(/\/$/, "")}',`, " auth: bearer({ token: need('ADMIN_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();", " },", queue && queueLine(github), "});", "", `/** The job queue's route: \`${jobsRoute}\` runs what its messages and the cron's calls name. */`, "export const jobs = Vercel.toQueueHandler(git.runtime);", "", 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", choices.serve !== "git" && "/** Git's REST, whose `route` and `fetch` serve Git's protocol and sign-in too. */\nexport const rest = createRestHandler(git);\n", next !== void 0 && serveExport(choices));
66
+ ].filter(Predicate.isString).toSorted(), "import { xdiff } from '@ref0/xdiff-wasm/node';", effectImports(choices), "", needHelper("the project's Environment Variables"), "", adminLines, "// Functions don't run between requests: a commit that saves a job sends a queue message, and the", "// cron in `vercel.json` sweeps for any message that was lost.", `const wake = Vercel.layerQueues({ topic: '${topic}' });`, "", records.code, "", lines(bucket === void 0 ? "const bucket = Vercel.layerBlob();" : bucket.code, ""), mergeLines(choices), policyLines, featuresLines(choices, {
67
+ merges: "{ xdiff: await xdiff() }",
68
+ uploads: lines(` // Vercel refuses a body over 4.5 MB, so a larger push uploads its pack to ${blob ? "Blob" : "the bucket"}.`, " Git.layerUploads({ above: 4 * 1024 * 1024 }),")
69
+ }), runtimeLines(choices, {
70
+ token: "need('ADMIN_TOKEN')",
71
+ adapter: "Layer.merge(store, bucket)",
72
+ maxDuration: limitsOf(choices).maxDuration
73
+ }), `/** The job queue's route: \`${jobsRoute}\` runs what its messages and the cron's calls name. */`, "export const jobs = Vercel.toQueueHandler(runtime);", "");
69
74
  };
70
- /** What `api/git.ts` answers each method with, for what it serves. */
71
- const handlers = {
72
- github: {
73
- names: "github, rest",
74
- fetch: lines("/** The drop-in's URLs, then Git's REST and protocol, then a JSON `404`. */", "const fetch = async (request: Request) => (await github.route(request)) ?? rest.fetch(request);")
75
- },
76
- api: {
77
- names: "rest",
78
- fetch: "/** Git's REST and protocol, then a JSON `404`. */\nconst { fetch } = rest;"
79
- },
80
- git: {
81
- names: "git",
82
- fetch: "/** Git's protocol and sign-in, then a JSON `404`. */\nconst { fetch } = git;"
83
- }
75
+ /** What `api/git.ts` answers, for what it serves. */
76
+ const handlerSays = {
77
+ github: "The drop-in's URLs, then Git's REST and protocol, then a JSON `404`.",
78
+ api: "Git's REST and protocol, then a JSON `404`.",
79
+ git: "Git's protocol and sign-in, then a JSON `404`."
84
80
  };
85
81
  /** `api/git.ts`: every URL but the jobs' routes, by `vercel.json`'s rewrite. */
86
- const gitRoute = (choices) => lines(`import { ${handlers[choices.serve].names} } from '../src/git.ts';`, "", handlers[choices.serve].fetch, "", "// Every URL but the jobs' routes comes here, by `vercel.json`'s rewrite.", "export {", ...[
82
+ const gitRoute = (choices) => lines("import { Git } from '@ref0/git';", "", "import { runtime } from '../src/git.ts';", "", `/** ${handlerSays[choices.serve]} */`, "const fetch = Git.toFetch(runtime);", "", "// Every URL but the jobs' routes comes here, by `vercel.json`'s rewrite.", "export {", ...[
87
83
  "DELETE",
88
84
  "GET",
89
85
  "HEAD",
@@ -5,6 +5,17 @@ import { catalog, frameworkPackages, nodeAppPackages, nodePackages, peerPackages
5
5
  * this release's own, and each other at the catalog's that this release was tested with. They're
6
6
  * `metadata.ts`'s, which `scripts/cli-metadata.ts` writes from the manifests and the catalogs.
7
7
  */
8
+ /** What a dry run, which packs nothing, writes for the hash of bytes it never made. */
9
+ const unpacked = "<hash>";
10
+ /**
11
+ * `pnpm pack`'s tarball name with its bytes' hash in it, `ref0-git-0.6.0-<12 hex>.tgz`, from
12
+ * `sha256`, their SHA-256: npm keeps a tarball installed when its name and version are the same,
13
+ * so two checkouts at one version name theirs apart, and a rerun installs its own (#2134).
14
+ */
15
+ const contentNamed = (file, sha256) => {
16
+ const hash = sha256 === "<hash>" ? unpacked : Array.from(sha256.subarray(0, 6), (byte) => byte.toString(16).padStart(2, "0")).join("");
17
+ return file.replace(/\.tgz$/u, `-${hash}.tgz`);
18
+ };
8
19
  /**
9
20
  * How `package.json` names one of Git's packages, or `ref0-git`: at this release, or from the
10
21
  * tarball `--from-checkout` packed of it, at the checkout's own version.
@@ -16,17 +27,34 @@ const specOf = (name, vendor) => {
16
27
  return `file:${path}`;
17
28
  };
18
29
  /**
19
- * The tarball path `--from-checkout` writes for `name` at any version, as `pnpm pack` names it:
20
- * Git's packages in `vendor/`, and `ref0-git` in `vendor/cli/`, since `@ref0/git`'s has its name.
30
+ * The tarball path `--from-checkout` writes for `name` at any version, as `pnpm pack` names it,
31
+ * with or without `contentNamed`'s hash: Git's packages in `vendor/`, and `ref0-git` in
32
+ * `vendor/cli/`, since `@ref0/git`'s has its name.
21
33
  */
22
34
  const packedPath = (name) => {
23
35
  const file = name.replace("@", "").replace("/", "-").replaceAll(".", "\\.");
24
36
  return new RegExp(`^file:vendor/${name === "ref0-git" ? "cli/" : ""}${file}-v?\\d[^/]*\\.tgz$`, "u");
25
37
  };
26
38
  /**
39
+ * A version npm publishes: semver 2.0.0's own, `MAJOR.MINOR.PATCH` with an optional prerelease and
40
+ * build, no leading `v` or `=` and no space, as `semver.valid` takes one without `loose`.
41
+ */
42
+ const published = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u;
43
+ /**
44
+ * Whether `at`, a path in the project, is a tarball `--from-checkout` can write for `name`: in its
45
+ * own folder, `pnpm pack`'s name at a version npm publishes, then `contentNamed`'s hash or none.
46
+ * Only those are init's to remove on a rerun. `initWrote` is broader, for a spec it moves, so a
47
+ * file of the person's own named like one, `ref0-git-1-backup.tgz`, isn't init's and stays.
48
+ */
49
+ const initPacked = (name, at) => {
50
+ const file = name.replace("@", "").replace("/", "-").replaceAll(".", "\\.");
51
+ const version = published.source.slice(1, -1);
52
+ return new RegExp(`^vendor/${name === "ref0-git" ? "cli/" : ""}${file}-${version}(?:-[0-9a-f]{12})?\\.tgz$`, "u").test(at);
53
+ };
54
+ /**
27
55
  * Whether `init` wrote `spec` for `name`, one of Git's packages or `ref0-git`, from either source:
28
56
  * the release, or the tarball `--from-checkout` names for that package. One it wrote moves to this
29
57
  * run's spec; any other is the person's, a tarball of their own in `vendor/` too, and stays.
30
58
  */
31
- const initWrote = (name, spec) => spec === "0.7.0" || spec !== void 0 && packedPath(name).test(spec);
32
- export { catalog, frameworkPackages, initWrote, nodeAppPackages, nodePackages, peerPackages, release, specOf, storePackages, vercelPackages };
59
+ const initWrote = (name, spec) => spec === "0.9.0" || spec !== void 0 && packedPath(name).test(spec);
60
+ export { catalog, contentNamed, frameworkPackages, initPacked, initWrote, nodeAppPackages, nodePackages, peerPackages, published, release, specOf, storePackages, unpacked, vercelPackages };