Created
June 8, 2017 08:44
-
-
Save Kovah/3bde87799457cbb139b0eba48c871549 to your computer and use it in GitHub Desktop.
InvoicePlane build script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
# InvoicePlane download package build script | |
# v0.0.1 | |
# | |
# Usage | |
# ./build-ipv1.sh [-l|-b branch|-f filename.zip] | |
## | |
# Parse arguments | |
while [[ $# -gt 1 ]] | |
do | |
ARGKEY="$1" | |
case $ARGKEY in | |
-l) | |
CLONE_FILESYSTEM=true | |
;; | |
-b) | |
BRANCH="$2" | |
shift | |
;; | |
-f) | |
FILENAME="$2" | |
shift | |
;; | |
esac | |
shift | |
done | |
# Start building | |
echo "BUILD INVOICEPLANE v1" && sleep 1 | |
cd ~/.invoiceplane/ | |
# Initial cleanup | |
[[ -d ip ]] && rm -rf ip || : | |
[[ -d langs ]] && rm -rf langs || : | |
[[ -e fusioninvoice.zip ]] && rm -f fusioninvoice.zip || : | |
[[ -e ip.zip ]] && rm -f ip.zip || : | |
# Clone the repo | |
if [[ "$CLONE_FILESYSTEM" == true ]] | |
then | |
git clone /Users/kg/htdocs/InvoicePlane/dev-v1 ip && cd ip | |
else | |
git clone git@github.com:InvoicePlane/InvoicePlane.git ip && cd ip | |
fi | |
# Checkout branch if applicable | |
if [[ -n "$BRANCH" ]] | |
then | |
git checkout "$BRANCH" | |
fi | |
echo "=======================================================" | |
echo "INSTALL DEPENDENCIES" && sleep 1 | |
composer install | |
npm install | |
echo "=======================================================" | |
echo "BUILD ASSETS" && sleep 1 | |
grunt build | |
echo "=======================================================" | |
echo "REMOVING JUNK" && sleep 1 | |
# Delete npm dependencies | |
rm -rf node_modules | |
# Delete all .DS_Store files | |
find . -type f -name '.DS_Store' -delete | |
# Delete unneeded mPDF assets | |
find vendor/mpdf/mpdf/ttfonts ! -name 'DejaVu*' -type f -exec rm -f {} + | |
rm -rf vendor/mpdf/mpdf/src/QrCode/data/* | |
# Delete all .git folders | |
find . -name '.git' -type d -exec rm -rf {} + | |
# Delete unneeded Codeigniter files | |
cd vendor/codeigniter/framework && find . -maxdepth 1 ! -name 'system' ! -name '.' ! -name '..' -exec rm -rf {} + | |
echo "=======================================================" | |
echo "UPDATING LANGUAGES" && sleep 1 | |
cd ~/.invoiceplane | |
wget https://crowdin.com/download/project/fusioninvoice.zip | |
unzip -q fusioninvoice.zip -d langs | |
cp -rf 'langs/ar/Arabic' 'ip/application/language/Arabic' | |
cp -rf 'langs/ca/Catalan' 'ip/application/language/Catalan' | |
cp -rf 'langs/cs/Czech' 'ip/application/language/Czech' | |
cp -rf 'langs/da/Danish' 'ip/application/language/Danish' | |
cp -rf 'langs/de/German' 'ip/application/language/German' | |
# Many more languages are bing copied here, stripped for readability | |
echo "=======================================================" | |
echo "PREPARING PACKAGE" && sleep 1 | |
if [[ -n "$FILENAME" ]] | |
then | |
zip -q -r -8 "$FILENAME" ip/* | |
else | |
zip -q -r -8 ip.zip ip/* | |
fi | |
# Cleanup | |
rm -rf ip | |
rm -rf langs | |
rm -f fusioninvoice.zip | |
echo "=======================================================" | |
echo "FINISHED!" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment