Last active
August 29, 2015 14:15
-
-
Save diniremix/9f1a4c115db9c48a8182 to your computer and use it in GitHub Desktop.
a simple script to generate skeletons for Web applications
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/sh | |
PULSEPHP_URL="https://github.com/diniremix/pulsePHP/archive/master.zip" | |
PULSEJS_URL="https://gist.githubusercontent.com/diniremix/8df589843792342197cd/raw/deebde566b25316fc39c8da5a18a4eeb9e88efa4/pulseJS.js" | |
TEST_DIR="./test" | |
APP_DIR="./js" | |
function help(){ | |
echo; | |
echo -e "\e[1;97mpulse\e[0m - a simple script to generate skeletons for Web applications"; | |
echo; | |
echo -e "\e[1;36mUsage example:\e[0m"; | |
echo; | |
echo -e "\e[1;32mstart|-start|--start:\e[0m [(proyect_name)] Generate a web app skel"; | |
echo; | |
echo -e "\e[1;32minstall|-install|--install:\e[0m [(pulsephp)|(pulsejs)|] Download and install the chosen library"; | |
echo; | |
echo -e "\e[1;32mhelp|-help|--help:\e[0m Displays this information."; | |
echo; | |
exit 1; | |
} | |
pulsescript_logo(){ | |
echo -e "Welcome to\e[1;33m | |
_____ _ _____ _ _ | |
| __ \ | | / ____| (_) | | | |
| |__) |_ _ | | ___ ___ | (___ ___ _ __ _ _ __ | |_ | |
| ___/| | | || |/ __| / _ \ \___ \ / __|| '__|| || '_ \ | __| | |
| | | |_| || |\__ \| __/ ____) || (__ | | | || |_) || |_ | |
|_| \__,_||_||___/ \___||_____/ \___||_| |_|| .__/ \__| | |
| | | |
|_| | |
\e[0m V.1.0.0 | |
" | |
} | |
create_proyect_files(){ | |
echo -e "\e[1;33mCreating some Project file...\e[0m" | |
touch $1/{.gitignore,.htaccess,$1.sublime-project,README.md} | |
echo -e '{ | |
"folders": | |
[ | |
{ | |
"path": "'`pwd`'/'$1'" | |
} | |
] | |
}'>>$1/$1.sublime-project | |
} | |
create_app(){ | |
echo -e "initializing \e[1;32m $1 \e[0m project..." | |
#mkdir -pv $1/{app,css,fonts,img,js/app,lib,templates,test} | |
echo -e "Project created in \e[1;36m $(basename "`pwd`")/$1 \e[0m" | |
echo; | |
create_proyect_files $1; | |
echo; | |
echo -e "\e[1;32mNext step:\e[0m \e[1;97mInstall third party libraries\e[0m" | |
} | |
install_apps(){ | |
case "$1" in | |
pulsephp|pulsePHP) | |
if [ ! -f $TEST_DIR/pulsePHP.zip ]; | |
then | |
echo -e "\e[1;32mDownloading pulsePHP...\e[0m" | |
mkdir -pv $TEST_DIR | |
curl -L $PULSEPHP_URL> $TEST_DIR/pulsePHP.zip | |
fi | |
echo; | |
echo -e "\e[1;32mInstalling pulsePHP...\e[0m" | |
unzip -o $TEST_DIR/pulsePHP.zip -d ./app/ | |
echo; | |
echo -e "\e[1;32mRenaming folder for pulsePHP...\e[0m" | |
mv -v ./app/pulsePHP-master ./app/pulsePHP | |
;; | |
pulsejs|pulseJS) | |
if [ ! -f $TEST_DIR/pulseJS.js ]; | |
then | |
echo -e "\e[1;32mDownloading pulseJS...\e[0m" | |
mkdir -pv $TEST_DIR | |
curl -L PULSEJS_URL> $TEST_DIR/pulseJS.js | |
fi | |
echo; | |
echo -e "\e[1;32mInstalling pulseJS...\e[0m" | |
cp -v $TEST_DIR/pulseJS.js ./js/pulseJS.js | |
;; | |
*) | |
echo -e "\e[1;31mError:\e[0m \e[1;97mFailed to install the application or the library is not found.\e[0m" | |
exit 1; | |
;; | |
esac | |
} | |
clear | |
#Bad arguments | |
if [ $? -ne 0 ]; | |
then | |
help; | |
fi | |
#print logo | |
pulsescript_logo; | |
case "$1" in | |
help|-help|--help) | |
help; | |
;; | |
start|-start|--start) | |
create_app $2; | |
;; | |
install|-install|--install) | |
install_apps $2; | |
;; | |
*|-|--) | |
help; | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment