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

main
ts 38 lines 1.26 KB
Raw
1 import { test } from "@playwright/test";
2 import * as Exit from "effect/Exit";
3 import * as ManagedRuntime from "effect/ManagedRuntime";
4 import * as Scope from "effect/Scope";
5 import * as Runtime from "./Runtime.ts";
6 import * as Server from "./Server.ts";
7 import { installTailwindNodeCompat } from "./TailwindNodeCompat.ts";
8
9 // Guard every playwright worker process before vite can load tailwind.
10 installTailwindNodeCompat();
11
12 export const SERVER_METHODS = ["live", "dev"] as const;
13 export type ServerMethod = (typeof SERVER_METHODS)[number];
14
15 export const make = (method: ServerMethod) =>
16 test.extend<{}, { readonly server: Server.Instance }>({
17 server: [
18 // oxlint-disable-next-line no-empty-pattern
19 async ({}, use) => {
20 const harness = await makeServerInstance(method);
21 await use(harness);
22 await harness.dispose();
23 },
24 { scope: "worker" },
25 ],
26 });
27
28 const makeServerInstance = async (method: ServerMethod) => {
29 const scope = Scope.makeUnsafe();
30 const runtime = ManagedRuntime.make(Runtime.layer);
31 const instance = await runtime.runPromise(
32 Server.Server.use((server) => server[method]()).pipe(Scope.provide(scope)),
33 );
34 return {
35 ...instance,
36 dispose: () => runtime.runPromise(Scope.close(scope, Exit.void)),
37 };
38 };