|
# =================== |
|
# STATUS FEEBACK |
|
# =================== |
|
SEPARATOR = ---------------------------------------------------------- |
|
CHECK = \033[32m✔\033[39m |
|
|
|
# ============== |
|
# EDIT THIS |
|
# ============== |
|
#--------------------------------------------- |
|
# Project Info |
|
PROJECT = |
|
DEV_NAME = |
|
DEV_EMAIL = |
|
APP_VER = 0.1.0 |
|
# APP_SLUG must be all lower case. Only use letters and underscores! |
|
APP_SLUG = |
|
LOCAL_DIR = $$HOME/Dropbox/SITES/${APP_SLUG} |
|
GIT_REPO = git@github.com:lopadz/wp-starter.git |
|
MYSQL_DB = ${APP_SLUG}_wp |
|
MYSQL_USER = root |
|
MYSQL_PASS = |
|
|
|
#--------------------------------------------- |
|
# WordPress Configuration |
|
WP_TITLE = |
|
WP_ADMIN = ${APP_SLUG}_admin |
|
WP_EMAIL = |
|
WP_THEME = main |
|
|
|
#--------------------------------------------- |
|
# WordPress Directories |
|
SUB_DIR = site |
|
WP_DIR = ${LOCAL_DIR}/${SUB_DIR} |
|
WP_PLUGINS_DIR = ${WP_DIR}/wp-content/plugins |
|
WP_THEMES_DIR = ${WP_DIR}/wp-content/themes |
|
|
|
.PHONY: build |
|
|
|
#--------------------------------------------- |
|
# Order of the default build |
|
#--------------------------------------------- |
|
build: valet wordpress done |
|
|
|
|
|
|
|
#--------------------------------------------- |
|
# Creates site folder and add SSL using Valet |
|
#--------------------------------------------- |
|
valet: |
|
@echo "\n${SEPARATOR}" |
|
@echo "Creating a new WordPress website for ${PROJECT}" |
|
@echo "${SEPARATOR}\n" |
|
@mkdir ${LOCAL_DIR} |
|
@valet secure ${APP_SLUG} |
|
@echo "\nCreate directory and serve over https ... ${CHECK} Done \n" |
|
|
|
|
|
|
|
#--------------------------------------------- |
|
# Specifies the order of the WP build |
|
#--------------------------------------------- |
|
wordpress: wp_core wp_plugins wp_starter_theme wp_style wp_index wp_config_local wp_clean wp_install |
|
|
|
#--------------------------------------------- |
|
# Downloads WP Core and custom wp-config.php |
|
#--------------------------------------------- |
|
wp_core: |
|
@mkdir ${WP_DIR} |
|
@wp core download --path=${WP_DIR} --quiet |
|
@wget -q -O ${WP_DIR}/wp-config.php https://gist.githubusercontent.com/lopadz/1670d9566a352e53cc6ef5cf77040738/raw/561bdcae65238cd76cb969fad9ae757e90cfa256/wp-config.php |
|
@chmod 644 ${WP_DIR}/wp-config.php |
|
@echo "Download latest Wordpress version to sub-directory ... ${CHECK} Done\n" |
|
|
|
#--------------------------------------------- |
|
# Downloads useful WP plugins |
|
#--------------------------------------------- |
|
wp_plugins: |
|
@wget -q -O ${WP_PLUGINS_DIR}/acf-pro.zip https://github.com/wp-premium/advanced-custom-fields-pro/archive/master.zip |
|
@wget -q -O ${WP_PLUGINS_DIR}/gravity_forms.zip https://github.com/wp-premium/gravityforms/archive/master.zip |
|
@unzip -q ${WP_PLUGINS_DIR}/acf-pro.zip -d ${WP_PLUGINS_DIR}/ |
|
@unzip -q ${WP_PLUGINS_DIR}/gravity_forms.zip -d ${WP_PLUGINS_DIR}/ |
|
@echo "Download useful plugins... ${CHECK} Done\n" |
|
|
|
#--------------------------------------------- |
|
# Clones starter theme from Github Repo |
|
#--------------------------------------------- |
|
wp_starter_theme: |
|
@git clone -q ${GIT_REPO} ${WP_THEMES_DIR}/${WP_THEME} |
|
@echo "Clone theme from repo and initiate versioning ... ${CHECK} Done\n" |
|
|
|
#--------------------------------------------- |
|
# Creates style.css with data from Vars |
|
#--------------------------------------------- |
|
wp_style: |
|
@printf '%s'\ |
|
'/*!\n'\ |
|
' Theme Name: ${PROJECT}\n'\ |
|
' Author: ${DEV_NAME}\n'\ |
|
' Author URI: mailto:${DEV_EMAIL}\n'\ |
|
' Description: Theme created for ${PROJECT}\n'\ |
|
' Version: 0.1.0\n'\ |
|
'*/\n'\ |
|
>${WP_THEMES_DIR}/${WP_THEME}/style.css |
|
|
|
#--------------------------------------------- |
|
# Creates index.php that points to sub dir |
|
#--------------------------------------------- |
|
wp_index: |
|
@printf "%s"\ |
|
"<?php\n"\ |
|
"/**\n"\ |
|
"* Front to the WordPress application. This file doesn't do anything, but loads\n"\ |
|
"* wp-blog-header.php which does and tells WordPress to load the theme.\n"\ |
|
"*\n"\ |
|
"* @package WordPress\n"\ |
|
"*/\n"\ |
|
"\n"\ |
|
"define( 'WP_USE_THEMES', true );\n"\ |
|
"\n"\ |
|
"/** Loads the WordPress Environment and Template */\n"\ |
|
"require( dirname( __FILE__ ) . '/${SUB_DIR}/wp-blog-header.php' );\n"\ |
|
>${LOCAL_DIR}/index.php |
|
|
|
#--------------------------------------------- |
|
# Creates local wp-config |
|
#--------------------------------------------- |
|
wp_config_local: |
|
@printf "%s"\ |
|
"<?php\n"\ |
|
"/* ==========================\n"\ |
|
" LOCAL WP CONFIGURATION\n"\ |
|
"============================= */\n"\ |
|
"\n"\ |
|
"// MySQL database password.\n"\ |
|
"define( 'DB_NAME', '${MYSQL_DB}' );\n"\ |
|
"\n"\ |
|
"// MySQL database username.\n"\ |
|
"define( 'DB_USER', '${MYSQL_USER}' );\n"\ |
|
"\n"\ |
|
"// MySQL database password.\n"\ |
|
"define( 'DB_PASSWORD', '${MYSQL_PASS}' );\n"\ |
|
"\n"\ |
|
"// MySQL hostname.\n"\ |
|
"define( 'DB_HOST', 'localhost' );\n"\ |
|
"\n"\ |
|
"// Maximum Post Revisions.\n"\ |
|
"define( 'WP_POST_REVISIONS', 3 );\n"\ |
|
"\n"\ |
|
"// WordPress Database Table prefix.\n"\ |
|
"\044table_prefix = 'wp_\ |
|
$(shell openssl rand -hex 12 |md5 | head -c5; echo)_';\n"\ |
|
"\n"\ |
|
"// For developers: WordPress debugging mode.\n"\ |
|
"define( 'WP_DEBUG', false );\n"\ |
|
"\n"\ |
|
"// The Database Collate type. Don't change this if in doubt.\n"\ |
|
"define( 'DB_COLLATE', '' );\n"\ |
|
>${WP_DIR}/wp-config-local.php |
|
|
|
#--------------------------------------------- |
|
# Cleans WP install from unnecessary files |
|
#--------------------------------------------- |
|
wp_clean: |
|
@rm -rf ${WP_PLUGINS_DIR}/akismet |
|
@rm -f ${WP_PLUGINS_DIR}/hello.php |
|
@rm -f ${WP_PLUGINS_DIR}/acf-pro.zip |
|
@rm -f ${WP_PLUGINS_DIR}/gravity_forms.zip |
|
@rm -rf ${WP_THEMES_DIR}/twentyfifteen |
|
@rm -rf ${WP_THEMES_DIR}/twentyseventeen |
|
@rm -rf ${WP_THEMES_DIR}/twentysixteen |
|
@rm -rf ${WP_THEMES_DIR}/${WP_THEME}/.git/ |
|
@rm -f ${WP_THEMES_DIR}/${WP_THEME}/.gitignore |
|
@echo "Clean up installation files ... ${CHECK} Done\n" |
|
|
|
#--------------------------------------------- |
|
# Install WP using wp-cli |
|
#--------------------------------------------- |
|
wp_install: |
|
@wp db create --path=${WP_DIR} |
|
@wp core install --path=${WP_DIR} --title=${WP_TITLE} --url=https://${APP_SLUG}.test --admin_name=${WP_ADMIN} --admin_email=${WP_EMAIL} --skip-email |
|
@wp option update siteurl https://${APP_SLUG}.test/${SUB_DIR} --path=${WP_DIR} |
|
@wp theme activate ${WP_THEME} --path=${WP_DIR} |
|
@wp rewrite structure "/%postname%/" --path=${WP_DIR} |
|
@echo "\nConfigure Wordpress ... ${CHECK} Done\n" |
|
|
|
|
|
|
|
#--------------------------------------------- |
|
# Opens VS Code and echoes the login URL |
|
#--------------------------------------------- |
|
done: |
|
@code ${LOCAL_DIR} |
|
@echo "Your WP site is ready! Log in here: https://${APP_SLUG}.test/wp-admin\n" |
|
|
|
|
|
|
|
#--------------------------------------------- |
|
# Use this to run tests |
|
#--------------------------------------------- |
|
test: |
|
|