@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 31 lines 1.26 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as FileSystem from "effect/FileSystem";
3 import * as HttpClient from "effect/http/HttpClient";
4 import * as Path from "effect/Path";
5 import * as Schedule from "effect/Schedule";
6
7 export const copyViteFixture = Effect.gen(function* () {
8 const fs = yield* FileSystem.FileSystem;
9 const path = yield* Path.Path;
10 const source = yield* path.fromFileUrl(new URL("./fixtures/vite/", import.meta.url));
11 const modules = yield* path.fromFileUrl(new URL("../../../node_modules/", import.meta.url));
12 const rootDir = yield* fs.makeTempDirectoryScoped({
13 prefix: "prisma-website-vite-",
14 });
15 yield* fs.copy(source, rootDir);
16 yield* fs.symlink(modules, path.join(rootDir, "node_modules"));
17 return rootDir;
18 });
19
20 export const bodyContaining = Effect.fn(function* (url: string, expected: string) {
21 return yield* Effect.gen(function* () {
22 const response = yield* HttpClient.get(url);
23 const body = yield* response.text;
24 if (response.status !== 200 || !body.includes(expected)) {
25 return yield* Effect.fail(
26 new Error(`${url} returned ${response.status} without ${expected}: ${body.slice(0, 500)}`),
27 );
28 }
29 return body;
30 }).pipe(Effect.retry({ schedule: Schedule.spaced("500 millis"), times: 8 }));
31 });