Skip to content

cuesoftinc/open-source-project-generator

Open Source Project Generator v2.0

πŸŽ‰ New in v2.0: Tool-Orchestration Architecture - Leverage industry-standard CLI tools for always up-to-date project generation!

A modern command-line tool that generates production-ready project structures by orchestrating industry-standard CLI tools (create-next-app, go mod init, etc.) with intelligent fallback generation.

πŸš€ What's New in v2.0?

Tool-Orchestration Architecture

Instead of maintaining templates, v2.0 delegates project generation to official framework tools:

  • Next.js: Uses create-next-app for latest Next.js projects
  • Go: Uses go mod init and official Go tooling
  • Android/iOS: Uses native tooling when available, falls back to minimal generation
  • Always Current: Get the latest framework versions automatically

Key Improvements

  • βœ… No Template Maintenance: Framework tools handle updates
  • βœ… Better Quality: Official tools generate best-practice code
  • βœ… Enhanced Logging: Comprehensive file logging with timestamps
  • βœ… Automatic Backups: Rollback on failure
  • βœ… Beautiful Output: Colored terminal output with status symbols
  • βœ… Security Scanning: Post-generation security checks
  • βœ… Offline Support: Works without internet after initial setup

πŸ“¦ Installation

# Using Go
go install github.com/cuesoftinc/open-source-project-generator/cmd/generator@latest

# From source
git clone https://github.com/cuesoftinc/open-source-project-generator
cd open-source-project-generator
make build

# Verify installation
generator --version

🎯 Quick Start

1. Check Your Environment

# Verify required tools are installed
generator check-tools

# Output:
# βœ“ npx (v10.2.3) - Available
# βœ“ go (v1.21.0) - Available
# βœ— gradle - Not found
#   Install: https://gradle.org/install/

2. Generate Configuration

# Create a configuration template
generator init-config --output project.yaml

3. Customize Configuration

Edit project.yaml:

name: my-awesome-app
description: My full-stack application
output_dir: ./my-awesome-app

components:
  - type: nextjs
    name: web-app
    enabled: true
    config:
      typescript: true
      tailwind: true
      app_router: true

  - type: go-backend
    name: api-server
    enabled: true
    config:
      module: github.com/user/my-awesome-app
      framework: gin

integration:
  generate_docker_compose: true
  generate_scripts: true
  api_endpoints:
    backend: http://localhost:8080

options:
  use_external_tools: true
  create_backup: true
  verbose: false

4. Preview Generation

# Dry-run to see what will be generated
generator generate --config project.yaml --dry-run

5. Generate Project

# Generate your project
generator generate --config project.yaml

# Output:
# ═══════════════════════════════════════════════════════════════════
# Step 1/11: Validating configuration...
# βœ“ Configuration validation passed
# Step 2/11: Applying default configuration values...
# βœ“ Defaults applied successfully
# ...
# ═══════════════════════════════════════════════════════════════════
# PROJECT GENERATION COMPLETED
# ═══════════════════════════════════════════════════════════════════
# βœ“ Project generated successfully in 45.2s
# Project Name: my-awesome-app
# Location: ./my-awesome-app
# Components: 2

πŸ—οΈ Generated Project Structure

my-awesome-app/
β”œβ”€β”€ App/                    # Next.js frontend (generated by create-next-app)
β”‚   β”œβ”€β”€ app/               # App router
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”œβ”€β”€ public/            # Static assets
β”‚   β”œβ”€β”€ package.json       # Dependencies
β”‚   └── next.config.js     # Next.js configuration
β”œβ”€β”€ CommonServer/          # Go backend (generated by go mod init)
β”‚   β”œβ”€β”€ cmd/               # Application entry points
β”‚   β”œβ”€β”€ internal/          # Private application code
β”‚   β”œβ”€β”€ pkg/               # Public packages
β”‚   β”œβ”€β”€ go.mod             # Go modules
β”‚   └── main.go            # Main application
β”œβ”€β”€ Mobile/                # Mobile applications
β”‚   β”œβ”€β”€ android/           # Android project (Gradle/Kotlin)
β”‚   └── ios/               # iOS project (Xcode/Swift)
β”œβ”€β”€ Deploy/                # Infrastructure
β”‚   β”œβ”€β”€ docker/            # Docker configurations
β”‚   └── k8s/               # Kubernetes manifests
β”œβ”€β”€ .logs/                 # Generation logs
β”œβ”€β”€ docker-compose.yml     # Docker Compose configuration
β”œβ”€β”€ .env                   # Environment variables
β”œβ”€β”€ README.md              # Project documentation
β”œβ”€β”€ TROUBLESHOOTING.md     # Troubleshooting guide
β”œβ”€β”€ build.sh               # Build script
β”œβ”€β”€ dev.sh                 # Development script
└── prod.sh                # Production script

