Last active
August 29, 2015 14:03
-
-
Save canadaduane/b5d6acc5051462e795d9 to your computer and use it in GitHub Desktop.
Ultimate Update Canvas Script
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
function is_git_dir() { | |
git rev-parse --is-inside-git-dir >/dev/null 2>&1 && [ -d .git ] | |
return $? | |
} | |
function is_canvas_root() { | |
CANVAS_IN_README=$(head -1 README.md 2>/dev/null | grep 'Canvas LMS') | |
[[ "$CANVAS_IN_README" != "" ]] && is_git_dir | |
return $? | |
} | |
function update_canvas() { | |
LOG=`pwd`/update_canvas.log | |
if is_canvas_root; then | |
echo "Bringing Canvas up to date ..." | |
echo " Log file is $LOG" | |
echo >>$LOG | |
echo "-----------------------------" >>$LOG | |
echo "Canvas Update ($(date)):" >>$LOG | |
echo "-----------------------------" >>$LOG | |
# Loop through each plugin dir, and if it's a git repo, update it | |
# This needs to be done first so that db:migrate can pull in any plugin- | |
# precipitated changes to the database. | |
for PLUGIN in vendor/plugins/*; do | |
( | |
cd $PLUGIN | |
if is_git_dir; then | |
echo " Updating plugin $PLUGIN ..." | |
echo " Updating plugin $PLUGIN ..." >>$LOG | |
( git checkout master >>$LOG 2>&1 && \ | |
git pull --rebase >>$LOG 2>&1 ) || \ | |
( echo " failed to pull plugin (see $LOG)"; kill -INT $$ ) | |
fi | |
) | |
done | |
echo " Pulling Canvas code ..." | |
echo " Pulling Canvas code ..." >>$LOG | |
( git checkout master >>$LOG 2>&1 && git pull --rebase >>$LOG 2>&1 ) || \ | |
( echo " failed to pull Canvas (see $LOG)"; kill -INT $$ ) | |
echo " Installing gems (bundle install) ..." | |
echo " Installing gems (bundle install) ..." >>$LOG | |
rm Gemfile.lock* >/dev/null 2>&1 | |
bundle install >>$LOG 2>&1 || \ | |
( echo " failed to bundle install (see $LOG)"; kill -INT $$ ) | |
echo " Migrating DB ..." | |
echo " Migrating DB ..." >>$LOG | |
RAILS_ENV=development bundle exec rake db:migrate >>$LOG 2>&1 || \ | |
( echo " failed to migrate db (development) (see $LOG)"; kill -INT $$ ) | |
RAILS_ENV=test bundle exec rake db:migrate >>$LOG 2>&1 || \ | |
( echo " failed to migrate db (test) (see $LOG)"; kill -INT $$ ) | |
echo " Generating JS ..." | |
echo " Generating JS ..." >>$LOG | |
bundle exec rake js:generate >>$LOG 2>&1 || \ | |
( echo " failed to generate JS (see $LOG)"; kill -INT $$ ) | |
echo " Generating CSS ..." | |
echo " Generating CSS ..." >>$LOG | |
bundle exec rake css:generate >>$LOG 2>&1 || \ | |
( echo " failed to generate CSS (see $LOG)"; kill -INT $$ ) | |
echo " Generating CSS Styleguide ..." | |
echo " Generating CSS Styleguide ..." >>$LOG | |
bundle exec rake css:styleguide >>$LOG 2>&1 || \ | |
( echo " failed to generate Styleguide (see $LOG)"; kill -INT $$ ) | |
echo " Generating Docs ..." | |
echo " Generating Docs ..." >>$LOG | |
bundle exec rake doc:api >>$LOG 2>&1 || \ | |
( echo " failed to generate Docs (see $LOG)"; kill -INT $$ ) | |
echo " Installing npm packages ..." | |
echo " Installing npm packages ..." >>$LOG | |
npm install >>$LOG 2>&1 || \ | |
( echo " failed to install npm packages (see $LOG)"; kill -INT $$ ) | |
echo "Tips:" | |
echo " - 'bundle exec guard': auto-compiles JS files while developing" | |
echo " - 'script/delayed_job run': run delayed jobs in the foreground" | |
else | |
echo "Please run from a Canvas root directory" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment