# Changelog

All notable changes to NestCraftX will be documented in this file.

## [1.0.0] - 2026-07-02

### Added

- **Standalone Relation Command (`nestcraftx g relation`)**: Standalone interactive module-to-module relation generator updating domain entities, DTOs, mappers, and database schemas.
- **Conditional RBAC Guards**: Automatically protects mutation endpoints (`POST`, `PATCH`, `DELETE`) with `JwtAuthGuard` and `RolesGuard` and read endpoints with `@Public()` if auth is enabled.
- **Global Rate Limiting (`@nestjs/throttler`)**: Configurable global rate limit policy with interactive prompts and `--throttler` flag.
- **Health Check Endpoint (`/health`)**: Exposes native health probe routes out of the box.
- **Advanced Query Parameters (Pagination, Filtering, Sorting)**: Auto-injects paginated data query parameters and repository mapping.
- **Interactive Scaffolding Report**: Post-scaffolding ASCII table summarizing files created and next steps.
- **62 Unit Tests**: Clean testing environment with Jest.

### Fixed

- **CommonJS Module System**: Unified ESM imports and CommonJS exports inside `utils.js` and `userInput.js` to prevent runtime crashes.
- **Non-Interactive Flag Parsing**: Corrected boolean flags and path arguments validations in `newCommand` parser.
- **Prisma capitalization**: Forced capitalization mapping for related model fields.

---

## [0.6.0] - 2026-06-16

### Added

- **Jest Testing Framework**: Standard Jest configuration to support unit and integration tests.
- **Unit Tests**: Wrote 26 unit tests cover CLI parsing, entity generation, DTO generation (including semantic Swagger), controller presentation, and app.module.ts updates.
- **E2E Integration Tests**: Wrote a complete generator integration test validating scaffolding, package installation, and TypeScript compilation (`tsc --noEmit`).
- **CI/CD GitHub Actions**: Pipeline executing tests on Ubuntu & Windows across all Node.js LTS versions (18, 20, 22).

### Fixed

- **Upstream Peer Dependency Conflicts (NestJS 11)**:
  - Appended `--legacy-peer-deps` dynamically to all npm install/add commands.
  - Injected `--skip-install` flag into initial Nest CLI creation to speed up scaffolding and avoid initial dependency clashes.
- **Test Files Tracking**: Adjusted `.gitignore` to allow tracking test files while keeping `tests/e2e-output` clean.

---

## [0.5.0] - 2026-06-16

### Added

- **Persistent DB Storage for OTPs & Password Reset Tokens**: Replaced process memory maps with dedicated DB tables/schemas and ORM repositories (Prisma, TypeORM, Mongoose).
- **Password Reset Validation**: Implemented validation of non-expiration and single-use invalidation of reset tokens in `AuthService`.
- **Strict Version Pinning**: Restricted all package installations (Prisma, Mongoose, TypeORM, Swagger, Auth) to precise semver ranges.
- **Semantic Swagger Descriptions**: Context-aware description templates for dates, decimals, foreign keys, and custom manually prompt descriptions.

### Fixed

- **De Morgan Logic Bug**: Fixed relation type exclusion check in `cleanModuleGenerator`.
- **ORM Detection Order**: Prioritized checking the physical existence of the `/prisma` folder over package dependencies in `generateConf`.
- **Conditional JWT Env Variables**: Generated JWT environment variables only if `useAuth` is true.
- **LIGHT Mode Arguments**: Fixed LIGHT mode scaffolding when no project name was passed.
- **npm install Timeout**: Set a 5-minute timeout on dependency installations.

---

## [0.4.0] - 2026-06-14

### Added

- **State-Based Entity Input Flow**: Navigable `EntityBuilder` to support unique constraints, nullable attributes, and default values.
- **Interactive Entity Revision Screen**: Revision menu allowing users to modify, rename, delete fields, or rename entities before code generation.
- **Dry-Run Simulation**: Global `--dry-run` flag to preview generated files without writing to disk.
- **Warnings Report**: Collected non-critical errors and displayed them as a warnings report at the end of execution.

### Changed

- **utils.js Split**: Eclated 2198-line monolith into dedicated generators (`entity.generator`, `dto.generator`, etc.).
- **userInput.js Split**: Split into file-system helpers (`file-system.js`) and module updaters (`app-module.updater.js`).
- **DRY Shared Pipeline**: Unified the project creation steps between `new` and `demo` commands.

---

## [0.3.0] - 2026-06-07

### Added

- **Dynamic Help Version**: Read version dynamically from `package.json` in the help command to prevent version mismatches.
- **Interactive Flags Check**: Fixed flag check validations to support non-interactive execution modes properly.
- **Dynamic Package Manager**: Support package manager selection dynamically based on inputs rather than hardcoding `npm`.

