HazelJS LogoHazelJS
HazelJS v0.2.0-beta.16: Supercharged CLI, 21 Generators & Interactive Scaffolding
HazelJS Blog

HazelJS v0.2.0-beta.16: Supercharged CLI, 21 Generators & Interactive Scaffolding

Author
HazelJS Team
2/8/2026
General
← Back to Blog

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@latest

What'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 Scaffoldinghazel new --interactive with 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.json for 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 --interactive

In 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 discovery

Each 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

CommandAliasWhat It Generates
controllercoREST controller with route decorators
servicesInjectable service class
modulemoHazelModule with providers & controllers
dtodData Transfer Object with validation
guardguRoute guard with canActivate
interceptoriRequest/response interceptor
middlewaremiExpress-style middleware

Advanced Generators

CommandAliasWhat It Generates
crudcrFull CRUD: controller + service + DTOs + module
authauJWT auth service with login/register/validate
exception-filterefGlobal exception filter
pipepValidation/transformation pipe
repositoryrData repository pattern
websocket-gatewaywsWebSocket gateway with event handlers
ai-serviceaiAI/LLM service with provider config
agentagAI agent with tools and memory
serverlessslServerless function handler
configcfgTyped configuration service
cachecaCache service with TTL support
croncjScheduled cron job
ragrgRAG pipeline with vector store
discoverydiService 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.ts

The 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 user
import { 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 session

Generates a typed cache service with get, set, delete, and clear methods — plus configurable TTL.

Cron Generator

hazel g cron cleanup

Creates a cron job service with the @Cron decorator and a default schedule expression.

Config Generator

hazel g config database

Scaffolds a typed configuration service with a validated schema using @hazeljs/config.

RAG Generator

hazel g rag knowledge

Creates a RAG pipeline service with document ingestion, vector store search, and query methods.

Discovery Generator

hazel g discovery payment

Scaffolds 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, and renderTemplate are centralized
  • Uniform options: --path and --dry-run work 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/ai

Build 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 latest npm dist-tag after every successful beta publish
  • Properly handle nested package.json files (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 install

What'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