scripts.test.ts
This file
Path
packages/config/test/scripts.test.ts
53 lines · 1.7 KiB · TypeScript
Last changed by
Merge infra/drop-demo into mainoscabrielbefore adoptionc49b6bf
History of this fileTake it
Name the swarm, seed and release scripts, and record every throwaway resource a live run makes in one ledgeroscabrielbefore adoptiond7064cb
lines 1–31why, one step back1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Effect, FileSystem, Path, Schema } from "effect";45import { repoRoot } from "./root.ts";67const RootPackage = Schema.Struct({8 scripts: Schema.Record(Schema.String, Schema.String),9});1011const entryOf = (name: string) =>12 Effect.gen(function* () {13 const fs = yield* FileSystem.FileSystem;14 const path = yield* Path.Path;15 const root = yield* repoRoot;16 const text = yield* fs.readFileString(path.join(root, "package.json"));1718 const { scripts } = yield* Schema.decodeEffect(19 Schema.fromJsonString(RootPackage)20 )(text);2122 const command = scripts[name] ?? "";23 const file = /^bun (?<file>\S+)$/u.exec(command)?.groups?.file;2425 return {26 command,27 exists:28 file === undefined ? false : yield* fs.exists(path.join(root, file)),29 };30 });31Merge infra/drop-demo into mainoscabrielbefore adoptionc49b6bf
line 32why, one step back32describe("the examples' scripts", () => {Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
lines 33–51why, one step back33 it.live(34 "swarm, seed, release and import-examples each run one entry file that exists",35 () =>36 Effect.gen(function* () {37 expect({38 "import-examples": yield* entryOf("import-examples"),39 release: yield* entryOf("release"),40 seed: yield* entryOf("seed"),41 swarm: yield* entryOf("swarm"),42 }).toStrictEqual({43 "import-examples": {44 command: "bun scripts/import-examples.ts",45 exists: true,46 },47 release: { command: "bun scripts/release.ts", exists: true },48 seed: { command: "bun scripts/seed.ts", exists: true },49 swarm: { command: "bun scripts/swarm.ts", exists: true },50 });51 }).pipe(Effect.provide(NodeServices.layer))Name the swarm, seed and release scripts, and record every throwaway resource a live run makes in one ledgeroscabrielbefore adoptiond7064cb
lines 52–53why, one step back52 );53});