Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge branch 'worktree-agent-a0d1a64e2033a58ed' into claude/cool-newton-7nm8r9 | 1 | /** |
| 2 | * What Settings, Deployments says a project is, from its last build: its | |
| 3 | * kind and what it was built with (`Static site · Astro`, `Container · | |
| 4 | * Dockerfile`), and what running it costs, in a line. No imports beyond | |
| 5 | * types, so it can be tested under Node. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { BuildAs, DetectedKind } from "@g1t/contracts"; | |
| 9 | ||
| 10 | export const KIND_LABELS: Record<DetectedKind, string> = { | |
| 11 | static: "Static site", | |
| 12 | html: "Plain HTML", | |
| 13 | workers: "Workers project", | |
| 14 | container: "Container", | |
| 15 | }; | |
| 16 | ||
| 17 | export const KIND_COSTS: Record<DetectedKind, string> = { | |
| 18 | static: "Serving its files runs no code, so it adds no requests or CPU time. Builds are metered.", | |
| 19 | html: "Its files are served as they are and run no code, so serving adds no requests or CPU time. Builds are metered.", | |
| 20 | workers: "Its code runs on every request: requests and CPU time are metered, and so are builds.", | |
| 21 | container: | |
| 22 | "Its container runs only while it is awake: from the first request until it has had none for a few minutes, metered by the minute at its size, with what it sends. Builds are metered.", | |
| 23 | }; | |
| 24 | ||
| 25 | /** `Static site · Astro`, `Container · Dockerfile`, or the kind alone when nothing names what it was built with. */ | |
| 26 | export function detectedLabel(kind: DetectedKind, framework: string | null | undefined, names: Record<string, string>): string { | |
| 27 | const built = framework ? (names[framework] ?? null) : null; | |
| 28 | if (!built) return KIND_LABELS[kind]; | |
| 29 | // A server g1t wrote a Dockerfile for says so. | |
| 30 | const written = kind === "container" && framework !== "dockerfile" ? `${built}, with a Dockerfile g1t wrote` : built; | |
| 31 | return `${KIND_LABELS[kind]} · ${written}`; | |
| 32 | } | |
| 33 | ||
| 34 | /** The Build as choices, as the select shows them. */ | |
| 35 | export const BUILD_AS_OPTIONS: { value: BuildAs; label: string }[] = [ | |
| 36 | { value: "auto", label: "Auto: found from its files" }, | |
| 37 | { value: "static", label: "Static site" }, | |
| 38 | { value: "workers", label: "Workers" }, | |
| 39 | { value: "docker", label: "Docker" }, | |
| 40 | ]; | |
| 41 | ||
| 42 | /** `1/16 vCPU, 256 MiB, 2 GB disk`. */ | |
| 43 | export function sizeLabel(size: { vcpu: number; memoryGib: number; diskGb: number }): string { | |
| 44 | const vcpu = size.vcpu >= 1 ? String(size.vcpu) : `1/${Math.round(1 / size.vcpu)}`; | |
| 45 | const memory = size.memoryGib >= 1 ? `${size.memoryGib} GiB` : `${Math.round(size.memoryGib * 1024)} MiB`; | |
| 46 | return `${vcpu} vCPU, ${memory}, ${size.diskGb} GB disk`; | |
| 47 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.