reallink-cli 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/rust/Cargo.lock +1 -1
- package/rust/Cargo.toml +1 -1
- package/rust/src/main.rs +12 -5
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm install -g reallink-cli
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
`npm install` performs a one-time Rust release build during postinstall. After that, `reallink` runs the compiled binary directly (no per-command cargo compile step).
|
|
12
|
-
CLI
|
|
12
|
+
CLI caches update metadata daily. To keep command startup fast, network update checks run during `reallink login` (or explicitly via `reallink self-update --check`) rather than every command.
|
|
13
13
|
|
|
14
14
|
## Commands
|
|
15
15
|
|
package/package.json
CHANGED
package/rust/Cargo.lock
CHANGED
package/rust/Cargo.toml
CHANGED
package/rust/src/main.rs
CHANGED
|
@@ -15,9 +15,10 @@ const SESSION_DIR_NAME: &str = "reallink";
|
|
|
15
15
|
const SESSION_FILE_NAME: &str = "session.json";
|
|
16
16
|
const UPDATE_CACHE_FILE_NAME: &str = "update-check.json";
|
|
17
17
|
const VERSION_CHECK_INTERVAL_MS: u128 = 24 * 60 * 60 * 1000;
|
|
18
|
+
const DEFAULT_VERSION_FETCH_TIMEOUT_MS: u64 = 800;
|
|
18
19
|
|
|
19
20
|
#[derive(Parser)]
|
|
20
|
-
#[command(name = "reallink", version, about = "Reallink CLI")]
|
|
21
|
+
#[command(name = "reallink", bin_name = "reallink", version, about = "Reallink CLI")]
|
|
21
22
|
struct Cli {
|
|
22
23
|
#[command(subcommand)]
|
|
23
24
|
command: Commands,
|
|
@@ -733,8 +734,13 @@ fn is_newer_version(current: &str, latest: &str) -> bool {
|
|
|
733
734
|
}
|
|
734
735
|
|
|
735
736
|
async fn fetch_latest_cli_version(client: &reqwest::Client) -> Option<String> {
|
|
737
|
+
let timeout_ms = std::env::var("REALLINK_UPDATE_CHECK_TIMEOUT_MS")
|
|
738
|
+
.ok()
|
|
739
|
+
.and_then(|value| value.parse::<u64>().ok())
|
|
740
|
+
.filter(|value| *value > 0)
|
|
741
|
+
.unwrap_or(DEFAULT_VERSION_FETCH_TIMEOUT_MS);
|
|
736
742
|
let response = with_cli_headers(client.get("https://registry.npmjs.org/reallink-cli/latest"))
|
|
737
|
-
.timeout(Duration::
|
|
743
|
+
.timeout(Duration::from_millis(timeout_ms))
|
|
738
744
|
.send()
|
|
739
745
|
.await
|
|
740
746
|
.ok()?;
|
|
@@ -749,7 +755,7 @@ async fn fetch_latest_cli_version(client: &reqwest::Client) -> Option<String> {
|
|
|
749
755
|
.filter(|value| !value.is_empty())
|
|
750
756
|
}
|
|
751
757
|
|
|
752
|
-
async fn maybe_notify_update(client: &reqwest::Client, force_refresh: bool) {
|
|
758
|
+
async fn maybe_notify_update(client: &reqwest::Client, force_refresh: bool, allow_network_fetch: bool) {
|
|
753
759
|
if std::env::var("REALLINK_DISABLE_AUTO_UPDATE_CHECK")
|
|
754
760
|
.map(|value| value == "1")
|
|
755
761
|
.unwrap_or(false)
|
|
@@ -772,7 +778,7 @@ async fn maybe_notify_update(client: &reqwest::Client, force_refresh: bool) {
|
|
|
772
778
|
None
|
|
773
779
|
};
|
|
774
780
|
|
|
775
|
-
if latest_version.is_none() {
|
|
781
|
+
if latest_version.is_none() && allow_network_fetch {
|
|
776
782
|
latest_version = fetch_latest_cli_version(client).await;
|
|
777
783
|
let _ = save_update_cache(&UpdateCheckCache {
|
|
778
784
|
last_checked_epoch_ms: now,
|
|
@@ -1922,7 +1928,8 @@ async fn main() -> Result<()> {
|
|
|
1922
1928
|
.build()?;
|
|
1923
1929
|
|
|
1924
1930
|
if !matches!(&cli.command, Commands::SelfUpdate(_)) {
|
|
1925
|
-
|
|
1931
|
+
let allow_update_fetch = matches!(&cli.command, Commands::Login(_));
|
|
1932
|
+
maybe_notify_update(&client, false, allow_update_fetch).await;
|
|
1926
1933
|
}
|
|
1927
1934
|
|
|
1928
1935
|
match cli.command {
|