HazelJS v0.2.0-beta.16: Supercharged CLI, 21 Generators & Interactive Scaffolding
The biggest CLI update yet — 21 code generators, interactive project scaffolding with package selection, dry-run mode, CRUD resource generation, and dedicated generators for every HazelJS package including Auth, Cache, Cron, RAG, and Discovery.
HazelJS v0.2.0-beta.16
21 generators, interactive scaffolding, dry-run mode, and dedicated generators for every HazelJS package.
npm install -g @hazeljs/cli@latestWhat's New in This Release
This beta release represents the biggest CLI update since launch. We've gone from 7 basic generators to 21 fully-featured generators, added interactive project scaffolding with package selection, introduced dry-run mode, and built dedicated generators for every HazelJS ecosystem package.
Whether you're starting a new project or adding features to an existing one, the CLI now covers every part of the HazelJS ecosystem — from auth guards to cron jobs, from cache services to RAG pipelines.
Release Highlights
- 21 Code Generators — up from 7 in the previous release
- Interactive Scaffolding —
hazel new --interactivewith package selection - Dry-Run Mode — preview generated files before writing to disk
- CRUD Resource Generator — full controller + service + DTO + module in one command
- Package-Specific Generators — Auth, Config, Cache, Cron, RAG, Discovery
- Consistent Architecture — all generators share a base class with uniform behavior
- Build Fix — corrected
tsconfig.jsonfor swagger, websocket, and cache packages
Interactive Project Scaffolding
The hazel new command now supports an interactive mode that lets you pick exactly which HazelJS packages to include when creating a new project. Selected packages get fully scaffolded — configuration files, boilerplate modules, environment variables, and everything wired together.
# Quick start — scaffold with defaults
hazel new my-api
# Interactive mode — choose your packages
hazel new my-api --interactiveIn interactive mode, you'll see a checklist of all 12 HazelJS packages:
? Select HazelJS packages to include:
◉ @hazeljs/swagger — Auto-generated OpenAPI docs
◉ @hazeljs/prisma — Database ORM integration
◉ @hazeljs/auth — JWT authentication & guards
◉ @hazeljs/config — Environment configuration
◯ @hazeljs/cache — Caching layer
◯ @hazeljs/cron — Scheduled tasks
◯ @hazeljs/websocket — Real-time WebSocket support
◯ @hazeljs/ai — AI/LLM integration
◯ @hazeljs/agent — AI agent runtime
◯ @hazeljs/rag — RAG pipeline
◯ @hazeljs/serverless — Serverless handlers
◯ @hazeljs/discovery — Service discoveryEach selected package gets its own scaffolded configuration. For example, selecting @hazeljs/auth generates a complete JWT auth setup with guards, strategies, and environment variables pre-configured.
All 21 Generators at a Glance
Every generator supports the --path option for custom output directories and the --dry-run flag to preview without writing files.
Core Generators
| Command | Alias | What It Generates |
|---|---|---|
controller | co | REST controller with route decorators |
service | s | Injectable service class |
module | mo | HazelModule with providers & controllers |
dto | d | Data Transfer Object with validation |
guard | gu | Route guard with canActivate |
interceptor | i | Request/response interceptor |
middleware | mi | Express-style middleware |
Advanced Generators
| Command | Alias | What It Generates |
|---|---|---|
crud | cr | Full CRUD: controller + service + DTOs + module |
auth | au | JWT auth service with login/register/validate |
exception-filter | ef | Global exception filter |
pipe | p | Validation/transformation pipe |
repository | r | Data repository pattern |
websocket-gateway | ws | WebSocket gateway with event handlers |
ai-service | ai | AI/LLM service with provider config |
agent | ag | AI agent with tools and memory |
serverless | sl | Serverless function handler |
config | cfg | Typed configuration service |
cache | ca | Cache service with TTL support |
cron | cj | Scheduled cron job |
rag | rg | RAG pipeline with vector store |
discovery | di | Service discovery registration |
CRUD Generator — Full Resources in Seconds
The new crud generator is a game-changer. One command creates a complete REST resource with controller, service, DTOs, and module — all wired together and ready to go.
hazel g crud product
# Creates:
# src/product/product.controller.ts
# src/product/product.service.ts
# src/product/dto/create-product.dto.ts
# src/product/dto/update-product.dto.ts
# src/product/product.module.tsThe generated controller comes with all five standard REST endpoints:
import { Controller, Get, Post, Put, Delete, Injectable } from '@hazeljs/core';
import { ProductService } from './product.service';
import { CreateProductDto } from './dto/create-product.dto';
import { UpdateProductDto } from './dto/update-product.dto';
@Controller('/products')
@Injectable()
export class ProductController {
constructor(private readonly productService: ProductService) {}
@Get()
findAll() {
return this.productService.findAll();
}
@Get('/:id')
findOne(id: string) {
return this.productService.findOne(id);
}
@Post()
create(data: CreateProductDto) {
return this.productService.create(data);
}
@Put('/:id')
update(id: string, data: UpdateProductDto) {
return this.productService.update(id, data);
}
@Delete('/:id')
remove(id: string) {
return this.productService.remove(id);
}
}Package-Specific Generators
Six new generators cover every HazelJS ecosystem package. Each produces production-ready boilerplate that follows the conventions of that package.
Auth Generator
Scaffolds a complete JWT authentication service with login, register, and token validation:
hazel g auth userimport { Injectable } from '@hazeljs/core';
import { AuthService as HazelAuthService, JwtService } from '@hazeljs/auth';
@Injectable()
export class UserAuthService {
constructor(
private readonly authService: HazelAuthService,
private readonly jwtService: JwtService,
) {}
async login(email: string, password: string) {
const user = await this.authService.validateUser(email, password);
if (!user) throw new Error('Invalid credentials');
return { access_token: this.jwtService.sign({ sub: user.id, email }) };
}
async register(data: { email: string; password: string; name?: string }) {
return this.authService.register(data);
}
async validateToken(token: string) {
return this.jwtService.verify(token);
}
}Cache Generator
hazel g cache sessionGenerates a typed cache service with get, set, delete, and clear methods — plus configurable TTL.
Cron Generator
hazel g cron cleanupCreates a cron job service with the @Cron decorator and a default schedule expression.
Config Generator
hazel g config databaseScaffolds a typed configuration service with a validated schema using @hazeljs/config.
RAG Generator
hazel g rag knowledgeCreates a RAG pipeline service with document ingestion, vector store search, and query methods.
Discovery Generator
hazel g discovery paymentScaffolds a service discovery registration that automatically registers your microservice with a discovery server and provides health check endpoints.
Dry-Run Mode
Every generator now supports the --dry-run flag. This lets you preview exactly what files will be created and their contents — without writing anything to disk.
hazel g controller user --dry-run
# Output:
# [dry-run] Would create: src/user/user.controller.ts
# --- File contents ---
# import { Controller, Get, Post, Put, Delete, Injectable } from '@hazeljs/core';
# ...This is particularly useful when you're exploring what a generator produces, or when running in CI pipelines for validation.
Refactored Generator Architecture
Under the hood, all 21 generators now extend a shared Generator base class. This ensures:
- Consistent file naming: Every generator uses the same kebab-case convention with appropriate suffixes (e.g.,
user.controller.ts,user.service.ts) - Shared utilities:
toPascalCase,toKebabCase,toCamelCase, andrenderTemplateare centralized - Uniform options:
--pathand--dry-runwork identically across every generator - Extensibility: Adding new generators is now a matter of extending the base class and providing a template
// The Generator base class pattern
class ControllerGenerator extends Generator {
protected suffix = 'controller';
protected getDefaultTemplate(): string {
return CONTROLLER_TEMPLATE;
}
}
// Usage: one-liner setup
const generator = new ControllerGenerator();
await generator.generate({ name, path: options.path, dryRun: options.dryRun });hazel add — Quick Package Installation
The hazel add command now supports all 14 packages in the HazelJS ecosystem:
# Add individual packages
hazel add swagger
hazel add auth
hazel add cache
hazel add agent
# The command resolves package names automatically:
# "swagger" → npm install @hazeljs/swagger
# "auth" → npm install @hazeljs/auth
# "ai" → npm install @hazeljs/aiBuild Fixes in This Release
This release also fixes a critical build issue that affected the @hazeljs/swagger, @hazeljs/websocket, and @hazeljs/cache packages. The TypeScript compiler was outputting files to dist/src/index.js instead of dist/index.js, causing module resolution failures when these packages were installed as dependencies.
The fix was adding rootDir: "./src" to the tsconfig.json of affected packages, ensuring the compiled output structure matches what package.json declares in its main field.
CI/CD Improvements
The publishing workflow (publish.yml) has been updated to:
- Automatically update the
latestnpm dist-tag after every successful beta publish - Properly handle nested
package.jsonfiles (like@template/package.json) during version bumps - Commit and push version changes before Lerna publish to prevent EUNCOMMIT errors
- Pull with rebase before push to handle concurrent CI runs
Upgrading
Update the CLI and all HazelJS packages to the latest version:
# Update the CLI globally
npm install -g @hazeljs/cli@latest
# Update packages in your project
npm install @hazeljs/core@latest @hazeljs/swagger@latest @hazeljs/auth@latest
# Or update everything at once
npx npm-check-updates -u "@hazeljs/*" && npm installWhat's Next
We're working toward a stable 0.2.0 release. Here's what's on the roadmap:
- Plugin System: Third-party generator plugins for community extensions
- Migration Generator: Database migration scaffolding integrated with Prisma
- Test Generator: Automatic test file generation alongside components
- OpenAPI-to-Code: Generate controllers and DTOs from OpenAPI specifications
Try the new CLI today and let us know what you think. Your feedback drives what we build next.
npm install -g @hazeljs/cli@latest
hazel new my-app --interactive