#!/bin/bash

rm -rf /tmp/woocommerce-billink /tmp/woocommerce-billink.zip
printf "Copying files to /tmp \n"
cp -RP . /tmp/woocommerce-billink
cd /tmp/woocommerce-billink
printf "Removing old vendor and git folders \n"
rm -rf ./vendor ./.git ./phpunit.xml.dist ./psalm.xml ./tests
printf "Installing dependencies \n"
composer install --no-dev --optimize-autoloader

rm -rf ./composer.json ./composer.lock 

# Remove the test directories
rm -rf ./vendor/marc-mabe/php-enum/tests/
rm -rf ./vendor/symfony/yaml/Tests/
rm -rf ./vendor/thunderer/serializard/tests/

# Remove the development readme and replace it with the WP one
rm README.md
cp readme.txt README.md

cd ../
zip -rqT woocommerce-billink.zip woocommerce-billink/ && echo "Zip created" || echo "ZIP FAILED"

rm -rf woocommerce-billink/

printf "Done! Archive can be found @ /tmp/woocommerce-billink.zip \n"