Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build production-ready Spring Boot 3.x applications with REST APIs, Security, Data JPA, and Actuator
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/validate.py
1#!/usr/bin/env python32"""3Validation script for java-spring-boot skill.4Category: general5"""67import os8import sys9import yaml10import json11from pathlib import Path121314def validate_config(config_path: str) -> dict:15"""16Validate skill configuration file.1718Args:19config_path: Path to config.yaml2021Returns:22dict: Validation result with 'valid' and 'errors' keys23"""24errors = []2526if not os.path.exists(config_path):27return {"valid": False, "errors": ["Config file not found"]}2829try:30with open(config_path, 'r') as f:31config = yaml.safe_load(f)32except yaml.YAMLError as e:33return {"valid": False, "errors": [f"YAML parse error: {e}"]}3435# Validate required fields36if 'skill' not in config:37errors.append("Missing 'skill' section")38else:39if 'name' not in config['skill']:40errors.append("Missing skill.name")41if 'version' not in config['skill']:42errors.append("Missing skill.version")4344# Validate settings45if 'settings' in config:46settings = config['settings']47if 'log_level' in settings:48valid_levels = ['debug', 'info', 'warn', 'error']49if settings['log_level'] not in valid_levels:50errors.append(f"Invalid log_level: {settings['log_level']}")5152return {53"valid": len(errors) == 0,54"errors": errors,55"config": config if not errors else None56}575859def validate_skill_structure(skill_path: str) -> dict:60"""61Validate skill directory structure.6263Args:64skill_path: Path to skill directory6566Returns:67dict: Structure validation result68"""69required_dirs = ['assets', 'scripts', 'references']70required_files = ['SKILL.md']7172errors = []7374# Check required files75for file in required_files:76if not os.path.exists(os.path.join(skill_path, file)):77errors.append(f"Missing required file: {file}")7879# Check required directories80for dir in required_dirs:81dir_path = os.path.join(skill_path, dir)82if not os.path.isdir(dir_path):83errors.append(f"Missing required directory: {dir}/")84else:85# Check for real content (not just .gitkeep)86files = [f for f in os.listdir(dir_path) if f != '.gitkeep']87if not files:88errors.append(f"Directory {dir}/ has no real content")8990return {91"valid": len(errors) == 0,92"errors": errors,93"skill_name": os.path.basename(skill_path)94}959697def main():98"""Main validation entry point."""99skill_path = Path(__file__).parent.parent100101print(f"Validating java-spring-boot skill...")102print(f"Path: {skill_path}")103104# Validate structure105structure_result = validate_skill_structure(str(skill_path))106print(f"\nStructure validation: {'PASS' if structure_result['valid'] else 'FAIL'}")107if structure_result['errors']:108for error in structure_result['errors']:109print(f" - {error}")110111# Validate config112config_path = skill_path / 'assets' / 'config.yaml'113if config_path.exists():114config_result = validate_config(str(config_path))115print(f"\nConfig validation: {'PASS' if config_result['valid'] else 'FAIL'}")116if config_result['errors']:117for error in config_result['errors']:118print(f" - {error}")119else:120print("\nConfig validation: SKIPPED (no config.yaml)")121122# Summary123all_valid = structure_result['valid']124print(f"\n==================================================")125print(f"Overall: {'VALID' if all_valid else 'INVALID'}")126127return 0 if all_valid else 1128129130if __name__ == "__main__":131sys.exit(main())132