vx-dependency
Dependency resolution engine for vx tool management system.
Overview
vx-dependency
provides a sophisticated dependency resolution engine for managing tool dependencies in the vx ecosystem. It handles complex dependency graphs, version constraints, and automatic dependency installation.
Features
- Multi-layer Dependency Support: Handle tool-to-tool dependencies automatically
- Dependency Graph Management: Build and analyze complex dependency relationships
- Circular Dependency Detection: Prevent and detect circular dependencies
- Version Constraint Resolution: Resolve version conflicts across dependencies
- Automatic Installation: Install dependencies in the correct order
- Conflict Resolution: Handle and resolve dependency conflicts intelligently
Installation
Add this to your Cargo.toml
:
[]
= "0.2.6"
Usage
Basic Dependency Resolution
use ;
async
Dependency Graph Analysis
use DependencyGraph;
let mut graph = new;
// Build dependency relationships
graph.add_dependency?;
graph.add_dependency?;
// Check for circular dependencies
if let Some = graph.detect_cycles
// Get topological order
let order = graph.topological_sort?;
println!;
Version Constraint Resolution
use ;
let resolver = new;
// Add version constraints
resolver.add_constraint?;
resolver.add_constraint?;
// Resolve compatible version
let version = resolver.resolve_version.await?;
println!;
Architecture
Core Components
- DependencyResolver: Main engine for dependency resolution
- DependencyGraph: Graph structure for dependency relationships
- VersionConstraint: Version constraint handling and resolution
- InstallationPlanner: Optimizes installation order
Integration Points
- vx-plugin: Tool plugin integration for dependency information
- vx-version: Version parsing and constraint resolution
- vx-core: Core tool management integration
Advanced Features
Dependency Caching
use ;
let cache_config = new
.with_ttl
.with_max_entries;
let resolver = with_cache;
Custom Dependency Sources
use ;
;
let resolver = with_source;
Examples
Package Manager Dependencies
// npm depends on node
resolver.add_dependency?;
// yarn depends on node
resolver.add_dependency?;
// pnpm depends on node
resolver.add_dependency?;
// When installing yarn, node will be installed first
let order = resolver.resolve_install_order.await?;
// Result: ["node", "yarn"]
Complex Dependency Chains
// Build tool chain: app -> bundler -> compiler -> runtime
resolver.add_dependency?;
resolver.add_dependency?;
resolver.add_dependency?;
let order = resolver.resolve_install_order.await?;
// Result: ["node", "typescript", "webpack", "my-app"]
Error Handling
use ;
match resolver.resolve_install_order.await
Testing
Run with dependency resolution logging:
RUST_LOG=vx_dependency=debug
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.