The best way to control Claude Code, Codex and more from any computer or phone

main
ts 52 lines 1.76 KB
Raw
1 /**
2 * Discovers the TypeScript entrypoint fixtures used by the bundle-size tools.
3 *
4 * The bundle CLI uses these fixture names to build current bundle reports,
5 * compare them against a base directory, and populate the visualization
6 * selector. Fixtures are intentionally discovered from the package's local
7 * `fixtures` directory as top-level `.ts` files and sorted by name so reports
8 * are deterministic.
9 *
10 * When adding or renaming fixtures, keep in mind that comparison reports match
11 * files by basename between the current fixtures directory and the provided
12 * base directory. New fixtures without a matching base file are reported as
13 * unchanged. Each fixture is bundled as its own Rollup entrypoint, so it should
14 * represent the import shape being measured and avoid depending on incidental
15 * fixture discovery order.
16 *
17 * @since 4.0.0
18 */
19 import * as Array from "effect/Array"
20 import * as Context from "effect/Context"
21 import * as Effect from "effect/Effect"
22 import * as Layer from "effect/Layer"
23 import * as Order from "effect/Order"
24 import * as Glob from "glob"
25 import { fileURLToPath } from "node:url"
26
27 /**
28 * Context service that discovers and sorts TypeScript fixture files used by the bundle size tooling.
29 *
30 * @category services
31 * @since 4.0.0
32 */
33 export class Fixtures extends Context.Service<Fixtures>()(
34 "@effect/bundle/Fixtures",
35 {
36 make: Effect.gen(function*() {
37 const fixturesDir = fileURLToPath(new URL("../fixtures/", import.meta.url))
38
39 const fixtures = yield* Effect.promise(() => Glob.glob("*.ts", { cwd: fixturesDir })).pipe(
40 Effect.map(Array.sort(Order.String)),
41 Effect.orDie
42 )
43
44 return {
45 fixtures,
46 fixturesDir
47 } as const
48 })
49 }
50 ) {
51 static readonly layer = Layer.effect(this, this.make)
52 }