Refactor website with new design & structure

This commit is contained in:
Andrew Miner
2016-04-03 19:30:15 -07:00
parent ec7e8c883d
commit d69585facd
406 changed files with 7411 additions and 37859 deletions
-27
View File
@@ -1,27 +0,0 @@
#!/bin/bash
USAGE=<<END
USAGE: all <command>
Executes a command for this project and each project related to this one.
Related projects must include this project's name as a prefix in their name
to be considered related.
END
COMMAND="$1"
[[ "$COMMAND" == "" ]] && echo $USAGE && exit 1
SRC_ROOT="/src"
BASE_NAME=$(basename $PWD)
pushd $SRC_ROOT &>/dev/null
for MODULE in $(ls | grep "$BASE_NAME"); do
cd "$SRC_ROOT/$MODULE"
if [[ -e './scripts/unpublished' ]]; then
./scripts/unpublished
fi
done
popd &>/dev/null
+14 -43
View File
@@ -1,51 +1,22 @@
#!/bin/bash
USAGE=<<END
function die {
echo $*
exit 1
}
END
if [[ -e "./aws.config" ]]; then
export AWS_CONFIG_FILE="./aws.config"
else
export AWS_CONFIG_FILE="$HOME/.aws/config"
fi
SOURCE_DIR="./dist/"
SITE="crafting-guide.com"
TARGET=""
ENVIRONMENT=""
while [[ "$1" != "" ]]; do
case "$1" in
"--staging") TARGET="staging";;
"--production") TARGET="production";;
"--staging") ENVIRONMENT="staging";;
"--prod") ENVIRONMENT="prod";;
*) die "Please specify environment: --staging or --prod";;
esac
shift
done
if [[ "$TARGET" == "" ]]; then
echo "Please choose either --staging or --production for the target."
exit 1
fi
if [[ "$TARGET" == "staging" ]]; then
TARGET_DIR="s3://new.$SITE/"
BUILD_CMD="build"
elif [[ "$TARGET" == "production" ]]; then
TARGET_DIR="s3://$SITE/"
BUILD_CMD="dist"
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
if grunt clean $BUILD_CMD; then
echo "Preparing to upload to S3..."
s3cmd sync -r -P --add-header="cache-control:max-age=1800" $SOURCE_DIR $TARGET_DIR
echo "S3 Upload Complete"
else
echo "ERROR: Building distribution failed. Aborting deployment!"
exit 1
fi
git push \
&& git checkout $ENVIRONMENT \
&& git rebase master \
&& git push \
&& git checkout master \
|| die "Could not publish changes"
+4 -11
View File
@@ -5,19 +5,12 @@ function die {
exit 1
}
read -p "Major, minor, patch? " VERSION_TYPE
if [[ "$VERSION_TYPE" == "" ]]; then
exit 1
VERSION_TYPE=""
while [[ "$VERSION_TYPE" != "major" && "$VERSION_TYPE" != "minor" && "$VERSION_TYPE" != "patch" ]]; then
read -p "Major, minor, patch? " VERSION_TYPE
fi
npm version "$VERSION_TYPE" || die "Invalid version type: $VERSION_TYPE"
npm publish
git push \
&& git checkout production \
&& git rebase master \
&& git push \
&& git checkout master \
|| die "Could not publish changes"
grunt clean build
grunt clean build
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
if [[ -e "./aws.config" ]]; then
export AWS_CONFIG_FILE="./aws.config"
else
export AWS_CONFIG_FILE="$HOME/.aws/config"
fi
ENVIRONMENT=""
while [[ "$1" != "" ]]; do
case "$1" in
"--staging") ENVIRONMENT="staging";;
"--production") ENVIRONMENT="production";;
*) die "Please specify environment: --staging or --production";;
esac
done
SOURCE_DIR="./dist/"
SITE="new.crafting-guide.com"
[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com"
TARGET_DIR="s3://$SITE/"
S3CMD_CFG="$HOME/.s3cfg"
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"
HEADERS="--add-header=cache-control:max-age=1800"
GZIP="--add-header=content-encoding:gzip"
CMD="sync $SOURCE_DIR $TARGET_DIR -r -P $HEADERS --exclude=*"
echo "Preparing to upload to S3..."
s3cmd $CMD $GZIP -m 'text/css; charset=utf8' --include="*.css"
s3cmd $CMD $GZIP -m 'text/html; charset=utf8' --include="*.html"
s3cmd $CMD $GZIP -m 'text/javascript; charset=utf8' --include="*.js"
s3cmd $CMD $GZIP -m 'application/json' --include="*.json"
s3cmd $CMD -m 'audio/mpeg3' --include="*.mp3"
s3cmd $CMD -m 'image/png' --include="*.png"
echo "S3 Upload Complete"
-64
View File
@@ -1,64 +0,0 @@
#!/usr/bin/env coffee
#
# Crafting Guide - serve-build
#
# Copyright (c) 2014-2015 by Redwood Labs
# All rights reserved.
#
express = require 'express'
fs = require 'fs'
path = require 'path'
########################################################################################################################
ROOT = './dist'
DATA_ROOT = '../crafting-guide-data'
PRERENDER_ROOT = '../crafting-guide-prerender/static'
CONTENT_TYPE = {
'.cg': 'text/plain'
'.css': 'text/css'
'.html': 'text/html'
'.js': 'text/javascript'
'.json': 'application/json'
'.map': 'application/json'
'.png': 'image/png'
'.ttf': 'application/octet-stream'
'.scss': 'text/css'
}
########################################################################################################################
app = express()
serveIndex = (request, response)->
response.set 'Content-Type', 'text/html'
filePath = "#{request.path}index.html".replace('index.htmlindex.html', 'index.html')
fs.stat "#{PRERENDER_ROOT}#{filePath}", (err, stats)->
if not err?
console.log ">>> #{request.path} ==> #{PRERENDER_ROOT}#{filePath}"
response.sendFile filePath, root:PRERENDER_ROOT
else
console.log ">>> #{request.path} ==> #{ROOT}/app.html"
response.sendFile '/app.html', root:ROOT
serveData = (request, response)->
response.set 'Content-Type', CONTENT_TYPE[path.extname request.path]
console.log ">>> #{request.path} ==> #{DATA_ROOT}#{request.path}"
response.sendFile request.path, root:DATA_ROOT
app.get '/data/*', serveData
app.get '/craft/*', serveIndex
app.get '/login', serveIndex
app.get '*.html', serveIndex
app.get '*/$', serveIndex
app.get '*', (request, response)->
response.set 'Content-Type', CONTENT_TYPE[path.extname request.path]
console.log ">>> #{request.path} ==> #{ROOT}#{request.path}"
response.sendFile request.path, root:ROOT
server = app.listen 8000, '127.0.0.1', ->
console.log "listening at: #{server.address().address}:#{server.address().port}"
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
pushd './build/' &>/dev/null
clear
nodemon ./server.coffee $*
echo ''
popd &>/dev/null
-27
View File
@@ -1,27 +0,0 @@
#!/bin/bash
MODULE=$(basename $PWD)
QUIET="NO"
while [[ "$1" != "" ]]; do
case "$1" in
"-q") QUIET="YES";;
esac
shift
done
CHANGES=$(git log --oneline production..master | while read LINE; do echo " $LINE"; done)
if [[ "$CHANGES" != "" ]]; then
printf "\nUndeployed changes for $MODULE:\n$CHANGES\n\n"
elif [[ "$QUIET" == "NO" ]]; then
printf "No undeployed changes for $MODULE\n\n"
fi
VERSION=$(cat package.json | grep "version" | sed 's/.*"version": "\(.*\)",$/\1/')
CHANGES=$(git log --oneline "v$VERSION"..master | while read LINE; do echo " $LINE"; done)
if [[ "$CHANGES" != "" ]]; then
printf "\nUnpublished NPM module changes for $MODULE:\n$CHANGES\n\n"
else
printf "No unpublished NPM module changes for $MODULE\n\n"
fi