feat: add dependency direction enforcement (v0.4.0)

Implement dependency direction detection to enforce Clean Architecture rules:
- Domain layer can only import from Domain and Shared
- Application layer can only import from Domain, Application, and Shared
- Infrastructure layer can import from all layers
- Shared layer can be imported by all layers

Added:
- IDependencyDirectionDetector interface in domain layer
- DependencyViolation value object with detailed suggestions and examples
- DependencyDirectionDetector implementation in infrastructure
- Integration with AnalyzeProject use case
- New DEPENDENCY_DIRECTION rule in constants
- 43 comprehensive tests covering all scenarios (100% passing)
- Good and bad examples in examples directory

Improvements:
- Optimized extractLayerFromImport method to reduce complexity
- Fixed indentation in DependencyGraph.ts
- Updated getExampleFix to avoid false positives in old detector

Test Results:
- All 261 tests passing
- Build successful
- Self-check: 0 architecture violations in src code
This commit is contained in:
imfozilbek
2025-11-24 18:31:41 +05:00
parent f46048172f
commit 3fecc98676
15 changed files with 1452 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
This document outlines the current features and future plans for @puaros/guardian.
## Current Version: 0.3.0 ✅ RELEASED
## Current Version: 0.4.0 ✅ RELEASED
**Released:** 2025-11-24
@@ -71,10 +71,9 @@ async getUser(id: string): Promise<UserResponseDto> {
---
## Future Roadmap
## Version 0.4.0 - Dependency Direction Enforcement 🎯 ✅ RELEASED
### Version 0.4.0 - Dependency Direction Enforcement 🎯
**Target:** Q1 2026
**Released:** 2025-11-24
**Priority:** HIGH
Enforce correct dependency direction between architectural layers:
@@ -103,16 +102,20 @@ import { User } from '../../domain/entities/User' // OK
- ✅ Infrastructure → Application, Domain (разрешено)
- ✅ Shared → используется везде
**Planned Features:**
- Detect domain importing from application
- Detect domain importing from infrastructure
- Detect application importing from infrastructure
- Visualize dependency graph
- Suggest refactoring to fix violations
- Support for custom layer definitions
**Implemented Features:**
- Detect domain importing from application
- Detect domain importing from infrastructure
- Detect application importing from infrastructure
- ✅ Detect violations in all import formats (ES6, require)
- ✅ Provide detailed error messages with suggestions
- ✅ Show example fixes for each violation type
- ✅ 43 tests covering all dependency scenarios
- ✅ Good and bad examples in examples directory
---
## Future Roadmap
### Version 0.5.0 - Repository Pattern Validation 📚
**Target:** Q1 2026
**Priority:** HIGH
@@ -1748,4 +1751,4 @@ Until we reach 1.0.0, minor version bumps (0.x.0) may include breaking changes a
---
**Last Updated:** 2025-11-24
**Current Version:** 0.3.0
**Current Version:** 0.4.0