Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesdlacroix/81564502a9122358310c76730560680c to your computer and use it in GitHub Desktop.
Save jamesdlacroix/81564502a9122358310c76730560680c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
establishDirectories () {
# Create templates directory if it does not exist
mkdir -p $SKETCH_TEMPLATES
# Create plugins directory if it does not exist
mkdir -p $SKETCH_PLUGINS
}
clean () {
# Use mv to test and then switch to rm -rf when directories are correct
mv "$DESIGN_SYSTEM_DESTINATION" "$TRASH"
# Use rm -rf in production
# rm -rf "$DESIGN_SYSTEM_DESTINATION" "$TRASH"
}
install () {
# Symlink design system templates
ln -s "$DESIGN_SYSTEM_SOURCE" "$DESIGN_SYSTEM_DESTINATION"
# Use bin/cp to avoid any permission errors since some terminals have an alias of cp to cp -i.
# Copy plugins
/bin/cp -rf "$PLUGIN_SOURCE" "$SKETCH_PLUGINS"
# Copy fonts
/bin/cp -rf "$FONT_SOURCE"/*.otf "$FONTS_DESTINATION"
}
cleanInstall () {
# Set Source Variables
# TODO Replace "Design System with the name of your design system"
DESIGN_SYSTEM_SOURCE=$1/"Design System"
PLUGIN_SOURCE=$1/Plugins
FONT_SOURCE=$1/Fonts/
# Set Destination Variables
SKETCH_TEMPLATES=$HOME/Library/"Application Support"/com.bohemiancoding.sketch3/Templates
SKETCH_PLUGINS=$HOME/Library/"Application Support"/com.bohemiancoding.sketch3/Plugins
# TODO Replace "Design System with the name of your design system"
DESIGN_SYSTEM_DESTINATION=$SKETCH_TEMPLATES/"Design System"
FONTS_DESTINATION=$HOME/Library/Fonts
DESKTOP=$HOME/Desktop
TRASH=$HOME/.Trash
# Set messaging
# TODO Change your messaging
SUCCESS_TITLE="Inlude your success title here"
SUCCESS_MESSAGE="Include your success message here."
# Make sure directories exist
establishDirectories
# Clean previous installations
clean
# Install the assets
install
# Open Font Book to recognize new fonts
open -a "Font Book"
# Success Message
echo "$SUCCESS_TITLE"
echo "$SUCCESS_MESSAGE"
exit
}
checkCleanInstall () {
# Set variables
GOOGLE_DRIVE_FILE_STREAM_LOCATION=$HOME/"Google Drive File Stream/My Drive"
GOOGLE_DRIVE_LOCATION=$HOME/"Google Drive"
DIRECTORY_FAIL_TITLE="🤔 Hmm…It appears that you haven't added the assets to your drive."
DIRECTORY_FAIL_MESSAGE="Make sure to add the .Design directory to your drive."
DIRECTORY_FAIL_URL="" # TODO Replace with Google Drive directory url
SYNC_FAIL_TITLE="🤔 Hmm…It appears that you haven't installed Google Drive File Stream."
SYNC_FAIL_MESSAGE="Install Google Drive File Stream and add the .Design directory to your drive."
SYNC_FAIL_URL="https://dl.google.com/drive-file-stream/googledrivefilestream.dmg"
# TODO Change all instances to .Design to whatever you name your directory
# Check to see if .Design directory exists in Google Drive File Stream
if [ -e "$GOOGLE_DRIVE_FILE_STREAM_LOCATION" ] && [ -e "$GOOGLE_DRIVE_FILE_STREAM_LOCATION/.Design" ];
then
# .Design directory exists in Google Drive File Stream, proceed with install
cleanInstall "$GOOGLE_DRIVE_FILE_STREAM_LOCATION/.Design"
# Check to see if .Design directory exists in Google Backup & Sync
elif [ -e "$GOOGLE_DRIVE_LOCATION" ] && [ -e "$GOOGLE_DRIVE_LOCATION/.Design" ];
then
# .Design directory exists in Google Backup & Sync, proceed with install
cleanInstall "$GOOGLE_DRIVE_LOCATION/.Design";
elif [ -e "$GOOGLE_DRIVE_FILE_STREAM_LOCATION" ] || [ -e "$GOOGLE_DRIVE_LOCATION" ];
then
echo "$DIRECTORY_FAIL_TITLE"
echo "$DIRECTORY_FAIL_MESSAGE"
echo "$DIRECTORY_FAIL_URL"
else
echo "$SYNC_FAIL_TITLE"
echo "$SYNC_FAIL_MESSAGE"
echo "Google Drive File Stream: $SYNC_FAIL_URL"
echo ".Design Directory: $DIRECTORY_FAIL_URL"
fi
}
checkCleanInstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment