"""Generate local Compose secrets once, without printing them.""" from pathlib import Path from secrets import token_hex root = Path(__file__).resolve().parents[1] example = (root / ".env.example").read_text(encoding="utf-8") try: with (root / ".env").open("x", encoding="utf-8", newline="\n") as target: target.write(example.replace("POSTGRES_PASSWORD=\n", f"POSTGRES_PASSWORD={token_hex(24)}\n") .replace("CURSOR_SECRET=\n", f"CURSOR_SECRET={token_hex(32)}\n")) except FileExistsError: print("Using the existing .env") else: print("Created local .env")