"""Shadow environment setup utilities.""" import shutil from pathlib import Path def setup_shadow_files(target_dir: Path) -> tuple[str, bool, str]: """ Copy shadow files to their target locations if they don't exist. - Copies .env.shadow to .env (if .env doesn't exist) - Copies event.shadow.json to event.json (if event.json doesn't exist) Args: target_dir: Path to the target directory (lambda or fargate) Returns: tuple: (target_name, success, error_message) """ target_name = target_dir.name try: # Copy .env.shadow to .env if .env doesn't exist env_shadow = target_dir / ".env.shadow" env_target = target_dir / ".env" if env_shadow.exists() and not env_target.exists(): shutil.copy2(env_shadow, env_target) # Copy event.shadow.json to event.json if event.json doesn't exist event_shadow = target_dir / "event.shadow.json" event_target = target_dir / "event.json" if event_shadow.exists() and not event_target.exists(): shutil.copy2(event_shadow, event_target) return (target_name, True, "") except Exception as e: return (target_name, False, str(e))