### Changed

- **Unified Module System**: Standardized all project files under CommonJS format to avoid hybrid ESM/CommonJS runtime crashes.
- **Graceful Error Handling**: Non-critical shell command failures (like `prisma format`) now log warnings rather than forcing process exit.

### Fixed

- **Prisma Generator Capitalization**: Forced capitalization of model names in database relations to match Prisma schema constraints.
- **Foreign Key Duplication**: Fixed relation mappings to prevent duplicate foreign key definitions in generated Prisma schemas.
- **Clean Architecture Loops**: Replaced asynchronous `forEach` loops with sequential `for...of` to prevent files being written out-of-order.
- **Safe Environment Generation**: `setupMongoose` now updates the `.env` file instead of overwriting it completely.
- **Robust AppModule Parsing**: Upgraded regex pattern matching in `safeUpdateAppModule` to handle nested array brackets safely.
- **Cleanups**: Removed dead/commented-out code and removed active debug `console.log` statements in generated security guards.

## [0.2.5] - 2026-01-10

### Added

- **New Interactive System (Inquirer.js)**: Replaced `readline-sync` with `Inquirer` for professional arrow-key navigation.
- **Package Manager Support**: Choice between `npm`, `yarn`, and `pnpm` (via `--pm` flag or interactive selection).
- **Smart DB Detection**: Automatic database type selection (PostgreSQL or MongoDB) based on the chosen ORM.
- **Advanced Flag Merging**: Seamless integration between CLI flags and interactive prompts for missing options.
- **Visual Status Badges**: Added README badges for Version, License, and Supported ORMs.

### Changed

- **FULL Architecture Refactor**: Services moved to `application/services` to strictly follow Clean Architecture patterns.
- **Auth Refactoring**: `AuthService` now interacts exclusively with `UserService` (removed direct repository access).
- **Enhanced Demo Command**: The `demo` command now generates a full blog project with 3 related entities (User, Post, Comment) and 1-N relationships.
- **Improved Security**: JWT secrets now generated via `crypto.randomBytes(32)` (64-character hex strings).
- **Docker by Default**: Docker files are now generated by default in both modes unless `--docker=false` is specified.

### Fixed

- **Module Compatibility**: Resolved CommonJS vs ES6 conflicts in generated project templates.
- **Flag Validation**: Fixed bugs where certain CLI flags were ignored during the interactive flow.
- **Circular Dependencies**: Cleaned up imports in the Auth module to prevent potential runtime issues.

---

## [0.2.2] - 2025-11-07

### Added

- **Professional Templates**: Auto-generation of NestJS-specific `.gitignore` and customized `README.md` for every new project.
- **Git Auto-init**: Automatic Git repository initialization and first commit after project generation.
- **Mongoose Support (Beta)**: Initial implementation of MongoDB architecture with Mongoose.

### Changed

- **Code Cleanup**: Removed obsolete configuration files (`start.js`, `fullModeInput.js`, `lightModeInput.js`).
- **Log Standardization**: Unified console messaging using a consistent color-coded system (Info, Success, Warning).

---

## [0.2.0] - 2025-10-27

### Added

- **Dual Architecture Modes**:
  - **Mode FULL**: Complete Clean Architecture + DDD (Use-cases, Mappers, Adapters).
  - **Mode LIGHT**: Simplified MVP Architecture (Controllers → Services → Repositories).
- **Modern CLI Parser**: Support for `--key=value` and `--key value` syntax with validation.
- **Improved UX**: Integrated animated spinners and a full post-generation configuration summary.

### Security

- **Secure Environment**: Automatic generation of `JWT_SECRET` and `JWT_REFRESH_SECRET` in `.env`.
- **Sanitized Examples**: Creation of a safe `.env.example` file without sensitive data.

---

## [0.1.0] - Previous Version

### Initial Features

- Basic NestJS project generation.
- Support for Prisma and TypeORM.
- Basic Docker and Swagger configuration.
- Standard JWT Authentication.

---

## Migration Notes

### From 0.1.x to 0.2.5

**Non-breaking changes**: Version 0.2.x is backward compatible.

**New Recommended Commands:**

```bash
# LIGHT Mode (Fastest for MVPs)
nestcraftx new my-api --light --orm=prisma --auth

# FULL Mode (Standard for enterprise-grade apps)
nestcraftx new my-app --full --orm=typeorm --auth --swagger
```

Benefits of updating:

- Automated secure JWT secrets.

- Choice of Package Manager (npm/yarn/pnpm).

- Cleaner separation of concerns in Auth/User modules.

- Better DX with arrow-key menus.