πŸ“– Usage Examples

Full-Stack Web Application

# fullstack.yaml
name: fullstack-app
output_dir: ./fullstack-app

components:
  - type: nextjs
    name: web-app
    enabled: true
    config:
      typescript: true
      tailwind: true

  - type: go-backend
    name: api-server
    enabled: true
    config:
      module: github.com/user/fullstack-app
      framework: gin

integration:
  generate_docker_compose: true
  generate_scripts: true
generator generate --config fullstack.yaml

Mobile Application with Backend

# mobile-app.yaml
name: mobile-app
output_dir: ./mobile-app

components:
  - type: android
    name: mobile-android
    enabled: true
    config:
      package: com.user.mobileapp
      language: kotlin

  - type: ios
    name: mobile-ios
    enabled: true
    config:
      bundle_id: com.user.mobileapp
      language: swift

  - type: go-backend
    name: api-server
    enabled: true
    config:
      module: github.com/user/mobile-app
      framework: gin

integration:
  generate_docker_compose: true
  api_endpoints:
    backend: http://localhost:8080
generator generate --config mobile-app.yaml

Frontend Only

# frontend.yaml
name: my-frontend
output_dir: ./my-frontend

components:
  - type: nextjs
    name: web-app
    enabled: true
    config:
      typescript: true
      tailwind: true
      app_router: true

integration:
  generate_docker_compose: false
  generate_scripts: true
generator generate --config frontend.yaml

πŸ› οΈ Commands

Core Commands

# Generate projects
generator generate --config project.yaml    # Generate from configuration
generator generate --config project.yaml --dry-run  # Preview without creating files

# Environment validation
generator check-tools                       # Check tool availability

# Configuration
generator init-config --output project.yaml # Generate configuration template

Command Options

# Generation options
--config <file>          # Configuration file path (required)
--dry-run                # Preview generation without creating files
--verbose                # Enable detailed logging
--no-external-tools      # Force fallback generation
--create-backup          # Create backup before generation
--stream-output          # Stream tool output in real-time
--force-overwrite        # Overwrite existing directories

# Output options
--output <dir>           # Override output directory from config
--log-level <level>      # Set log level (debug, info, warn, error)

πŸ”§ Configuration Reference

Component Types

Type Description Bootstrap Tool Fallback Available
nextjs Next.js frontend create-next-app No
go-backend Go backend API go mod init No
android Android mobile app gradle Yes
ios iOS mobile app xcodebuild Yes

Component Configuration

Next.js Component:

- type: nextjs
  name: web-app
  enabled: true
  config:
    typescript: true      # Use TypeScript
    tailwind: true        # Include Tailwind CSS
    app_router: true      # Use App Router
    eslint: true          # Include ESLint

Go Backend Component:

- type: go-backend
  name: api-server
  enabled: true
  config:
    module: github.com/user/project  # Go module path
    framework: gin                    # Framework (gin, echo, chi)
    database: postgres                # Database (postgres, mysql, sqlite)

Android Component:

- type: android
  name: mobile-android
  enabled: true
  config:
    package: com.user.app    # Package name
    language: kotlin         # Language (kotlin, java)
    min_sdk: 24             # Minimum SDK version

iOS Component:

- type: ios
  name: mobile-ios
  enabled: true
  config:
    bundle_id: com.user.app  # Bundle identifier
    language: swift          # Language (swift, objc)
    deployment_target: 15.0  # Minimum iOS version

Integration Options

integration:
  generate_docker_compose: true    # Generate docker-compose.yml
  generate_scripts: true           # Generate build/run scripts
  api_endpoints:
    backend: http://localhost:8080 # Backend API endpoint
    auth: http://localhost:8081    # Auth service endpoint

