feat: update notifier — warn when perchd is outdated#4
Merged
Conversation
On each run, print a one-line notice if the installed version is behind npm's latest. The check never delays a command: the notice reflects the previous check, and a stale cache (>24h) triggers a detached, unref'd `perchd __update-check` that fetches the registry and writes ~/.cache/perchd. Notice goes to stderr and the whole feature is skipped when stdout isn't a TTY, so it can't corrupt `perchd path` in the shell cd function. Off under CI/NO_UPDATE_NOTIFIER/ pnpm dev. Native fetch, no new dependency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On each run, if the installed perchd is behind npm's
latest, print a one-line notice:Design — never delay a command, never corrupt output
Mirrors
update-notifier: the notice reflects the previous background check; the hot path is one small file read.perchd __update-check(hidden argv branch, handled before cac) that fetches the registry and writes$XDG_CACHE_HOME/perchd/update-check.json. The current command never awaits the network; the result shows next time.stdoutisn't a TTY.perchd pathis read via$(...)in the shellcdfunction, so a notice on stdout would corrupt it. Verified:p=$(perchd path main)stays clean.CI,NO_UPDATE_NOTIFIER=1, andpnpm dev(running from source).fetch(Node 20) toregistry.npmjs.org/perchd/latest.Files
src/core/update.ts—isNewer,updateNotice, cache read/write,isStale,runUpdateCheck(injectable fetcher),refreshInBackground,maybeNotifyUpdate,updateCheckSuppressed.src/cli.ts— hidden__update-checkbranch + onemaybeNotifyUpdate(version)call.Verification
pnpm typecheckclean ·pnpm test135/135 (10 new unit tests).XDG_CACHE_HOME: real registry fetch writes the cache; a seeded "outdated" cache prints the notice (via pty);perchd pathstdout stays clean; a stale cache triggers the detached refresh that advancescheckedAtand pullslatestfrom the registry after the parent exits; and it correctly stays silent when you're ahead oflatest.Release
Additive, non-breaking. Filed under
[Unreleased]in the CHANGELOG — no version bump here; it'll ride whatever you publish next (0.5.0 is still unpublished).