Last active
September 1, 2020 15:33
-
-
Save diedexx/e04596ad682bcbde5da778be271bdffc to your computer and use it in GitHub Desktop.
Run this to get a basic Yoast development setup
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
#!/usr/bin/env bash | |
install(){ | |
if [ "$EUID" -eq 0 ]; then | |
error "This script should not be used as root" | |
exit | |
fi | |
info "Preparing your Mac for development" | |
INSTALLED_SOFTWARE=() | |
FAILED_SOFTWARE=() | |
INSTALLED_PACKAGES=() | |
FAILED_PACKAGES=() | |
INSTALLED_CASKS=() | |
FAILED_CASKS=() | |
INSTALLED_YARN_PACKAGES=() | |
FAILED_YARN_PACKAGES=() | |
# Install Homebrew if it's not already installed | |
if test ! $(which brew); then | |
info "Installing Homebrew" | |
if /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; then | |
success "DONE installing Homebrew" | |
else | |
fail "Failed to install Homebrew. Aborting" | |
exit | |
fi | |
fi | |
info "Updating Homebrew..." | |
if brew update; then | |
success "DONE updating Homebrew" | |
INSTALLED_SOFTWARE+=("Homebrew") | |
else | |
fail "Failed to updaste Homebrew." | |
FAILED_SOFTWARE+=("Homebrew") | |
fi | |
PACKAGES=( | |
zsh | |
zsh-completions | |
autojump | |
nvm | |
bat | |
yarn | |
the_silver_searcher | |
git | |
git-lfs | |
lazygit | |
[email protected] | |
java | |
swagger-codegen | |
redis | |
TomAnthony/brews/itermocil | |
) | |
CASKS=( | |
microsoft-edge | |
firefox | |
google-chrome | |
jetbrains-toolbox | |
postman | |
tableplus | |
typora | |
visual-studio-code | |
spectacle | |
iterm2 | |
slack | |
sublime-text | |
spotify | |
sim-daltonism | |
zoomus | |
java | |
alfred | |
skitch | |
) | |
info "Installing Homebrew packages..." | |
for PACKAGE in "${PACKAGES[@]}" | |
do | |
if brew install ${PACKAGE}; then | |
success "Installed $PACKAGE" | |
INSTALLED_PACKAGES+=($PACKAGE) | |
else | |
fail "Failed to install $PACKAGE" | |
notice "to retry, use:" | |
info "\tbrew install $PACKAGE" | |
FAILED_PACKAGES+=($PACKAGE) | |
fi | |
done | |
info "DONE installing Homebrew packages" | |
info "Cleaning up..." | |
brew cleanup | |
info "DONE cleaning up" | |
info "Installing Homebrew casks..." | |
for CASK in "${CASKS[@]}" | |
do | |
if brew cask install "${CASK[@]}"; then | |
success "Installed $CASK" | |
INSTALLED_CASKS+=($CASK) | |
else | |
fail "Failed to install $CASK" | |
notice "to retry, use:" | |
info "\tbrew cask install $CASK" | |
FAILED_CASKS+=($CASK) | |
fi | |
done | |
info "Finishing git-lfs install" | |
if git lfs install; then | |
success "git-lfs installed" | |
INSTALLED_SOFTWARE+=("git-lfs") | |
else | |
fail "git-lfs installation failed" | |
FAILED_SOFTWARE+=("git-lfs") | |
fi | |
info "Installing global yarn packages..." | |
PACKAGES=( | |
grunt-cli | |
) | |
for PACKAGE in "${PACKAGES[@]}" | |
do | |
if yarn global add ${PACKAGE}; then | |
success "Installed $PACKAGE" | |
INSTALLED_YARN_PACKAGES+=($PACKAGE) | |
else | |
fail "Failed to install $PACKAGE" | |
FAILED_YARN_PACKAGES+=($PACKAGE) | |
fi | |
done | |
success "Done installing yarn packages" | |
if test ! $(which composer); then | |
info "Installing Composer" | |
if curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin; then | |
INSTALLED_SOFTWARE+=("Composer") | |
success "Composer installed" | |
else | |
FAILED_SOFTWARE+=("Composer") | |
success "Composer install failed" | |
fi | |
fi | |
info "Making ~/Dev directory" | |
mkdir ~/Dev | |
success "DONE making ~/Dev directory" | |
info "Installing Medis" | |
if git clone https://github.com/luin/medis ~/Dev/medis; then | |
(cd ~/Dev/medis && yarn && yarn run build) | |
success "Installed medis" | |
INSTALLED_SOFTWARE+=("medis") | |
else | |
fail "Failed to install medis" | |
FAILED_SOFTWARE+=("medis") | |
fi | |
# Yoast.com specific development | |
if ask "Are you going to be working on the Yoast.com project?" N; then | |
info "Cloning yoast.com" | |
if git clone https://github.com/yoast/yoast.com ~/Dev/yoast.com; then | |
success "Cloned yoast.com" | |
INSTALLED_SOFTWARE+=("yoast.com") | |
else | |
fail "Failed to clone yoast.com" | |
FAILED_SOFTWARE+=("yoast.com") | |
fi | |
fi | |
if ask "Are you going to be working on the my-yoast project?" N; then | |
info "Cloning my-yoast" | |
if git clone https://github.com/yoast/my-yoast ~/Dev/my-yoast; then | |
success "Cloned my-yoast" | |
INSTALLED_SOFTWARE+=("my-yoast") | |
else | |
fail "Failed to clone my-yoast" | |
FAILED_SOFTWARE+=("my-yoast") | |
fi | |
fi | |
info "Installing powerline fonts for Oh My Zsh themes like Agnoster" | |
git clone https://github.com/powerline/fonts.git --depth=1 | |
(cd fonts && ./install.sh) | |
rm -rf fonts | |
success "Done Installing powerline fonts for Oh My Zsh themes like Agnoster" | |
# This must be the last step of the installation becuase it opens another shell and pauses this script untill the new shell is stopped with exit. | |
info "Installing Oh My Zsh" | |
if ask "This will open a new shell. Because of this, the current script will pause in the background. You must close that shell using 'exit' for this script to continue. Type 'y' if you understand, 'n' to cancel the Oh My Zsh installation." N; then | |
if sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"; then | |
success "Installed Oh My Zsh" | |
INSTALLED_SOFTWARE+=("Oh my zsh") | |
else | |
fail "Failed installing Oh My Zsh" | |
FAILED_SOFTWARE+=("Oh my zsh") | |
fi | |
else | |
fail "Aborted Oh My Zsh installation" | |
FAILED_SOFTWARE+=("Oh my zsh") | |
fi | |
echo "Adding aliases" | |
echo "alias composer=\"php /usr/local/bin/composer\"" >> $HOME/.zshrc | |
echo "alias cat=\"bat\"" >> $HOME/.zshrc | |
echo "alias zsh=\"vim $HOME/.zshrc\"" >> $HOME/.zshrc | |
echo "alias y=\"yarn\"" >> $HOME/.zshrc | |
echo "alias ci=\"composer install\"" >> $HOME/.zshrc | |
echo "Setting terminal theme" | |
sed -i '' 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/' $HOME/.zshrc | |
echo "\n\n\n\n" | |
success "Your laptop now now ready for development" | |
echo "\n" | |
info "installed software" | |
for line in "${INSTALLED_SOFTWARE[@]}"; do | |
success "$line" | |
done | |
echo "\n" | |
info "Installed Brew packages" | |
for line in "${INSTALLED_PACKAGES[@]}"; do | |
success "$line" | |
done; | |
echo "\n" | |
info "Installed Brew casks" | |
for line in "${INSTALLED_CASKS[@]}"; do | |
success "$line" | |
done; | |
echo "\n" | |
info "Installed Yarn packages (global)" | |
for line in "${INSTALLED_YARN_PACKAGES[@]}"; do | |
success "$line" | |
done; | |
echo "\n\n" | |
info "Not installed software" | |
for line in "${FAILED_SOFTWARE[@]}"; do | |
fail "$line" | |
done; | |
echo "\n" | |
info "Not installed Brew packages" | |
for line in "${FAILED_PACKAGES[@]}"; do | |
fail "$line" | |
done; | |
echo "\n" | |
info "Not installed Brew casks" | |
for line in "${FAILED_CASKS[@]}"; do | |
fail "$line" | |
done; | |
echo "\n" | |
info "Not installed Yarn packages (global)" | |
for line in "${FAILED_YARN_PACKAGES[@]}"; do | |
fail "$line" | |
done; | |
} | |
info () { | |
echo $1 | |
} | |
success() { | |
echo "\033[1;32m \t $1 \033[0m" | |
} | |
fail() { | |
echo "\033[1;31m \t $1 \033[0m" | |
} | |
notice() { | |
echo "\033[1;33m \t $1 \033[0m" | |
} | |
# This is a general-purpose function to ask Yes/No questions in Bash, either | |
# with or without a default answer. It keeps repeating the question until it | |
# gets a valid answer. | |
ask() { | |
# https://djm.me/ask | |
local prompt default reply | |
while true; do | |
if [ "${2:-}" = "Y" ]; then | |
prompt="Y/n" | |
default=Y | |
elif [ "${2:-}" = "N" ]; then | |
prompt="y/N" | |
default=N | |
else | |
prompt="y/n" | |
default= | |
fi | |
# Ask the question (not using "read -p" as it uses stderr not stdout) | |
notice "$1 [$prompt] " | |
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else) | |
read reply </dev/tty | |
# Default? | |
if [ -z "$reply" ]; then | |
reply=$default | |
fi | |
# Check if the reply is valid | |
case "$reply" in | |
Y*|y*) return 0 ;; | |
N*|n*) return 1 ;; | |
esac | |
done | |
} | |
install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment