EmberClone/scripts/phase41_features.py

98 lines
3.6 KiB
Python

#!/usr/bin/env python3
"""Phase-41: standalone components — PageHeader, StatCard, ToolbarButton, Kbd."""
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 / ".phase41-state.json"
FEATURES: list[Feature] = [
Feature(
name="page-header-component",
description="PageHeader mit Title + Actions",
files=[FileGen(
path="apps/web/src/components/PageHeader.tsx",
purpose=(
"PageHeader-Component. Props: title (string), subtitle?, actions?: ReactNode, breadcrumb?: ReactNode. "
"Flex layout: links title + subtitle, rechts actions. Border-bottom + padding. "
"Tailwind. Export default."
),
)],
),
Feature(
name="stat-card-component",
description="StatCard für Dashboards",
files=[FileGen(
path="apps/web/src/components/StatCard.tsx",
purpose=(
"StatCard-Component. Props: label, value (string|number), icon?, change?: number (für trend %), unit?. "
"Card-Layout: Icon oben-links, label grau klein, value groß bold, optional trend mit grün/rot Pfeil. "
"Tailwind. Export default."
),
)],
),
Feature(
name="toolbar-button-component",
description="ToolbarButton mit Tooltip + Icon",
files=[FileGen(
path="apps/web/src/components/ToolbarButton.tsx",
purpose=(
"ToolbarButton-Component. Props: icon (ReactNode), label, onClick, active?, disabled?. "
"Quadratischer Button mit Icon. Tooltip via title attribute. "
"Active: bg-blue-100 ring-blue. Tailwind. Export default."
),
)],
),
Feature(
name="kbd-component",
description="Kbd für Keyboard-Shortcut-Display",
files=[FileGen(
path="apps/web/src/components/Kbd.tsx",
purpose=(
"Kbd-Component. Props: children (key text wie 'Ctrl' oder 'K'). "
"Kleiner styled <kbd> mit bg-zinc-100 dark:bg-zinc-700, border, rounded, px-1.5 py-0.5, mono, text-xs. "
"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-41 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-41 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()))