@flowwright/plugin-cache
v0.1.0
Published
FlowWright shared library — ergonomic content-keyed cache wrappers (withCache, cachedStage).
Readme
@flowwright/plugin-cache
The cache dance in one call. You know the steps — content-hash a lockfile, restore, run the
command that produces the files, save. This package bundles that whole routine into a single
ergonomic wrapper so you don't hand-write it in every stage. The @flowwright/core
cache.restore/cache.save primitives are still right there when you want them.
import { stage } from "@flowwright/core";
import { withCache, cachedStage } from "@flowwright/plugin-cache";
stage("Install", async () => {
await withCache({ path: "node_modules", keyFiles: "pnpm-lock.yaml" }, async () => {
await sh`pnpm install --frozen-lockfile`;
});
});
// or as a ready-made stage:
cachedStage("Install", { id: "install", path: "node_modules", keyFiles: "pnpm-lock.yaml" }, async () => {
await sh`pnpm install --frozen-lockfile`;
});The key is <prefix>-<hashFiles(keyFiles)> (prefix defaults to the slugified
path). Restores run before the stage's steps and saves after — the body always
runs; a warm cache just makes it fast (same semantics as actions/cache).
