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

main
ts 81 lines 2.79 KB
Raw
1 import * as Namespace from "alchemy/Namespace";
2 import { resolveAstroOutput } from "alchemy/Website/AstroOutput";
3 import * as Effect from "effect/Effect";
4 import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
5
6 /** Configuration for a Prisma Astro website. */
7 export interface AstroProps extends FrameworkSiteProps {
8 /** Serializable overrides merged over astro.config.*; the Node target owns adapter. */
9 astro?: {
10 /** Canonical deployment URL. */
11 site?: string;
12 /** Deployment base path. */
13 base?: string;
14 /**
15 * Render on demand or prerender every page. Overrides the `output` in
16 * your `astro.config.*`; leave it unset to use the file's value.
17 * @default the config file's `output`, else `"server"`
18 */
19 output?: "server" | "static";
20 /** Source directory relative to rootDir. @default "./src" */
21 srcDir?: string;
22 /** Static passthrough directory. @default "./public" */
23 publicDir?: string;
24 /** Production output directory. @default "./dist" */
25 outDir?: string;
26 /** Route trailing-slash policy. */
27 trailingSlash?: "always" | "never" | "ignore";
28 };
29 }
30
31 /**
32 * Astro SSR and prerendered pages on Prisma Compute. The Node target owns the adapter; omit adapter from astro.config.*. Set `output: "static"` in astro.config.* or astro.output to prerender every page.
33 *
34 * Native framework development and HMR run without Prisma cloud resources.
35 * Apply `Alchemy.remote()` to use the live Compute deployment during dev.
36 * Packaging requires the optional `@vercel/nft` peer dependency.
37 *
38 * ### Creating a Website
39 * **Example:** Astro application
40 * ```typescript
41 * const site = yield* Prisma.Website.Astro("Web", {
42 * rootDir: "./app",
43 * });
44 * ```
45 *
46 * ### Deployment Configuration
47 * **Example:** Existing project and custom hostname
48 * ```typescript
49 * const site = yield* Prisma.Website.Astro("Web", {
50 * project,
51 * domain: "www.example.com",
52 * env: { API_BASE: "https://api.example.com" },
53 * compute: { destroyOldDeployment: true },
54 * });
55 * ```
56 *
57 * ### Static Output
58 * **Example:** Prerendered documentation with a 404 page
59 * ```typescript
60 * const docs = yield* Prisma.Website.Astro("Docs", {
61 * rootDir: "./docs",
62 * astro: { output: "static" },
63 * assets: { notFoundHandling: "404-page" },
64 * });
65 * ```
66 *
67 * @resource
68 * @product Website
69 */
70 export const Astro = (id: string, props: AstroProps = {}) =>
71 resolveAstroOutput({ rootDir: props.rootDir, output: props.astro?.output }).pipe(
72 Effect.flatMap((output) =>
73 makeFrameworkSite(id, props, {
74 framework: "@alchemy.run/frontend-frameworks/astro",
75 target: "@alchemy.run/frontend-frameworks/astro/node",
76 options: { astro: { ...props.astro, output } },
77 notFoundHandling: "none",
78 }),
79 ),
80 Namespace.push(id),
81 );