runCompact
uses tcmts.cli.main.execute, which uses tcmts.cli.help.usageError, which uses tcmts.cli.help.usageOf, which uses tcmts.cli.style.bold, which uses node:util
Runs tcm compact.
import { routeCompact } from "#codebase/tcmts/cli/commands"; import { pruneCache } from "#codebase/tcmts/cli/compact"; import { execute } from "#codebase/tcmts/cli/main"; import type { Context } from "#codebase/tcmts/cli/run"; import { dim } from "#codebase/tcmts/cli/style"; import { success } from "#codebase/tcmts/cli/ui"; import { parse } from "@bomb.sh/router"; export function runCompact({ cb, cmd, rest }: Context): number { execute(cmd, parse(routeCompact(), { argv: rest })); const r = cb.store.compact(); const cache = pruneCache(cb); const size = (n: number) => n >= 1024 * 1024 ? `${(n / 1024 / 1024).toFixed(0)} MB` : `${Math.ceil(n / 1024)} KB`; success( `compressed ${r.packed} row(s); the codebase is ${size(r.after)} (it was ${size(r.before)})`, ); console.log( dim( ` removed ${cache.files} cached file(s) no branch uses (${size(cache.bytes)}): they're made again if needed`, ), ); return 0; }
uses
- tcmts.cli.commands.routeCompact
- tcmts.cli.compact.pruneCache
- tcmts.cli.main.execute
- tcmts.cli.run.Context
- tcmts.cli.style.dim
- tcmts.cli.ui.success