From fb1146f37b0f8b702cbde858a82b4cab205a6b26 Mon Sep 17 00:00:00 2001 From: Param Harrison Date: Tue, 13 Oct 2026 23:10:41 +0300 Subject: [PATCH 1/2] factory: claim #177 by runner-21047-1791922241806 From 9a21e3ae5fbc5a0da222034347837f1ef3739696 Mon Sep 17 00:00:00 2001 From: Param Harrison Date: Wed, 14 Oct 2026 14:32:11 +0300 Subject: [PATCH 2/2] factory: build #177 --- README.md | 19 +++++++++++++++++++ tests/readme.test.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/readme.test.ts diff --git a/README.md b/README.md index 666ab78..23d1892 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,25 @@ transfers. Bun, TypeScript, Hono, `bun:sqlite`. No build step for the web page (`public/index.html` is served as-is). +## Run it + +```sh +bun install +bun run dev +``` + +`bun run dev` serves the web page and API on http://localhost:3200 (set +`PORT` to use another port). Demo data is seeded into `splitbill.sqlite` +on first run. + +The CLI reads the same database: + +```sh +bun run src/cli.ts groups +bun run src/cli.ts balances +bun run src/cli.ts export +``` + ## Layout ``` diff --git a/tests/readme.test.ts b/tests/readme.test.ts new file mode 100644 index 0000000..a5ec510 --- /dev/null +++ b/tests/readme.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +const root = join(import.meta.dir, ".."); +const readme = readFileSync(join(root, "README.md"), "utf8"); +const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8")); +const server = readFileSync(join(root, "src/server.ts"), "utf8"); +const cli = readFileSync(join(root, "src/cli.ts"), "utf8"); + +function runItSection(): string { + const start = readme.indexOf("\n## Run it\n"); + if (start === -1) return ""; + const rest = readme.slice(start + 1); + const next = rest.indexOf("\n## ", 1); + return next === -1 ? rest : rest.slice(0, next); +} + +describe("README Run it", () => { + test("Run it section lists install, dev and URL", () => { + const section = runItSection(); + expect(section).not.toBe(""); + expect(section).toContain("bun install"); + expect(section).toContain("bun run dev"); + expect(section).toContain("http://localhost:3200"); + }); + + test("Run it section has a CLI example", () => { + expect(runItSection()).toContain("bun run src/cli.ts groups"); + expect(readme).toContain("balances "); + expect(readme).toContain("export "); + expect(cli).toContain("splitbill balances "); + expect(cli).toContain("splitbill export "); + }); + + test("Run it commands match package.json and server default port", () => { + expect(pkg.scripts.dev).toBe("bun run src/server.ts"); + expect(server).toContain("process.env.PORT ?? 3200"); + }); +});