brand.ts
This file
Path
scripts/brand.ts
60 lines · 1.6 KiB · TypeScript
Last changed by
Merge build/comments-ops into mainoscabrielbefore adoptione4c407e
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/comments-ops into mainoscabrielbefore adoptione4c407e
line 1why, one step back1// Files come from git, so ignored files (the closed `.env*` values among them) are never opened.Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 2–60why, one step back2import { BunRuntime, BunServices } from "@effect/platform-bun";3import { findLeaks } from "@repo/brand/leaks";4import { Console, Data, Effect, FileSystem, pipe } from "effect";5import { ChildProcess, ChildProcessSpawner } from "effect/process";67class BrandLeaks extends Data.TaggedError("BrandLeaks")<{8 readonly count: number;9}> {}1011const listCommittable = Effect.gen(function* () {12 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;1314 const lines = yield* spawner.lines(15 ChildProcess.make("git", [16 "ls-files",17 "--cached",18 "--others",19 "--exclude-standard",20 "--deduplicate",21 ])22 );2324 return lines.filter((line) => line.length > 0);25});2627const check = Effect.gen(function* () {28 const fs = yield* FileSystem.FileSystem;29 const paths = yield* listCommittable;3031 const files = yield* pipe(32 paths,33 Effect.forEach((path) =>34 fs.exists(path).pipe(35 Effect.flatMap((exists) =>36 exists ? fs.readFileString(path) : Effect.succeed("")37 ),38 Effect.map((content) => ({ content, path }))39 )40 )41 );4243 const leaks = findLeaks(files);4445 if (leaks.length === 0) {46 return yield* Console.log(`brand:check: ${files.length} files, no leaks`);47 }4849 for (const leak of leaks) {50 yield* Console.error(`${leak.path}:${leak.line}: ${leak.text}`);51 }5253 yield* Console.error(54 "brand:check: take the name from @repo/brand instead of spelling it."55 );5657 return yield* new BrandLeaks({ count: leaks.length });58});5960BunRuntime.runMain(check.pipe(Effect.provide(BunServices.layer)));