From 0b273b4d9dbc3720c78677ef90f3e2afdfb31ff3 Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Mon, 4 Apr 2016 20:07:34 -0700 Subject: [PATCH] Speed up build/deployment by using symlinked image --- Gruntfile.coffee | 27 ++++++++++----------------- circle.yml | 1 + package.json | 1 + scripts/s3_upload | 13 +++++++++---- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 27234a10..d8d0627a 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -21,18 +21,7 @@ module.exports = (grunt)-> {expand: true, cwd:'./data', src:'**/*.cg', dest:'./dist/data'} ] - copy: - data: - files: [ - {expand:true, cwd:'./data', src:'**/*', dest:'./build/data'} - ] - build_to_dist: - files: [ - {expand:true, cwd:'./build', src:'**/*', dest:'./dist'} - ] - clean: - build: ['./build'] dist: ['./dist'] mochaTest: @@ -47,6 +36,13 @@ module.exports = (grunt)-> verbose: true src: ['./test/**/*.test.coffee'] + symlink: + images: + files: [ + {expand:true, cwd:'./data', src:'**/*.png', dest:'./dist/data'} + ] + + watch: data_files: files: ['./data/**/*.cg'] @@ -54,23 +50,20 @@ module.exports = (grunt)-> # Compound Tasks ################################################################################################### - grunt.registerTask 'build', 'build the project to be run from a local server', - ['copy:data'] - grunt.registerTask 'default', 'run tests to verify data files', ['test'] grunt.registerTask 'dist', 'build the project to be run from Amazon S3', - ['build', 'copy:build_to_dist', 'compress'] + ['clean', 'symlink:images', 'compress'] grunt.registerTask 'test', 'run unit tests', ['mochaTest'] grunt.registerTask 'upload:prod', 'upload the project to the production Amazon S3 environment', - ['dist', 'script:s3_upload:prod'] + ['script:s3_upload:prod'] grunt.registerTask 'upload:staging', 'upload the project the staging Amazon S3 environment', - ['dist', 'script:s3_upload:staging'] + ['script:s3_upload:staging'] # Code Tasks ####################################################################################################### diff --git a/circle.yml b/circle.yml index 5626698f..ea55ce94 100644 --- a/circle.yml +++ b/circle.yml @@ -6,5 +6,6 @@ deployment: all: branch: master commands: + - grunt dist - grunt upload:prod - grunt upload:staging diff --git a/package.json b/package.json index 7dede420..347bf254 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "grunt-contrib-clean": "^1.0.0", "grunt-contrib-compress": "^1.2.0", "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-symlink": "^1.0.0", "grunt-contrib-watch": "^0.6.1", "grunt-mocha-test": "^0.12.7", "mocha": "^2.2.4", diff --git a/scripts/s3_upload b/scripts/s3_upload index 70ef6065..a7861c0b 100755 --- a/scripts/s3_upload +++ b/scripts/s3_upload @@ -1,5 +1,10 @@ #!/bin/bash +function die { + echo $* + exit 1 +} + if [[ -e "./aws.config" ]]; then export AWS_CONFIG_FILE="./aws.config" else @@ -10,15 +15,15 @@ ENVIRONMENT="" while [[ "$1" != "" ]]; do case "$1" in "--staging") ENVIRONMENT="staging";; - "--production") ENVIRONMENT="production";; - *) die "Please specify environment: --staging or --production";; + "--prod") ENVIRONMENT="prod";; + *) die "Please specify environment: --staging or --prod";; esac shift done SOURCE_DIR="./dist/" SITE="staging.crafting-guide.com" -[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com" +[[ "$ENVIRONMENT" == "prod" ]] && SITE="crafting-guide.com" TARGET_DIR="s3://$SITE/" S3CMD_CFG="$HOME/.s3cfg" @@ -28,7 +33,7 @@ cat $AWS_CONFIG_FILE | grep "aws_secret_access_key" | sed "s/aws_secret_access_k HEADERS="--add-header=cache-control:max-age=1800" GZIP="--add-header=content-encoding:gzip" -CMD="sync $SOURCE_DIR $TARGET_DIR -r -P $HEADERS --stop-on-error --exclude=*" +CMD="sync $SOURCE_DIR $TARGET_DIR -r -F -P $HEADERS --stop-on-error --exclude=*" echo "Preparing to upload to S3..." s3cmd $CMD -m 'image/png' --include="*.png" || exit 1