« All Posts

How We Adopted an Agency-wide Grunt Workflow

#!/bin/bash
command -v lolcat >/dev/null 2>&1 || { echo >&2 "I require lolcat but it's not installed. Run gem install lolcat."; exit 1; }
command -v wp >/dev/null 2>&1 || { echo >&2 "I require Wordpress CLI but it's not installed. ,\n Run the following:,\n curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | bash
."; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 "I require git. For more information, visit: http://git-scm.com/book/en/Getting-Started-Installing-Git "; exit 1; }

purple='\x1B[0;35m'
NC='\x1B[0m' # No Color


echo '

LAUNCHFRAME 0.1 #########
####### A WHITEBOARD TOOL

       !
       !
       ^
      / \
     /___\
    |=   =|
    |     |
    |     |
    |     |
    |     |
    |     |
    |     |
    |     |
    |     |
    |     |
   /|##|##|\
  / |##|##| \
 /  |##|##|  \
|  / ^ | ^ \  |
| /  ( | )  \ |
|/   ( | )   \|
    ((   ))
   ((  :  ))
   ((  :  ))
    ((   ))
     (( ))
      ( )
       .
       .
       .
' | lolcat

if [[ $1 == "" ]]; then
    read -p "Enter the site folder you want to create for installation: " sitefolder
else
    sitefolder=$1
fi

echo -e "${purple}Downloading Wordpress... Please wait a moment.${NC}"

mkdir -p "${sitefolder}" && cd "${sitefolder}"

wp core download

echo -n "Enter database name (press enter for wp_${sitefolder}) "
read dbname
if [[ $dbname == "" ]]; then
    dbname="wp_$sitefolder"
fi

echo -n "Enter database username (press enter for root) "
read dbuser
if [[ $dbuser == "" ]]; then
    dbuser="root"
fi
read -p "Enter database password (required): " dbpass
while [[ $dbpass = "" ]]; do
    read -p "You cannot continue without entering a database password (required): " dbpass
done

echo -n "Enter site url (press enter for http://localhost/${sitefolder}) "
read siteurl
if [[ $siteurl == "" ]]; then
    siteurl="http://localhost/${sitefolder}"
fi

echo -n "Enter site title (press enter for ${sitefolder}) "
read sitetitle
if [[ $sitetitle == "" ]]; then
    sitetitle="${sitefolder}"
fi
echo -n "Enter admin email (press enter for admin@example.com) "
read adminemail
if [[ $adminemail == "" ]]; then
    adminemail="admin@example.com"
fi

echo -e ",\n"
echo -e "${purple}Creating the wp-config file.${NC}"
echo -e ",\n"

wp core config --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass

echo -e ",\n"
echo -e "${purple}Creating the database.${NC}"
echo -e ",\n"

adminpw='[filtered]'
adminun='admin'
wp db create
wp core install --url=$siteurl --title=$sitetitle --admin_name=$adminun --admin_password=$adminpw --admin_email="$adminemail"

echo -n "Install Multiple Post Thumbnails? (y/N) "
read a
if [[ ${a:0:1} == "Y" || ${a:0:1} == "y" ]]; then
    wp plugin install multiple-post-thumbnails
    wp plugin activate multiple-post-thumbnails
else
    echo -e ",\n"
    echo -e "${purple}Run wp plugin install multiple-post-thumbnails to install later.${NC}"
    echo -e ",\n"
fi

echo -n "Install Yoast SEO? (y/N)"
read a
if [[ ${a:0:1} == "Y" || ${a:0:1} == "y" ]]; then
    wp plugin install wordpress-seo
    wp plugin activate wordpress-seo
else
    echo -e ",\n"
    echo -e "${purple}Run wp plugin install wordpress-seo to install later.${NC}"
    echo -e ",\n"
fi

echo -e ",\n"
echo -e "${purple}Downloading Launchframe...${NC}"
echo -e ",\n"

wp theme install https://github.com/Whiteboard/launchframe/archive/master.zip

echo -e ",\n"
echo -e "${purple}Activating Launchframe...${NC}"
echo -e ",\n"

mv wp-content/themes/launchframe-master wp-content/themes/launchframe
wp theme activate launchframe
echo -n "Install Custom Meta Boxes? (y/N)"
read a
if [[ ${a:0:1} == "Y" || ${a:0:1} == "y" ]]; then
  git clone git@github.com:jaredatch/Custom-Metaboxes-and-Fields-for-WordPress.git wp-content/themes/launchframe/inc/cmb
  echo "Custom Meta Boxes requires a manual include and setup - be sure to add this in functions.php or somewhere similar."
fi

cd wp-content/themes/launchframe
npm install


echo -e ",\n"
echo -e "${purple}Opening the site install...${NC}"
echo -e ",\n"

open $siteurl

echo "Done!"
echo '
  ______   _______  _______  _______  _______
(  ___ \ (  ___  )(  ___  )(  ___  )(       )
| (   ) )| (   ) || (   ) || (   ) || () () |
| (__/ / | |   | || |   | || |   | || || || |
|  __ (  | |   | || |   | || |   | || |(_)| |
| (  \ \ | |   | || |   | || |   | || |   | |
| )___) )| (___) || (___) || (___) || )   ( |
|/ \___/ (_______)(_______)(_______)|/     \|


 ' | lolcat
subl ../../..
grunt watch