#!/usr/bin/env tsx // Rebuild the stats datasets. Runs as `tsx bin/build-stats.ts` (export's // build:stats script); `main` is exported for the archilyzer CLI. import { getPaths, type Paths } from "../lib/paths"; import { buildStats } from "../controller/buildStats"; import { settingsFromFile } from "../lib/settings"; import { applyHealthTimings } from "../lib/storageHealth"; import { runIfEntryPoint } from "./_cli"; export async function main(opts: { paths?: Paths } = {}): Promise { const paths = opts.paths ?? getPaths(); // A CLI process has no health pass: the drive-health timings the build's // watchdog runs on (settings.storage.health) are applied here, once. applyHealthTimings(settingsFromFile(paths.settingsFile).storage.health); await buildStats({ paths }); } runIfEntryPoint(import.meta.url, () => main());