fix: complete TechLog migration evidence
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import type { TechLogServingContract } from "./tech-log-serving-contract.ts";
|
||||
|
||||
type ServingArtifactOptions = Readonly<{
|
||||
distRoot: string;
|
||||
contract: TechLogServingContract;
|
||||
serverSourcePath?: string;
|
||||
}>;
|
||||
|
||||
export async function writeTechLogServingArtifact({
|
||||
distRoot,
|
||||
contract,
|
||||
serverSourcePath = "scripts/lib/tech-log-production-server.ts",
|
||||
}: ServingArtifactOptions): Promise<void> {
|
||||
const absoluteDistRoot = path.resolve(distRoot);
|
||||
const serverSource = await readFile(path.resolve(serverSourcePath), "utf8");
|
||||
await mkdir(absoluteDistRoot, { recursive: true });
|
||||
await Promise.all([
|
||||
writeFile(
|
||||
path.join(absoluteDistRoot, "tech-log-serving-contract.json"),
|
||||
`${JSON.stringify(contract, null, 2)}\n`,
|
||||
),
|
||||
writeFile(path.join(absoluteDistRoot, "server.mjs"), serverSource),
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user