@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 47 lines 1.63 KB
Raw
1 import { registerHooks } from "node:module";
2 import { FrameworkServerError } from "alchemy/Website/Server";
3 import * as Cause from "effect/Cause";
4 import * as Effect from "effect/Effect";
5 import * as Exit from "effect/Exit";
6
7 // Simulate an absent optional peer without changing the workspace install.
8 let attempts = 0;
9 registerHooks({
10 resolve(specifier, context, nextResolve) {
11 if (
12 specifier === "@alchemy.run/frontend-frameworks" ||
13 specifier.startsWith("@alchemy.run/frontend-frameworks/")
14 ) {
15 attempts++;
16 throw new Error(`Cannot find package '${specifier}'`);
17 }
18 return nextResolve(specifier, context);
19 },
20 });
21
22 const providers: string[] = [];
23 for (const provider of ["Prisma", "Neon", "Fly", "Hetzner", "Railway"]) {
24 const module = await import(`@alchemy.run/${provider.toLowerCase()}`);
25 if (module.Website) providers.push(provider);
26 }
27 const providerImportAttempts = attempts;
28 const { loadFrontendCore } = await import("alchemy/Website/FrontendCore");
29 const exit = await Effect.runPromiseExit(loadFrontendCore);
30 const error = Exit.isFailure(exit) ? Cause.squash(exit.cause) : undefined;
31 console.log(
32 JSON.stringify({
33 providers,
34 providerImportAttempts,
35 loaderImportAttempts: attempts - providerImportAttempts,
36 defect: Exit.isFailure(exit) && exit.cause.reasons.some((reason) => reason._tag === "Die"),
37 error:
38 error instanceof FrameworkServerError
39 ? {
40 _tag: error._tag,
41 framework: error.framework,
42 message: error.message,
43 cause: error.cause instanceof Error ? error.cause.message : error.cause,
44 }
45 : null,
46 }),
47 );