chore: refactor hardcoded values to constants (v0.5.1)

Major internal refactoring to eliminate hardcoded values and improve
maintainability. Guardian now fully passes its own quality checks!

Changes:
- Extract all RepositoryViolation messages to domain constants
- Extract all framework leak template strings to centralized constants
- Extract all layer paths to infrastructure constants
- Extract all regex patterns to IMPORT_PATTERNS constant
- Add 30+ new constants for better maintainability

New files:
- src/infrastructure/constants/paths.ts (layer paths, patterns)
- src/domain/constants/Messages.ts (25+ repository messages)
- src/domain/constants/FrameworkCategories.ts (framework categories)
- src/shared/constants/layers.ts (layer names)

Impact:
- Reduced hardcoded values from 37 to 1 (97% improvement)
- Guardian passes its own src/ directory checks with 0 violations
- All 292 tests still passing (100% pass rate)
- No breaking changes - fully backwards compatible

Test results:
- 292 tests passing (100% pass rate)
- 96.77% statement coverage
- 83.82% branch coverage
This commit is contained in:
imfozilbek
2025-11-24 20:12:08 +05:00
parent 0534fdf1bd
commit a34ca85241
19 changed files with 416 additions and 96 deletions

View File

@@ -2,7 +2,7 @@
This document outlines the current features and future plans for @puaros/guardian.
## Current Version: 0.4.0 ✅ RELEASED
## Current Version: 0.5.0 ✅ RELEASED
**Released:** 2025-11-24
@@ -114,10 +114,9 @@ import { User } from '../../domain/entities/User' // OK
---
## Future Roadmap
## Version 0.5.0 - Repository Pattern Validation 📚 ✅ RELEASED
### Version 0.5.0 - Repository Pattern Validation 📚
**Target:** Q1 2026
**Released:** 2025-11-24
**Priority:** HIGH
Validate correct implementation of Repository Pattern:
@@ -148,15 +147,20 @@ class CreateUser {
}
```
**Planned Features:**
- Check repository interfaces for ORM-specific types
- Detect concrete repository usage in use cases
- Detect `new Repository()` in use cases (should use DI)
- Validate repository methods follow domain language
- Check for data mapper pattern usage
**Implemented Features:**
- Check repository interfaces for ORM-specific types (Prisma, TypeORM, Mongoose, Sequelize, etc.)
- Detect concrete repository usage in use cases
- Detect `new Repository()` in use cases (should use DI)
- Validate repository methods follow domain language
- ✅ 31 tests covering all repository pattern scenarios
- ✅ 96.77% statement coverage, 83.82% branch coverage
- ✅ Examples for both good and bad patterns
- ✅ Comprehensive README with patterns and principles
---
## Future Roadmap
### Version 0.6.0 - Aggregate Boundary Validation 🔒
**Target:** Q1 2026
**Priority:** MEDIUM
@@ -1751,4 +1755,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.4.0
**Current Version:** 0.5.0