vx_installer/
lib.rs

1//! # vx-installer
2//!
3//! Installation utilities and helpers for the vx universal tool manager.
4//!
5//! This crate provides a unified interface for downloading, extracting, and installing
6//! development tools across different platforms and archive formats.
7//!
8//! ## Features
9//!
10//! - **Unified Installation API**: Single interface for all installation operations
11//! - **Multiple Archive Formats**: Support for ZIP, TAR.GZ, TAR.XZ, and binary files
12//! - **Progress Tracking**: Built-in progress bars for downloads and extractions
13//! - **Platform Agnostic**: Works across Windows, macOS, and Linux
14//! - **Async Support**: Fully async API for non-blocking operations
15//!
16//! ## Example
17//!
18//! ```rust,no_run
19//! use vx_installer::{Installer, InstallConfig, InstallMethod, ArchiveFormat};
20//! use std::path::PathBuf;
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//!     let installer = Installer::new().await?;
25//!     
26//!     let config = InstallConfig::builder()
27//!         .tool_name("node")
28//!         .version("18.17.0")
29//!         .download_url("https://nodejs.org/dist/v18.17.0/node-v18.17.0-linux-x64.tar.gz")
30//!         .install_method(InstallMethod::Archive {
31//!             format: ArchiveFormat::TarGz
32//!         })
33//!         .install_dir(PathBuf::from("/opt/vx/tools/node/18.17.0"))
34//!         .build();
35//!     
36//!     let executable_path = installer.install(&config).await?;
37//!     println!("Installed to: {}", executable_path.display());
38//!     
39//!     Ok(())
40//! }
41//! ```
42
43pub mod downloader;
44pub mod error;
45pub mod formats;
46pub mod installer;
47pub mod progress;
48
49// Re-export main types for convenience
50pub use downloader::Downloader;
51pub use error::{Error, Result};
52pub use installer::{ArchiveFormat, InstallConfig, InstallConfigBuilder, InstallMethod, Installer};
53pub use progress::{ProgressReporter, ProgressStyle};
54
55// Re-export format handlers
56pub use formats::{ArchiveExtractor, FormatHandler};
57
58/// Version information for the vx-installer crate
59pub const VERSION: &str = env!("CARGO_PKG_VERSION");
60
61/// Default user agent for HTTP requests
62pub const USER_AGENT: &str = concat!("vx-installer/", env!("CARGO_PKG_VERSION"));
63
64#[cfg(test)]
65mod tests {
66    use super::*;
67
68    #[test]
69    fn test_version_info() {
70        assert!(!VERSION.is_empty());
71        assert!(USER_AGENT.contains("vx-installer"));
72    }
73}