-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Leo CLI new version update notification #28345
base: mainnet
Are you sure you want to change the base?
Conversation
needs review @d0cd |
Thanks for the contribution @ungaro!
|
Well, I researched best practices before implementing this, and here are some examples of how tools handle checking for updates to themselves: npm (Node.js package manager):
Homebrew (macOS package manager):
Cargo (Rust package manager):
Git:
VS Code:
These examples show that while practices vary, many popular tools do implement some form of periodic self-update checking rather than checking on every invocation. This approach balances keeping users informed with avoiding excessive network requests and potential API rate limiting issues. (more about rate-limiting below) Regarding checking every time, you'll still need some cache files. Once an update is found, it's unnecessary to check for new updates as For Also, caching files doesn't prevent consistently reminding users of an update. It's consistently checking from the cache files and providing the notification in subsequent requests. Moreover, frequent update checks might lead to rate limiting issues with GitHub's API. Many projects hosted on GitHub use their API for version checks, and GitHub does impose rate limits. For instance, unauthenticated requests are limited to 60 per hour per IP address. This could potentially cause problems for users in shared environments or those who frequently use the tool. Caching also helps in offline scenarios, allowing the tool to provide the last known update information even when a network connection isn't available. if you're offline, you'll see some real lag as the connection will have to fail. While the option to skip the update check is a good idea, having a reasonable default interval (like once a day) with the option to force a check seems to balance user awareness with system performance and API usage considerations. @d0cd |
Thank you for doing the research @ungaro! I agree with your analysis and like the overall approach. Left some comments on mainly focused on making the implementation more lightweight and canonical. |
Motivation
Implemented an update notification system to keep users informed about new versions of the Leo CLI tool.
This PR introduces the following enhancements to the update notification system:
Conditional Update Checks: The update notification system performs checks based on a time interval (currently set to once per day) or when forced, reducing unnecessary network requests. It writes the last check timestamp and latest version to cache files. This check runs on any command with arguments.
Integration with Help and Version Commands: Update notifications are also integrated into the help (
--help
) and version (--version
) command outputs. These commands do not trigger an update check; instead, they read from the cached latest version file.Closes #28335