Skip to content

Commit

Permalink
Merge pull request #1316 from harvesthq/grunt-s3
Browse files Browse the repository at this point in the history
Remove generated assets from repo and add a grunt task to push to S3
  • Loading branch information
pfiller committed Jul 2, 2013
2 parents 3a43166 + 02c0612 commit 771867c
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 2,271 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
node_modules
.project
dist/
public/*.js
public/*.min.css
grunt-aws.json
chosen.zip
39 changes: 38 additions & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ module.exports = (grunt) ->
grunt.file.readJSON("package.json").version
version_tag = ->
"v#{version()}"
version_url = ->
"http://chosen.getharvest.com.s3.amazonaws.com/chosen_#{version_tag()}.zip"
aws = ->
file = 'grunt-aws.json'
if grunt.file.exists file then grunt.file.readJSON file else {}

grunt.initConfig
pkg: grunt.file.readJSON("package.json")
Expand Down Expand Up @@ -64,10 +69,37 @@ module.exports = (grunt) ->

clean:
dist: ["dist/"]
chosen_zip: ["chosen.zip"]

build_gh_pages:
gh_pages: {}

dom_munger:
download_links:
src: 'public/index.html'
options:
callback: ($) ->
$("#latest_version").attr("href", version_url()).text("Stable Version (#{version_tag()})")

zip:
chosen:
cwd: 'public/'
src: ['public/*']
dest: 'chosen.zip'

s3:
options: aws()
master:
upload: [
src: 'chosen.zip'
dest: "chosen_master.zip"
]
latest_version:
upload: [
src: 'chosen.zip'
dest: "chosen_#{version_tag()}.zip"
]

grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-concat'
Expand All @@ -76,10 +108,14 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-css'
grunt.loadNpmTasks 'grunt-build-gh-pages'
grunt.loadNpmTasks 'grunt-zip'
grunt.loadNpmTasks 'grunt-dom-munger'
grunt.loadNpmTasks 'grunt-s3'

grunt.registerTask 'default', ['build']
grunt.registerTask 'build', ['coffee', 'concat', 'uglify', 'cssmin']
grunt.registerTask 'release', ['build', 'package_jquery']
grunt.registerTask 'master-s3', ['build', 'zip:chosen', 's3:master', 'clean:chosen_zip']
grunt.registerTask 'update-s3', ['build', 'zip:chosen', 'dom_munger:download_links', 's3:master', 's3:latest_version', 'package_jquery', 'clean:chosen_zip']
grunt.registerTask 'gh_pages', ['copy:dist', 'build_gh_pages:gh_pages']

grunt.registerTask 'package_jquery', 'Generate a jquery.json manifest file from package.json', () ->
Expand All @@ -91,6 +127,7 @@ module.exports = (grunt) ->
"description": pkg.description
"version": version()
"licenses": pkg.licenses
"download": version_url()
json2 = pkg.jqueryJSON
json1[key] = json2[key] for key of json2
json1.author.name = pkg.author
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
"grunt-css": "~0.5.4",
"grunt-build-gh-pages": "0.0.4"
"grunt-build-gh-pages": "0.0.4",
"grunt-zip": "~0.9.2",
"grunt-dom-munger": "~2.0.1",
"grunt-s3": "~0.2.0-alpha.2"
},
"licenses": [
{
Expand Down
Loading

0 comments on commit 771867c

Please sign in to comment.