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
| 1 | import { expect } from "@alchemy.run/test"; |
| 2 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as FileSystem from "effect/FileSystem"; |
| 5 | import * as Path from "effect/Path"; |
| 6 | import { noopSession } from "@/Report"; |
| 7 | import { Server, ServerProviderLive } from "@/Website/Server"; |
| 8 | |
| 9 | const { test } = Test.make({ providers: ServerProviderLive() }); |
| 10 | |
| 11 | for (const location of ["root", "ancestor", "sibling", "symlink", "dist"] as const) { |
| 12 | test.provider( |
| 13 | `cleanup preserves source when output is ${location}`, |
| 14 | () => |
| 15 | Effect.gen(function* () { |
| 16 | const fs = yield* FileSystem.FileSystem; |
| 17 | const path = yield* Path.Path; |
| 18 | const directory = yield* fs.makeTempDirectoryScoped(); |
| 19 | const root = path.join(directory, "app"); |
| 20 | const dist = path.join(root, "dist"); |
| 21 | const sibling = path.join(directory, "other-app"); |
| 22 | yield* fs.makeDirectory(dist, { recursive: true }); |
| 23 | yield* fs.makeDirectory(sibling); |
| 24 | const source = path.join(root, "page.tsx"); |
| 25 | yield* fs.writeFileString(source, "export default () => 'keep me';"); |
| 26 | yield* fs.writeFileString(path.join(dist, "index.html"), "generated"); |
| 27 | yield* fs.writeFileString(path.join(sibling, "source.ts"), "keep sibling"); |
| 28 | const alias = path.join(root, "output-link"); |
| 29 | yield* fs.symlink(root, alias); |
| 30 | const distDir = { |
| 31 | root, |
| 32 | ancestor: directory, |
| 33 | sibling, |
| 34 | symlink: alias, |
| 35 | dist, |
| 36 | }[location]; |
| 37 | const provider = yield* Server.Provider; |
| 38 | const remove = provider.delete({ |
| 39 | id: "Build", |
| 40 | fqn: "Build", |
| 41 | instanceId: "cleanup-test", |
| 42 | olds: { framework: "unused", target: "unused", root }, |
| 43 | output: { |
| 44 | distDir, |
| 45 | clientDir: undefined, |
| 46 | serverEntry: undefined, |
| 47 | url: undefined, |
| 48 | hash: { input: undefined, output: undefined }, |
| 49 | }, |
| 50 | bindings: [], |
| 51 | session: { ...noopSession, note: () => Effect.void }, |
| 52 | }); |
| 53 | yield* remove; |
| 54 | yield* remove; |
| 55 | expect(yield* fs.readFileString(source)).toBe("export default () => 'keep me';"); |
| 56 | expect(yield* fs.readFileString(path.join(sibling, "source.ts"))).toBe("keep sibling"); |
| 57 | expect(yield* fs.exists(dist)).toBe(location !== "dist"); |
| 58 | }), |
| 59 | { tags: ["unit", "local"], timeout: 10_000 }, |
| 60 | ); |
| 61 | } |