The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; |
| 2 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 3 | import * as Data from "effect/Data"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as FileSystem from "effect/FileSystem"; |
| 6 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 7 | import * as Layer from "effect/Layer"; |
| 8 | import { packageWebsiteArtifact, type WebsiteArtifactProps } from "./Artifact.ts"; |
| 9 | |
| 10 | export class PackageRunnerInvalidProps extends Data.TaggedError("PackageRunnerInvalidProps")<{ |
| 11 | readonly message: string; |
| 12 | readonly cause?: unknown; |
| 13 | }> {} |
| 14 | |
| 15 | NodeRuntime.runMain( |
| 16 | Effect.gen(function* () { |
| 17 | const fs = yield* FileSystem.FileSystem; |
| 18 | const inputPath = process.argv[2]; |
| 19 | const outputPath = process.argv[3]; |
| 20 | if (!inputPath || !outputPath) |
| 21 | return yield* new PackageRunnerInvalidProps({ message: "Missing Website packaging paths" }); |
| 22 | const source = yield* fs.readFileString(inputPath); |
| 23 | const props = yield* Effect.try(() => JSON.parse(source) as WebsiteArtifactProps); |
| 24 | const { archive } = yield* packageWebsiteArtifact(props); |
| 25 | yield* fs.writeFile(outputPath, archive); |
| 26 | }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer))), |
| 27 | ); |