CLI
Overview
Section titled “Overview”The GamanJS CLI streamlines your development workflow with commands for development, production builds, and project management:
npx gaman dev # Start development servernpx gaman build # Build for productionnpx gaman start # Run production server
Available Commands
Section titled “Available Commands”npx gaman dev
Section titled “npx gaman dev”Starts the development server with hot reload and debugging features enabled.
npx gaman dev
Features:
- Hot reload on file changes
- Detailed error messages and stack traces
- Development-optimized performance
- Automatic server restart on configuration changes
- Enhanced logging for debugging
Usage:
# Start development servernpx gaman dev
# Development server will typically run on http://localhost:3000# Check console output for the exact URL and port
npx gaman build
Section titled “npx gaman build”Builds your application for production deployment with optimizations.
npx gaman build
Features:
- Code optimization and minification
- Static asset processing
- Production environment configuration
- Bundle analysis and optimization
- Dependency tree optimization
Usage:
# Build for productionnpx gaman build
# Creates optimized build artifacts# Ready for deployment to production servers
npx gaman start
Section titled “npx gaman start”Starts the production server using the built application files.
npx gaman start
Requirements:
- Must run
npx gaman build
first - Requires built production files
Features:
- Production-optimized performance
- Minimal resource usage
- Production logging
- Error handling for production environment
Usage:
# Build firstnpx gaman build
# Then start production servernpx gaman start
npx gaman make:block <name>
Section titled “npx gaman make:block <name>”Generates a new route block to group related routes.
npx gaman make:block user
Features:
- Creates a new block file in the designated
blocks/
directory - Designed to organize routes in logical modules
- Prepares reusable block structure
npx gaman make:routes <name>
Section titled “npx gaman make:routes <name>”Scaffolds a full route tree file for organizing nested or grouped routes.
npx gaman make:routes user
Features:
- Automatically generates boilerplate for a route tree
- Ideal for defining structured API endpoints
- Works well with blocks and children routes
npx gaman make:service <name>
Section titled “npx gaman make:service <name>”Creates a new service class for reusable business logic.
npx gaman make:service user
Features:
- Centralizes reusable operations or logic
- Great for abstracting database, API, or external logic
- Generates file in
services/
directory
npx gaman make:integration <name>
Section titled “npx gaman make:integration <name>”Sets up a new custom integration module (e.g., for third-party services).
npx gaman make:integration stripe
Features:
- Ideal for integrating external APIs or tools
- Generated in the
integrations/
directory - Comes with basic structure for config and methods
npx gaman make:middleware <name>
Section titled “npx gaman make:middleware <name>”Generates a new middleware to intercept requests.
npx gaman make:middleware auth
Features:
- Creates a middleware in the
middleware/
folder - Supports asynchronous logic
- Can be used in block or global context
Development Workflow
Section titled “Development Workflow”Typical Development Process
Section titled “Typical Development Process”# 1. Generate application key (first time setup)npx gaman key:generate
# 2. Start development servernpx gaman dev
# 3. Make changes to your code (hot reload automatically applied)
# 4. When ready for productionnpx gaman build
# 5. Test production build locallynpx gaman start
# 6. Deploy to production server
Environment Setup
Section titled “Environment Setup”# Create .env file with generated keyecho "GAMAN_KEY=your_generated_key_here" > .env
# Start developmentnpx gaman dev
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Command not found:
# Make sure you're in a GamanJS project directory# Verify package.json includes GamanJS as dependencynpm install gaman
Development server won’t start:
# Check if port is already in use# Verify your main application file exists# Check for syntax errors in your codenpx gaman dev --verbose
Build fails:
# Check for TypeScript errors# Verify all dependencies are installed# Review error messages for specific issuesnpm installnpx gaman build
Production server issues:
# Ensure build was completed successfully# Check environment variables are set# Verify production dependencies are installednpx gaman buildnpx gaman start
Tips and Best Practices
Section titled “Tips and Best Practices”- Always generate and set your application key before development
- Use
dev
command during development for better debugging experience - Run
build
before deploying to production - Keep your generated keys secure and never commit them to version control
- Use environment variables for different deployment environments
- Test your production build locally with
start
before deploying
Getting Help
Section titled “Getting Help”# Get help for specific commands (coming soon)npx gaman dev --helpnpx gaman build --helpnpx gaman --help
The CLI tool is actively being developed with more commands and options coming in future releases. Stay tuned for code generation, database management, and advanced deployment tools!