The best way to control Claude Code, Codex and more from any computer or phone

main
ts 93 lines 3.28 KB
Raw
1 import { resolveAstroOutput } from "alchemy/Website/AstroOutput";
2 import * as Effect from "effect/Effect";
3 import { frameworkSite, staticConfigFromAssets, type FrameworkSiteProps } from "./FrameworkSite.ts";
4
5 /** The framework-integration package that drives the Astro build. */
6 export const ASTRO_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/astro";
7
8 /** The Node container deploy target for the Astro build. */
9 export const ASTRO_NODE_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/astro/node";
10
11 export interface AstroProps extends FrameworkSiteProps {
12 /**
13 * Serializable Astro config merged OVER the project's own
14 * `astro.config.*` (which loads natively). `adapter` is owned by the Node
15 * deploy target and may not be set here.
16 */
17 astro?: {
18 /** The full URL the site deploys to (`Astro.site`). */
19 site?: string;
20 /** Base path the site deploys under. */
21 base?: string;
22 /**
23 * Astro output target. `"server"` renders pages on demand; individual
24 * pages opt into prerendering with `export const prerender = true`.
25 * `"static"` prerenders every page at build time and deploys
26 * assets-only (no SSR server). Overrides the `output` in your
27 * `astro.config.*`; leave it unset to use the file's value.
28 * @default the config file's `output`, else `"server"`
29 */
30 output?: "server" | "static";
31 /** Source directory, relative to `rootDir`. @default "./src" */
32 srcDir?: string;
33 /** Public (static passthrough) directory. @default "./public" */
34 publicDir?: string;
35 /** Build output directory. @default "./dist" */
36 outDir?: string;
37 /** Trailing-slash handling for routes. */
38 trailingSlash?: "always" | "never" | "ignore";
39 };
40 }
41
42 /**
43 * Deploy an [Astro](https://astro.build) application to Cloud Run: a service
44 * running the Node adapter's serve entry (static files first, then the
45 * framework handler) on Cloud Run's `PORT` (8080).
46 *
47 * Pages render on demand by default (`output: "server"`). When your
48 * `astro.config.*` or `astro: { output: "static" }` declares a static
49 * site, every page is prerendered and the deploy is assets-only.
50 *
51 *
52 * ### Creating Astro Sites
53 * **Example:** Basic Astro App
54 * ```typescript
55 * const site = yield* GCP.Website.Astro("Web", {
56 * rootDir: "./app",
57 * });
58 * ```
59 *
60 * **Example:** Warm Instance with More Memory
61 * ```typescript
62 * const site = yield* GCP.Website.Astro("Web", {
63 * rootDir: "./app",
64 * scaling: { minInstanceCount: 1 },
65 * resources: { limits: { cpu: "1", memory: "1Gi" } },
66 * });
67 * ```
68 *
69 * ### Static Sites
70 * **Example:** Fully Static Astro Site
71 * ```typescript
72 * const site = yield* GCP.Website.Astro("Docs", {
73 * rootDir: "./docs",
74 * astro: { output: "static" },
75 * assets: { notFoundHandling: "404-page" },
76 * });
77 * ```
78 *
79 * @resource
80 * @product Website
81 */
82 export const Astro = (id: string, props: AstroProps = {}) =>
83 resolveAstroOutput({ rootDir: props.rootDir, output: props.astro?.output }).pipe(
84 Effect.flatMap((output) =>
85 frameworkSite(id, props, {
86 name: "Astro",
87 framework: ASTRO_FRAMEWORK_SPECIFIER,
88 target: ASTRO_NODE_TARGET_SPECIFIER,
89 options: { astro: { ...props.astro, output } },
90 static: output === "static" ? staticConfigFromAssets(props.assets) : undefined,
91 }),
92 ),
93 );