#!/bin/bash
source "$ROOT_PATH"/scripts/common.sh
set -eo pipefail

# Function to handle errors
handle_error() {
    echo_red_bg "Error: $1"
    exit 1
}

# Get the current script directory
script_dir="$( cd ~ && pwd)" || handle_error "failed to get current script directory"

# Search for .zip files in the script directory
zip_file=$(find . -maxdepth 5 -type f -name "*.zip" -print -quit) || handle_error "failed to find .zip files"

if [ -z "$zip_file" ]; then
    handle_error "No .zip file found in $script_dir."
else
    new_name="$script_dir/lambda.zip"
    mv "$zip_file" "$new_name" || handle_error "failed to rename zip file "$zip_file" to "$new_name""
    echo_green "Renamed $zip_file to $new_name"
fi
