160 lines
3.7 KiB
Python
160 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Cleanup script for PunimTag project organization.
|
|
|
|
This script removes redundant test files and organizes the project structure.
|
|
"""
|
|
|
|
import os
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
def cleanup_old_tests():
|
|
"""Remove old test files that are now consolidated."""
|
|
old_test_files = [
|
|
"test_syntax_fix.html",
|
|
"test_js_validator.html",
|
|
"test_direct_error_check.html",
|
|
"test_console_tracker.html",
|
|
"test_syntax_check.html",
|
|
"test_progressive.html",
|
|
"test_simple_main.html",
|
|
"test_diagnostic.html",
|
|
"test_minimal.html",
|
|
"debug_ui.html",
|
|
"test_backend.py",
|
|
"test_punimtag.py",
|
|
"test_web_api.py"
|
|
]
|
|
|
|
removed_count = 0
|
|
for file_name in old_test_files:
|
|
file_path = Path(file_name)
|
|
if file_path.exists():
|
|
try:
|
|
file_path.unlink()
|
|
print(f"✅ Removed: {file_name}")
|
|
removed_count += 1
|
|
except Exception as e:
|
|
print(f"❌ Failed to remove {file_name}: {e}")
|
|
|
|
print(f"\n📊 Cleanup complete: {removed_count} files removed")
|
|
|
|
def verify_structure():
|
|
"""Verify that the new structure is properly organized."""
|
|
required_structure = {
|
|
"src/backend/app.py": "Main Flask application",
|
|
"src/backend/db_manager.py": "Database manager",
|
|
"src/backend/visual_identifier.py": "Face recognition",
|
|
"src/utils/tag_manager.py": "Tag management",
|
|
"config/settings.py": "Configuration settings",
|
|
"data/punimtag_simple.db": "Main database",
|
|
"tests/test_main.py": "Main test suite",
|
|
"docs/product.md": "Product vision",
|
|
"docs/structure.md": "Project structure",
|
|
"docs/tech.md": "Technical architecture",
|
|
"docs/api-standards.md": "API standards",
|
|
"docs/testing-standards.md": "Testing standards",
|
|
"docs/code-conventions.md": "Code conventions"
|
|
}
|
|
|
|
print("\n🔍 Verifying project structure:")
|
|
print("=" * 50)
|
|
|
|
all_good = True
|
|
for file_path, description in required_structure.items():
|
|
if Path(file_path).exists():
|
|
print(f"✅ {file_path} - {description}")
|
|
else:
|
|
print(f"❌ {file_path} - {description} (MISSING)")
|
|
all_good = False
|
|
|
|
return all_good
|
|
|
|
def create_gitignore():
|
|
"""Create or update .gitignore file."""
|
|
gitignore_content = """# Python
|
|
__pycache__/
|
|
*.py[cod]
|
|
*$py.class
|
|
*.so
|
|
.Python
|
|
build/
|
|
develop-eggs/
|
|
dist/
|
|
downloads/
|
|
eggs/
|
|
.eggs/
|
|
lib/
|
|
lib64/
|
|
parts/
|
|
sdist/
|
|
var/
|
|
wheels/
|
|
*.egg-info/
|
|
.installed.cfg
|
|
*.egg
|
|
|
|
# Virtual environments
|
|
venv/
|
|
env/
|
|
ENV/
|
|
|
|
# Database files (keep structure, ignore content)
|
|
data/*.db
|
|
data/*.sqlite
|
|
|
|
# Temporary files
|
|
*.tmp
|
|
*.temp
|
|
temp_face_crop_*.jpg
|
|
|
|
# IDE
|
|
.vscode/
|
|
.idea/
|
|
*.swp
|
|
*.swo
|
|
|
|
# OS
|
|
.DS_Store
|
|
Thumbs.db
|
|
|
|
# Logs
|
|
*.log
|
|
|
|
# Environment variables
|
|
.env
|
|
"""
|
|
|
|
with open(".gitignore", "w") as f:
|
|
f.write(gitignore_content)
|
|
|
|
print("✅ Updated .gitignore file")
|
|
|
|
def main():
|
|
"""Main cleanup function."""
|
|
print("🧹 PunimTag Project Cleanup")
|
|
print("=" * 50)
|
|
|
|
# Clean up old test files
|
|
cleanup_old_tests()
|
|
|
|
# Verify structure
|
|
structure_ok = verify_structure()
|
|
|
|
# Update gitignore
|
|
create_gitignore()
|
|
|
|
print("\n" + "=" * 50)
|
|
if structure_ok:
|
|
print("🎉 Project cleanup completed successfully!")
|
|
print("\n📋 Next steps:")
|
|
print("1. Review the steering documents in docs/")
|
|
print("2. Run tests: python tests/test_main.py")
|
|
print("3. Start the app: python main.py")
|
|
else:
|
|
print("⚠️ Project cleanup completed with issues.")
|
|
print("Please check the missing files above.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |