| Crates.io | vx-version |
| lib.rs | vx-version |
| version | 0.2.2 |
| created_at | 2025-06-19 09:45:17.913313+00 |
| updated_at | 2025-06-19 13:52:34.066164+00 |
| description | Version management and parsing utilities for the vx universal tool manager |
| homepage | https://github.com/loonghao/vx |
| repository | https://github.com/loonghao/vx |
| max_upload_size | |
| id | 1718054 |
| size | 96,631 |
Advanced Version Management for the vx Universal Tool Manager
Intelligent version parsing, fetching, and management with semantic version support
vx-version provides comprehensive version management capabilities for the vx universal tool manager. It handles version parsing, fetching from external sources, semantic version comparison, and constraint resolution across different tool ecosystems.
Add vx-version to your Cargo.toml:
[dependencies]
vx-version = "0.2"
use vx_version::{VersionManager, GitHubVersionFetcher, VersionUtils};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Fetch versions from GitHub
let fetcher = GitHubVersionFetcher::new("astral-sh", "uv");
let versions = fetcher.fetch_versions(false).await?;
println!("Latest UV version: {}", versions[0].version);
// Get installed version
if let Some(installed) = VersionManager::get_installed_version("uv")? {
println!("Installed UV version: {}", installed);
}
// Compare versions
let is_newer = VersionUtils::is_greater_than("0.7.13", "0.7.10");
println!("0.7.13 > 0.7.10: {}", is_newer);
Ok(())
}
use vx_version::{GitHubVersionFetcher, NodeVersionFetcher, VersionFetcher};
// GitHub releases
let uv_fetcher = GitHubVersionFetcher::new("astral-sh", "uv");
let uv_versions = uv_fetcher.fetch_versions(true).await?; // Include prereleases
// Node.js official API
let node_fetcher = NodeVersionFetcher::new();
let node_versions = node_fetcher.fetch_versions(false).await?; // Stable only
// Get latest version
let latest_uv = uv_fetcher.get_latest_version().await?;
if let Some(version) = latest_uv {
println!("Latest UV: {}", version.version);
}
use vx_version::{Version, VersionUtils};
// Parse semantic versions
let v1 = Version::parse("1.2.3")?;
let v2 = Version::parse("1.2.4-alpha.1")?;
println!("v1: {}, prerelease: {}", v1, v1.is_prerelease());
println!("v2: {}, prerelease: {}", v2, v2.is_prerelease());
// Compare versions
assert!(v1 < v2); // Semantic comparison
// Utility functions
assert!(VersionUtils::is_greater_than("2.0.0", "1.9.9"));
assert!(VersionUtils::is_prerelease("1.0.0-beta"));
assert_eq!(VersionUtils::clean_version("v1.0.0", &["v"]), "1.0.0");
use vx_version::VersionInfo;
let version = VersionInfo::new("18.17.0".to_string())
.with_release_date("2023-06-20".to_string())
.with_download_url("https://nodejs.org/dist/v18.17.0/node-v18.17.0.tar.gz".to_string())
.with_metadata("lts".to_string(), "true".to_string())
.with_metadata("lts_name".to_string(), "Hydrogen".to_string());
println!("Version: {}", version); // "18.17.0 (LTS: Hydrogen)"
println!("Is LTS: {}", version.is_lts());
println!("Download URL: {:?}", version.download_url);
use vx_version::{VersionFetcher, VersionInfo, Result};
use async_trait::async_trait;
struct CustomVersionFetcher {
tool_name: String,
}
#[async_trait]
impl VersionFetcher for CustomVersionFetcher {
fn tool_name(&self) -> &str {
&self.tool_name
}
async fn fetch_versions(&self, include_prerelease: bool) -> Result<Vec<VersionInfo>> {
// Custom implementation
let versions = vec![
VersionInfo::new("1.0.0".to_string()),
VersionInfo::new("1.1.0".to_string()),
];
Ok(versions)
}
}
vx-version/
โโโ error.rs # Error types and handling
โโโ fetcher.rs # Version fetching traits and implementations
โโโ info.rs # VersionInfo type and utilities
โโโ manager.rs # Version management and comparison
โโโ parser.rs # Version parsing for different tools
โโโ utils.rs # Utility functions and helpers
| Source | Tool Support | Features |
|---|---|---|
| GitHub Releases | UV, Rust, Go, etc. | Releases API, prerelease detection |
| Node.js Official | Node.js | LTS detection, release metadata |
| Custom APIs | Extensible | Plugin-based architecture |
| Format | Example | Tools |
|---|---|---|
| Semantic | 1.2.3 |
Most tools |
| Prefixed | v1.2.3 |
GitHub releases |
| Tool-specific | go1.21.0 |
Go releases |
| Prerelease | 1.0.0-alpha.1 |
Development versions |
# Run all tests
cargo test
# Run specific test modules
cargo test version_parsing
cargo test version_fetching
cargo test version_comparison
# Run with network tests (requires internet)
cargo test --features network-tests
# Test with coverage
cargo tarpaulin --out Html
vx-installer - Universal installation enginevx-core - Core functionality and utilitiesvx-cli - Command-line interfacevx-config - Configuration managementvx-plugin - Plugin system and trait definitionsThis project is licensed under the MIT License - see the LICENSE file for details.
Intelligent version management for the modern developer