98 lines
3.5 KiB
Python
98 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Phase-46: standalone components — PriceTag, TimeAgo, Address, IconButton."""
|
|
|
|
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 / ".phase46-state.json"
|
|
|
|
FEATURES: list[Feature] = [
|
|
Feature(
|
|
name="price-tag-component",
|
|
description="PriceTag mit Currency-Formatting",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/PriceTag.tsx",
|
|
purpose=(
|
|
"PriceTag-Component. Props: amountCents (number), currency? (default 'EUR'), size?: 'sm'|'md'|'lg'. "
|
|
"Formatiert via Intl.NumberFormat 'de-DE'. Z.B. 1234 → '12,34 €'. "
|
|
"Tailwind. Export default."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="time-ago-component",
|
|
description="TimeAgo relative-time (vor X min)",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/TimeAgo.tsx",
|
|
purpose=(
|
|
"TimeAgo-Component. Props: date (Date|string). "
|
|
"Berechnet diff. Output: 'vor X Sekunden/Minuten/Stunden/Tagen'. "
|
|
"Auto-refresh setInterval 60s. Tailwind. Export default."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="address-component",
|
|
description="Address für mehrteilige Adressen",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/Address.tsx",
|
|
purpose=(
|
|
"Address-Component. Props: street, city, zip, country?. "
|
|
"Mehrzeilig: Street / ZIP City / Country. "
|
|
"Tailwind. Export default."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="icon-button-component",
|
|
description="IconButton (only icon, square, accessible)",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/IconButton.tsx",
|
|
purpose=(
|
|
"IconButton-Component. Props: icon (ReactNode), ariaLabel (required), onClick, variant?: 'ghost'|'solid', size?: 'sm'|'md'|'lg'. "
|
|
"Square button with focus-ring. aria-label gesetzt. "
|
|
"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-46 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-46 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()))
|