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

main
ts 70 lines 2.42 KB
Raw
1 import * as Fly from "@alchemy.run/fly";
2 import { describe, expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as Effect from "effect/Effect";
5 import * as pathe from "pathe";
6 import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
7 import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
8 import { prepareNextjsFixture } from "../../Cloudflare/Website/TypeScriptCompat.ts";
9
10 const { test } = Test.make({ providers: Fly.providers(), dev: true });
11
12 const fixtureDir = pathe.resolve(import.meta.dirname, "../../AWS/Website/fixtures/nextjs-app");
13 const fixtureEntries = [
14 ".gitignore",
15 "package.json",
16 "next.config.ts",
17 "tsconfig.json",
18 "app",
19 "public",
20 ];
21
22 describe(
23 "Fly.Website.Nextjs local",
24 { tags: ["provider:fly", "provider:fly:website", "local"] },
25 () => {
26 test.provider(
27 "dev runs the framework server with no cloud resources",
28 (stack) =>
29 Effect.gen(function* () {
30 yield* stack.destroy();
31
32 // Clone OUTSIDE the repo (OS temp dir): an in-workspace clone makes
33 // Next treat the alchemy monorepo as the workspace root and look up
34 // the root's typescript (catalog:build = tsgo).
35 const rootDir = yield* cloneFixture(fixtureDir, {
36 prefix: "alchemy-nextjs-fly-local-",
37 entries: fixtureEntries,
38 });
39 yield* prepareNextjsFixture(rootDir);
40
41 const deployed = yield* stack.deploy(
42 Effect.gen(function* () {
43 const site = yield* Fly.Website.Nextjs("Web", { rootDir });
44 return { site };
45 }),
46 );
47
48 const url = deployed.site.url;
49 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
50 expect(deployed.site.service).toBeUndefined();
51 expect(deployed.site.app).toBeUndefined();
52 expect(deployed.site.ip).toBeUndefined();
53
54 yield* expectUrlContains(`${url}/`, "NEXTJS_AWS_PAGE_MARKER", {
55 timeout: "180 seconds",
56 label: "dev home page",
57 });
58 yield* expectUrlContains(`${url}/api/hello?echo=roundtrip`, "NEXTJS_AWS_API_MARKER", {
59 label: "api route (dev)",
60 });
61 yield* expectUrlContains(`${url}/static`, "NEXTJS_AWS_STATIC_MARKER", {
62 label: "extra route (dev)",
63 });
64
65 yield* stack.destroy();
66 }),
67 { timeout: 600_000 },
68 );
69 },
70 );