@todoforai/update-notifier
v0.3.3
Published
Zero-dep, cached update notifier for TODOforAI CLIs
Readme
@todoforai/update-notifier
Zero-dep update notifier and self-updater used by TODOforAI CLIs.
import { checkForUpdates, autoUpdate, selfUpdate } from "@todoforai/update-notifier";
import pkg from "../package.json" with { type: "json" };
checkForUpdates(pkg); // just print "update available" (fire-and-forget)
autoUpdate(pkg); // install newer version at startup, then re-exec
await selfUpdate(pkg); // `<cli> update` command: query registry, install, report- Cached for 24h under
~/.config/todoforai/notifier-<pkg>.json - Silent on CI / non-TTY / when
NO_UPDATE_NOTIFIERis set / when running from abun link/npm linksource checkout - Registry fetch runs in background with a 3s timeout
autoUpdate(pkg)
Non-blocking: decides from the cached version, so an offline or slow registry
never delays startup (a fresh release lands on the run after the background
refresh picks it up). On update it runs npm i -g <pkg>@<latest> and re-execs
the process with the same args; the child gets TODOFORAI_NO_AUTO_UPDATE=1 to
rule out update loops. No-op for linked checkouts and standalone binaries.
selfUpdate(pkg)
User-initiated (<cli> update): queries the registry directly (10s), installs,
prints the outcome, returns true if a new version was installed. No re-exec.
