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

main
ts 73 lines 2.42 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
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: GCP.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 "GCP.Website.Nextjs local",
24 { tags: ["provider:gcp", "provider:gcp: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-gcp-local-",
37 entries: fixtureEntries,
38 });
39 yield* prepareNextjsFixture(rootDir);
40
41 const deployed = yield* stack.deploy(
42 Effect.gen(function* () {
43 const site = yield* GCP.Website.Nextjs("Web", {
44 rootDir,
45 });
46 return { site };
47 }),
48 );
49
50 const url = deployed.site.url;
51 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
52 expect(deployed.site.service).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 {
68 tags: ["provider:gcp", "provider:gcp:website", "live"],
69 timeout: 600_000,
70 },
71 );
72 },
73 );