#!/usr/bin/env python3 """ Framework Generator Orchestrator Generates complete framework from configuration file. Usage: python generators/orchestrator.py [--config CONFIG_PATH] Example: python generators/orchestrator.py python generators/orchestrator.py --config custom.config.json """ import argparse import logging import shutil from pathlib import Path from .config_loader import load_config from .structure_generator import StructureGenerator from .model_generator import ModelGenerator from .code_generator import CodeGenerator # Setup logging logging.basicConfig( level=logging.INFO, format='%(message)s' ) logger = logging.getLogger(__name__) def generate_framework(config_path: Path, output_dir: Path): """Generate complete framework from configuration""" logger.info("="*60) logger.info("Framework Generator") logger.info("="*60) # Load configuration logger.info(f"Loading configuration from {config_path}...") config = load_config(config_path) logger.info(f"\nGenerating {config.framework.name.capitalize()}") logger.info(f" {config.framework.tagline}") logger.info(f" Version: {config.framework.version}") logger.info(f"\nOutput directory: {output_dir}") logger.info(f"\nSystems:") for sys in config.systems: logger.info(f" {sys.title} ({sys.name}) - {sys.tagline}") # Generate structure logger.info(f"\n[1/4] Generating folder structure...") struct_gen = StructureGenerator(config, output_dir) struct_gen.generate() # Generate models logger.info(f"\n[2/4] Generating Pydantic models...") model_gen = ModelGenerator(config, output_dir) model_gen.generate() # Generate code logger.info(f"\n[3/4] Generating Python code...") code_gen = CodeGenerator(config, output_dir) code_gen.generate() # Copy templates logger.info(f"\n[4/4] Copying templates...") templates_dir = Path(__file__).parent.parent / "templates" if (templates_dir / "index.html").exists(): shutil.copy(templates_dir / "index.html", output_dir / "index.html") logger.info(f" Copied index.html") if (templates_dir / "requirements.txt").exists(): shutil.copy(templates_dir / "requirements.txt", output_dir / "requirements.txt") logger.info(f" Copied requirements.txt") logger.info(f"\n{'='*60}") logger.info(f"Framework generated successfully!") logger.info(f"{'='*60}\n") logger.info(f"Next steps:") logger.info(f" 1. Review generated files in {output_dir}") logger.info(f" 2. Install dependencies: pip install -r requirements.txt") logger.info(f" 3. Run hub: python {output_dir}/main.py") logger.info(f" 4. Visit http://localhost:{config.framework.hub_port}") def main(): parser = argparse.ArgumentParser( description="Generate framework from configuration" ) parser.add_argument( "--config", default="soleprint.config.json", help="Path to configuration file (default: soleprint.config.json)" ) parser.add_argument( "--output", default=None, help="Output directory (default: same as config directory)" ) args = parser.parse_args() config_path = Path(args.config) if not config_path.exists(): # Try relative to script location script_dir = Path(__file__).parent.parent config_path = script_dir / args.config if not config_path.exists(): logger.error(f"Configuration file not found: {args.config}") return 1 # Output directory defaults to config directory if args.output: output_dir = Path(args.output) else: output_dir = config_path.parent generate_framework(config_path, output_dir) return 0 if __name__ == "__main__": exit(main())