
DESC="
# IDEMPOWENT SCRIPT
# creates a prod folder with the latest version of the service
# ready to be sent to the server
# typically: build -> archiever -> deploy_rem
--------------
"

ENV_FOLDER="_prod"
BE_FOLDER="be"
FE_FOLDER="fe"
CONTAINING_BE_FOLDER="boilerplate_backend"
CONTAINING_FE_FOLDER="boilerplate_frontend"
STATE_ETF_FLODER="downloaded_etf"
STATE_DATA_FOLDER="pb_data"

echo "$DESC"

# 1 check if prod folder exists
if [ -d "$ENV_FOLDER" ]; then
    echo "1 prod folder exists removing everything inside"
    rm -rf $ENV_FOLDER/*
else
    echo "1 prod folder does not exist"
    mkdir $ENV_FOLDER
fi

# 2 create structure
echo "2 creating structure inside prod folder"
mkdir $ENV_FOLDER/$BE_FOLDER
mkdir $ENV_FOLDER/$FE_FOLDER

# 3 moving backend
echo "3 moving backend"
cp -r $CONTAINING_BE_FOLDER/* $ENV_FOLDER/$BE_FOLDER/

# 4 remove state from backend
echo "4 removing state from backend"
rm -rf $ENV_FOLDER/$BE_FOLDER/$STATE_ETF_FLODER
rm -rf $ENV_FOLDER/$BE_FOLDER/$STATE_DATA_FOLDER

# 4 moving frontend
echo "4 moving frontend"
cp -r $CONTAINING_FE_FOLDER/* $ENV_FOLDER/$FE_FOLDER/

# 5 copy docker
echo "5 copying docker"
cp -r dockercontainer/* $ENV_FOLDER/





