The modern, production-ready code generator built with TypeScript and powered by decorators.
Hypergen is a scalable, flexible code generator that helps you create consistent, high-quality code across your projects. Whether you're building React components, API endpoints, or entire application structures, Hypergen provides the tools you need to automate repetitive coding tasks and maintain consistency across your team.
- π― TypeScript-First - Built with TypeScript for type safety and excellent developer experience
- π¨ Decorator-Based Actions - Clean, declarative action definitions using modern decorators
- π YAML Configuration - Intuitive
template.yml
files for generator configuration - π§ Comprehensive CLI - Rich command-line interface with helpful commands and error messages
- π Multiple Sources - Load generators from local files, npm packages, GitHub repos, and more
- β Template Validation - Comprehensive validation with detailed error reporting
- π Rich Documentation - Extensive documentation with examples and best practices
- π Smart Discovery - Automatic discovery of generators from multiple sources
- πΎ Intelligent Caching - Performance optimization through smart caching
- π§ͺ Testing Support - Built-in testing utilities for generator development
# Install globally
npm install -g hypergen
# Or use with npx
npx hypergen --help
# Create a workspace with example generators
hypergen init workspace --withExamples=true
# Discover available generators
hypergen discover
# List available actions
hypergen list
# Get information about an action
hypergen info create-react-component
# Generate a React component
hypergen action create-react-component \
--name=Button \
--type=tsx \
--withTests=true \
--withStories=true
# Create a new generator
hypergen init generator --name=my-widget --framework=react
# Validate the template
hypergen template validate _templates/my-widget/template.yml
# Test your generator
hypergen action my-widget --name=TestWidget
- π Complete Documentation - Comprehensive guides and references
- π Getting Started - Installation and first steps
- π― CLI Reference - All CLI commands and options
- π Template Syntax - EJS template syntax and helpers
- βοΈ Template.yml Reference - Configuration file reference
- π‘ Examples - Real-world examples and patterns
Actions are executable commands defined with TypeScript decorators:
@action({
name: 'create-component',
description: 'Create a React component with tests and stories',
category: 'react'
})
async function createComponent(context: ActionContext): Promise<ActionResult> {
// Generate files, run commands, etc.
return { success: true, message: 'Component created successfully' };
}
EJS-based templates with YAML frontmatter:
---
to: src/components/<%= name %>.tsx
---
import React from 'react';
interface <%= name %>Props {
children?: React.ReactNode;
}
export const <%= name %>: React.FC<<%= name %>Props> = ({ children }) => {
return <div className="<%= h.kebabCase(name) %>">{children}</div>;
};
YAML-based template configuration:
name: create-component
description: Create a React component with TypeScript
version: 1.0.0
category: react
variables:
name:
type: string
required: true
description: Component name
pattern: ^[A-Z][a-zA-Z0-9]*$
withTests:
type: boolean
default: true
description: Generate test files
examples:
- title: Basic Component
description: Create a simple React component
variables:
name: Button
withTests: true
# Discover from all sources
hypergen discover
# Discover from specific sources
hypergen discover local npm github:user/repo
# Show system status
hypergen system status
# Validate specific template
hypergen template validate _templates/my-generator/template.yml
# Show template information
hypergen template info _templates/my-generator/template.yml
# List all templates
hypergen template list _templates
# Resolve GitHub template
hypergen url resolve github:facebook/react/packages/react-scripts
# Resolve npm package
hypergen url resolve npm:@company/generators
# Manage cache
hypergen url cache clear
hypergen url cache info
hypergen/
βββ src/
β βββ actions/ # Action system and execution
β βββ cli/ # CLI interface and commands
β βββ config/ # Configuration and parsing
β βββ discovery/ # Generator discovery
β βββ errors/ # Error handling system
β βββ templates/ # Template processing
βββ docs/ # Documentation
βββ examples/ # Example generators
β βββ _templates/ # Sample generators
βββ tests/ # Test suite
βββ package.json
# Clone the repository
git clone https://github.com/svallory/hypergen.git
cd hypergen
# Install dependencies
bun install
# Run tests
bun test
# Run tests in watch mode
bun test --watch
# Build the project
bun run build
# Run all tests
bun test
# Run specific test file
bun test tests/error-handling.test.ts
# Run tests with coverage
bun test --coverage
# Run integration tests
bun test tests/metaverse.spec.ts
# Start development server
bun run dev
# Run hypergen locally
bun run hygen
# Run built version
bun run hygen:build
# Type checking
bun run tsc
# Linting
bun run lint
# Initialize generator
hypergen init generator --name=react-component --framework=react
# Generate component
hypergen action react-component \
--name=SearchInput \
--withTests=true \
--withStories=true \
--typescript=true
# Initialize generator
hypergen init generator --name=api-endpoint --framework=node
# Generate endpoint
hypergen action api-endpoint \
--name=users \
--methods=GET,POST,PUT,DELETE \
--withAuth=true \
--database=postgresql
# Initialize generator
hypergen init generator --name=feature --framework=generic
# Generate complete feature
hypergen action feature \
--name=UserProfile \
--withFrontend=true \
--withBackend=true \
--withDatabase=true \
--withTests=true
Hypergen is designed for performance with:
- Lazy Loading - Dependencies loaded only when needed
- Intelligent Caching - Template and generator caching
- Parallel Processing - Concurrent file operations
- Efficient Discovery - Fast generator discovery algorithms
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
- TypeScript with strict type checking
- ESLint for code quality
- Prettier for formatting
- Conventional commits for commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with TypeScript
- Powered by EJS templating
- Inspired by Hygen
- Testing with Vitest
- Documentation: Complete Documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Website: https://hypergen.dev
Happy generating! π