| 1 | import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; |
| 2 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as FileSystem from "effect/FileSystem"; |
| 5 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 6 | import { |
| 7 | packageWebsiteArtifact, |
| 8 | type WebsiteArtifactProps, |
| 9 | } from "./Artifact.ts"; |
| 10 | |
| 11 | NodeRuntime.runMain( |
| 12 | Effect.gen(function* () { |
| 13 | const fs = yield* FileSystem.FileSystem; |
| 14 | const inputPath = process.argv[2]; |
| 15 | const outputPath = process.argv[3]; |
| 16 | if (!inputPath || !outputPath) |
| 17 | return yield* Effect.fail(new Error("Missing Website packaging paths")); |
| 18 | const source = yield* fs.readFileString(inputPath); |
| 19 | const props = yield* Effect.try( |
| 20 | () => JSON.parse(source) as WebsiteArtifactProps, |
| 21 | ); |
| 22 | const { archive } = yield* packageWebsiteArtifact(props); |
| 23 | yield* fs.writeFile(outputPath, archive); |
| 24 | }).pipe( |
| 25 | Effect.scoped, |
| 26 | Effect.provide(NodeServices.layer), |
| 27 | Effect.provide(FetchHttpClient.layer), |
| 28 | ), |
| 29 | ); |