EmberClone/scripts/phase45_features.py

98 lines
3.6 KiB
Python

#!/usr/bin/env python3
"""Phase-45: standalone components — Footer, Hint, Loader, NavLink."""
from __future__ import annotations
import asyncio, datetime, json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from phase2_features import Feature, FileGen, ROOT, log, log_section
from phase3_features import run_feature_v2
PHASE_STATE = ROOT / ".phase45-state.json"
FEATURES: list[Feature] = [
Feature(
name="footer-component",
description="Footer mit Copyright + Links",
files=[FileGen(
path="apps/web/src/components/Footer.tsx",
purpose=(
"Footer-Component. Props: links?: array {label, href}, copyright? (default 'EmberClone 2026'). "
"Flex: Copyright links, Links rechts. Border-top + padding. text-sm text-zinc-500. "
"Tailwind. Export default."
),
)],
),
Feature(
name="hint-component",
description="Hint mit Info-Icon",
files=[FileGen(
path="apps/web/src/components/Hint.tsx",
purpose=(
"Hint-Component. Props: children, variant?: 'tip'|'warning'|'note'. "
"Kleine inline box mit Info-Icon (lucide Info/Lightbulb/AlertCircle per variant) + text. "
"bg-blue-50/yellow-50/zinc-50. Tailwind. Export default."
),
)],
),
Feature(
name="loader-component",
description="Loader fullscreen-overlay",
files=[FileGen(
path="apps/web/src/components/Loader.tsx",
purpose=(
"Loader-Component. Props: message? (default 'Wird geladen...'), fullscreen?: boolean. "
"Wenn fullscreen: fixed inset-0 mit backdrop. Sonst: inline-zentriert. "
"Lucide Loader2 animate-spin + message text. Tailwind. Export default."
),
)],
),
Feature(
name="nav-link-component",
description="NavLink mit active-State (Tanstack-Router-kompatibel)",
files=[FileGen(
path="apps/web/src/components/NavLink.tsx",
purpose=(
"NavLink-Component. Props: to, label, icon?. "
"Verwendet @tanstack/react-router Link. activeProps: bg-zinc-100 + font-medium. "
"Hover: bg-zinc-50. Icon optional links. Tailwind. Export default."
),
)],
),
]
def load_state():
if PHASE_STATE.exists():
return json.loads(PHASE_STATE.read_text())
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
def save_state(state):
PHASE_STATE.write_text(json.dumps(state, indent=2))
async def main():
log_section("🚀 Phase-45 Codegen-Run gestartet")
state = load_state()
for feature in FEATURES:
if feature.name in state.get("completed_features", []):
continue
state["current_feature"] = feature.name; save_state(state)
try:
success = await run_feature_v2(feature)
state.setdefault("completed_features" if success else "attempted_features", []).append(feature.name)
save_state(state)
except Exception as e:
log(f"{feature.name} crashed: {e}", level="ERROR")
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
log_section("Phase-45 Run beendet")
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
return 0
if __name__ == "__main__":
sys.exit(asyncio.run(main()))