Generation Options

options:
  use_external_tools: true   # Use bootstrap tools (recommended)
  create_backup: true        # Create backup before generation
  verbose: false             # Enable verbose logging
  stream_output: false       # Stream tool output in real-time
  force_overwrite: false     # Overwrite existing directories
  disable_parallel: false    # Disable parallel component generation

πŸ”’ Security Features

Input Sanitization

  • All user inputs sanitized before processing
  • Path traversal attack prevention
  • Project name validation

Security Scanning

  • Post-generation security scan
  • Detection of exposed secrets
  • Identification of insecure configurations
  • Security report generation

Tool Execution Safety

  • Whitelisted tools and flags only
  • Command injection prevention
  • Timeout protection
  • Sandboxed execution

Backup and Rollback

  • Automatic backups before generation
  • Rollback on failure
  • Backup restoration
  • Cleanup of partial generations

πŸ“Š Logging and Monitoring

File Logging

All operations are logged to files:

# Log file location
./my-project/.logs/generation-20240101-120000.log

# Log format
[INFO] 2024-01-01 12:00:00 Starting project generation | project=my-app
[DEBUG] 2024-01-01 12:00:01 Sanitizing project name: my-app
[INFO] 2024-01-01 12:00:02 Tool discovery completed | component=nextjs
[INFO] 2024-01-01 12:00:05 Component generated successfully | component=web-app type=nextjs method=bootstrap duration=3.2s

Console Output

Beautiful, colored terminal output:

═══════════════════════════════════════════════════════════════════
PROJECT GENERATION COMPLETED
═══════════════════════════════════════════════════════════════════
βœ“ Project generated successfully in 45.2s
Project Name: my-awesome-app
Location: ./my-awesome-app
Components: 2

─────────────────────────────────────────────────────
Generated Components
─────────────────────────────────────────────────────
βœ“ web-app (nextjs) - bootstrap
βœ“ api-server (go-backend) - bootstrap

─────────────────────────────────────────────────────
Next Steps
─────────────────────────────────────────────────────
  β€’ Navigate to: cd ./my-awesome-app
  β€’ Review the README.md for detailed instructions
  β€’ Run with Docker: docker-compose up
  β€’ Run development mode: ./dev.sh

Log File: ./my-awesome-app/.logs/generation-20240101-120000.log

🚨 Troubleshooting

Tool Not Found

Error: Required tool 'npx' not found

Solution:
# Install Node.js (includes npx)
brew install node  # macOS
sudo apt-get install nodejs npm  # Ubuntu

Generation Failed

Error: Component generation failed: nextjs

Solution:
1. Check the log file for details
2. Verify tool versions: generator check-tools
3. Try with verbose logging: --verbose
4. Use fallback generation: --no-external-tools

Permission Denied

Error: failed to create directory: permission denied

Solution:
# Ensure write permissions
chmod +w ./output-directory
# Or use a different output directory
generator generate --config project.yaml --output ~/projects/my-app

πŸ“š Documentation

πŸ”„ Migrating from v1.x

If you're upgrading from v1.x, see the Migration Guide for detailed instructions.

Quick migration steps:

  1. Backup existing projects
  2. Install required tools (generator check-tools)
  3. Convert configuration (template β†’ components)
  4. Test with dry-run (--dry-run)
  5. Generate new project

🀝 Contributing

We welcome contributions! Please see our Contributing Guide.

Development Setup

# Clone repository
git clone https://github.com/cuesoftinc/open-source-project-generator
cd open-source-project-generator

# Install dependencies
go mod download

# Build
make build

# Run tests
make test

# Run linter
make lint

# Check for version updates
make check-versions

# Update to latest versions
make update-versions

Version Management

All dependency versions are centrally managed in configs/versions.yaml. This provides a single source of truth for all framework and tool versions used in generated projects.

See configs/VERSIONS.md for details.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ Acknowledgments

  • Built with Go
  • Uses Cobra for CLI
  • Leverages official framework tools for generation
  • Community feedback and contributions

Ready to generate your next project? Start with generator check-tools to verify your environment!

About

Project Generator Template for Open-Source Projects

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •