Files
SpacetimeDB/crates/update/Cargo.toml
clockwork-labs-bot 5404126aba CLI - Notify users if there's an update available (#4363)
## Summary

Adds a version update check to the `spacetimedb-update` proxy, so users
are notified when a newer version of SpacetimeDB is available.

## Changes

Adds `crates/update/src/update_notice.rs` — a lightweight update check
that runs in the proxy path before exec'ing the CLI:

- **Cache-based**: Stores the last check result in
`~/.spacetime/.update_check_cache`. Only hits the network once every 24
hours.
- **Non-blocking on cache hit**: If the cache is fresh, it's a single
file read — no network, no delay.
- **Short timeout**: When the cache is stale, makes a single HTTP
request to GitHub releases API with a 5-second timeout. Uses the same
`SPACETIME_UPDATE_RELEASES_URL` env var as `spacetime version upgrade`.
- **Best-effort**: Any failure (network, parse, file I/O) is silently
ignored. The update check never interferes with the user's command.
- **Uses semver**: Proper version comparison via the `semver` crate
(already a dependency).

## Output

When a newer version is available:
```
A new version of SpacetimeDB is available: v2.1.0 (current: v2.0.0)
Run `spacetime version upgrade` to update.
```

# Testing
- [x] I get a warning if my local version is less than 2.0.2
- [x] If I have a cached update check, I get the same error even if I
have no network connection
- [x] if the cache is old, the next command checks again
- [x] if I'm not connected and the cache is stale, I'm still able to use
the CLI

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-05 22:20:57 +00:00

43 lines
1.1 KiB
TOML

[package]
name = "spacetimedb-update"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license-file = "LICENSE"
publish = false
[features]
# NOTE(bfops): This is not a well-thought-through feature. It's really only meant for internal testing/debugging.
# Specifically, we use it in some CI.
github-token-auth = []
[dependencies]
spacetimedb-paths.workspace = true
anyhow.workspace = true
bytes.workspace = true
clap.workspace = true
dialoguer = { workspace = true, default-features = false }
flate2.workspace = true
http-body-util = "0.1.2"
colored.workspace = true
indicatif.workspace = true
log.workspace = true
reqwest.workspace = true
self-replace.workspace = true
semver = { workspace = true, features = ["serde"] }
serde.workspace = true
serde_json.workspace = true
tar.workspace = true
tempfile.workspace = true
tokio.workspace = true
toml.workspace = true
tracing = { workspace = true, features = ["release_max_level_off"] }
zip = "2.3"
[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = ["Win32_System_Console"] }
[lints]
workspace = true