Enhanced Dependencies Command
The Rhema dependencies command has been significantly enhanced to provide comprehensive dependency analysis using lock file data. This allows for accurate dependency impact analysis, version conflict detection, and detailed comparison between lock file and current state.
Overview
The enhanced dependencies command provides multiple analysis modes and comprehensive reporting options. It can analyze dependencies from either the current state or the lock file, compare them, and provide detailed insights into dependency relationships, conflicts, and impact.
Command Options
Analysis Mode Options
--lock-file: Analyze dependencies from the lock file instead of current state--compare: Compare lock file with current state and report differences--visualize: Show enhanced dependency chain visualization--conflicts: Detect and report version conflicts--impact: Show detailed dependency impact analysis
Output Format Options
--format text: Output in human-readable text format (default)--format json: Output in JSON format for programmatic processing--format yaml: Output in YAML format for configuration files
Usage Examples
Basic Dependency Analysis
# Analyze current dependencies
rhema dependencies
# Analyze dependencies from lock file
rhema dependencies --lock-file
# Compare lock file with current state
rhema dependencies --compareAdvanced Analysis
# Full analysis with visualization
rhema dependencies --lock-file --visualize --conflicts --impact
# Output in JSON format for automation
rhema dependencies --compare --format json
# Detect conflicts only
rhema dependencies --conflictsAnalysis Features
1. Accurate Dependency Impact Analysis
The enhanced command provides precise dependency impact analysis using lock file data:
- Dependency Depth Calculation: Determines how many levels deep each scopeβs dependencies go
- High Impact Scope Identification: Identifies scopes with the most dependencies
- Independent Scope Detection: Finds scopes with no dependencies
- Transitive Dependency Analysis: Analyzes dependencies of dependencies
Example Output:
π Enhanced Dependency Impact Analysis
==================================================
π High Impact Scopes:
π΄ Critical main-app (8 dependencies)
π‘ High shared-lib (5 dependencies)
π’ Medium utils (3 dependencies)
π΅ Low config (1 dependencies)
π’ Independent Scopes:
π¦ standalone-tool
π¦ documentation2. Version Conflict Detection
Comprehensive version conflict detection between lock file and current state:
- Version Mismatches: Detects when current versions differ from locked versions
- Missing Dependencies: Identifies dependencies in lock file but not in current state
- Extra Dependencies: Finds dependencies in current state but not in lock file
- Type Mismatches: Detects changes in dependency types
Example Output:
β οΈ Version Conflicts:
π΄ main-app β shared-lib: expected 1.0.0, got 2.0.0
π‘ main-app β missing-dep: expected 1.0.0, got missing
π’ utils β extra-dep: expected missing, got 1.0.03. Dependency Chain Visualization
Enhanced visualization of dependency relationships:
- Hierarchical Display: Shows dependency tree structure
- Impact Indicators: Visual indicators for high-impact dependencies
- Circular Dependency Detection: Highlights circular dependency chains
- Longest Chain Analysis: Identifies the longest dependency chains
Example Output:
π¨ Dependency Graph Visualization:
π Enhanced Dependency Graph
==================================================
π main-app
βββ π¦ shared-lib
β βββ π utils
β βββ π config
βββ π¦ external-api
βββ π auth-service
π shared-lib
βββ π utils
βββ π config
π utils
βββ π΄ Independent (no dependencies)4. Performance Optimization
The command uses pre-computed dependency graphs for improved performance:
- Lock File Caching: Leverages pre-computed dependency information
- Incremental Analysis: Only analyzes changed dependencies when possible
- Efficient Graph Algorithms: Uses optimized algorithms for large dependency graphs
- Memory Management: Efficient memory usage for large projects
5. Comparison Between Lock File and Current State
Detailed comparison reporting:
- Scope Differences: Added, removed, or modified scopes
- Dependency Changes: Changes in dependency relationships
- Version Updates: Version changes between lock file and current state
- Structural Changes: Changes in dependency structure
Example Output:
π Differences between lock file and current state:
β main-app: Dependency 'new-feature' added
β utils: Dependency 'old-lib' removed
π shared-lib: Dependency 'auth-service' version changed from 1.0.0 to 2.0.0Output Formats
Text Format (Default)
Human-readable output with color coding and emojis for easy scanning:
π DEPENDENCY ANALYSIS RESULTS
================================================================================
π Statistics:
β’ Total scopes: 15
β’ Scopes with dependencies: 12
β’ Independent scopes: 3
β’ Circular dependencies: 0
β’ Version conflicts: 2
π High Impact Scopes:
π΄ Critical main-app (8 dependencies)
π‘ High shared-lib (5 dependencies)
β οΈ Version Conflicts:
π΄ main-app β shared-lib: expected 1.0.0, got 2.0.0JSON Format
Structured data for programmatic processing:
{
"analysis": {
"total_scopes": 15,
"dependency_depths": {
"main-app": 8,
"shared-lib": 5
},
"circular_dependencies": [],
"version_conflicts": [
{
"scope": "main-app",
"dependency": "shared-lib",
"expected_version": "1.0.0",
"actual_version": "2.0.0",
"conflict_type": "VersionMismatch"
}
],
"longest_chains": [
["main-app", "shared-lib", "utils", "config"]
],
"high_impact_scopes": [
["main-app", 8],
["shared-lib", 5]
],
"independent_scopes": ["standalone-tool", "documentation"],
"differences": [
{
"scope": "main-app",
"difference_type": "Added",
"details": "Dependency 'new-feature' added"
}
]
}
}YAML Format
Configuration-friendly output:
analysis:
total_scopes: 15
dependency_depths:
main-app: 8
shared-lib: 5
circular_dependencies: []
version_conflicts:
- scope: main-app
dependency: shared-lib
expected_version: "1.0.0"
actual_version: "2.0.0"
conflict_type: VersionMismatch
longest_chains:
- - main-app
- shared-lib
- utils
- config
high_impact_scopes:
- - main-app
- 8
- - shared-lib
- 5
independent_scopes:
- standalone-tool
- documentation
differences:
- scope: main-app
difference_type: Added
details: "Dependency 'new-feature' added"Integration with Other Commands
The enhanced dependencies command integrates with other Rhema commands:
- Health Command: Uses dependency analysis for lock file health checks
- Validation Command: Leverages dependency information for validation
- Impact Command: Provides dependency impact data for change analysis
- Sync Command: Uses dependency information for synchronization
Best Practices
For Development Teams
- Regular Analysis: Run dependency analysis regularly to catch issues early
- Lock File Comparison: Use
--compareto ensure lock file stays in sync - Conflict Detection: Use
--conflictsbefore major updates - Impact Assessment: Use
--impactto understand change implications
For CI/CD Pipelines
- JSON Output: Use
--format jsonfor automated processing - Conflict Checking: Include
--conflictsin validation pipelines - Comparison Monitoring: Use
--compareto detect drift - Performance Monitoring: Track analysis time for large projects
For Large Projects
- Incremental Analysis: Use lock file analysis for faster results
- Focused Analysis: Use specific flags to analyze only whatβs needed
- Output Filtering: Use JSON output and filter results programmatically
- Caching: Leverage lock file caching for repeated analysis
Troubleshooting
Common Issues
- No Lock File Found: Use current state analysis or generate lock file first
- Large Analysis Times: Use
--lock-filefor faster analysis of large projects - Memory Issues: Use specific flags to limit analysis scope
- Output Format Issues: Ensure proper JSON/YAML parsing for automated tools
Performance Tips
- Use Lock File: Lock file analysis is typically faster than current state analysis
- Limit Scope: Use specific flags to analyze only what you need
- Batch Processing: Use JSON output for batch processing of multiple projects
- Caching: Lock file data is cached for repeated analysis
Future Enhancements
Planned improvements for the dependencies command:
- Graph Visualization: Interactive dependency graph visualization
- Dependency Metrics: Advanced metrics and analytics
- Predictive Analysis: Predict impact of dependency changes
- Integration APIs: Programmatic access to dependency analysis
- Real-time Monitoring: Continuous dependency monitoring
- Advanced Filtering: More sophisticated filtering and querying options