Convert site to a single JavaScript archive

* Convert build to use a single JavaScript file on the site (instead
  of downloading each library separately). This also means that all
  global variables (e.g., `$` for JQuery, `_` for Underscore.js) can
  be removed.
* Remove unused scripts and/or move them to a more appropriate repo
* Update the `deploy` script to work with CircleCI's automation
* Update markdown display code to allow images to be located with the
  markdown data files instead of the pre-rendered index pages
This commit is contained in:
Andrew Miner
2015-04-29 19:58:53 -07:00
parent 414017f689
commit 930b8049a2
60 changed files with 195 additions and 359 deletions
+25 -17
View File
@@ -1,32 +1,40 @@
#!/bin/bash
export AWS_CONFIG_FILE="aws.config"
if [[ -e "./aws.config" ]]; then
export AWS_CONFIG_FILE="./aws.config"
else
export AWS_CONFIG_FILE="$HOME/.aws/config"
fi
ROOT="./dist"
SOURCE_DIR="./dist/"
SITE="crafting-guide.com"
TARGET=""
while [[ "$1" != "" ]]; do
case "$1" in
"--new") TARGET="new";;
"--promote") TARGET="promote";;
"--staging") TARGET="staging";;
"--production") TARGET="production";;
esac
shift
done
if [[ "$TARGET" == "" ]]; then
echo "Please choose either --new or --promote for the target."
exit
echo "Please choose either --staging or --production for the target."
exit 1
fi
if [[ "$TARGET" == "new" ]]; then
find . -name ".DS_Store" 2>/dev/null | xargs rm &>/dev/null
if grunt dist; then
echo "Preparing to upload to S3..."
s3cmd sync -r --add-header="cache-control:max-age=1800" "$ROOT/" "s3://new.$SITE/"
grunt clean:dist build
else
echo "Aborting deployment"
fi
elif [[ "$TARGET" == "promote" ]]; then
aws s3 sync "s3://new.$SITE" "s3://$SITE" --delete
if [[ "$TARGET" == "staging" ]]; then
TARGET_DIR="s3://new.$SITE/"
elif [[ "$TARGET" == "production" ]]; then
TARGET_DIR="s3://$SITE/"
fi
S3CMD_CFG="$HOME/.s3cfg"
if [[ ! -e "$S3CMD_CFG" ]]; then
echo "[default]" > "$S3CMD_CFG"
cat $AWS_CONFIG_FILE | grep "aws_access_key_id" | sed "s/aws_access_key_id/access_key/" >> "$S3CMD_CFG"
cat $AWS_CONFIG_FILE | grep "aws_secret_access_key" | sed "s/aws_secret_access_key/secret_key/" >> "$S3CMD_CFG"
fi
echo "Preparing to upload to S3..."
s3cmd sync -r --add-header="cache-control:max-age=1800" $SOURCE_DIR $TARGET_DIR
echo "S3 Upload Complete"