From 79a25828ee6e8ee60b3efed0dc5622267fa55dc7 Mon Sep 17 00:00:00 2001 From: jenny Date: Tue, 9 Jul 2013 11:20:51 -0500 Subject: [PATCH] Add clean, stage, stage-latest Grunt taks. --- Gruntfile.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ package.json | 1 + 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 49b3855..42cab4b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,12 +7,18 @@ module.exports = function(grunt) { // Project configuration grunt.initConfig({ - // Configs pkg: grunt.file.readJSON('package.json'), + + // timeline configuration timeline: { compiled: 'compiled', website: '../timeline.knightlab.com' }, + + // cdn configuation + cdn: { + path: path.join('..', 'cdn.knightlab.com', 'apps', 'libs', 'timeline') + }, // Banner for the top of CSS and JS files // Note: The existing Timeline repo has its own banner, so we'll ignore this for now @@ -21,19 +27,49 @@ module.exports = function(grunt) { ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' + ' */\n', + // Clean + clean: { + stg: { + options: { force: true }, + src: path.join('<%= cdn.path %>', '<%= pkg.version %>') + }, + stgLatest: { + options: { force: true }, + src: path.join('<%= cdn.path %>', 'latest') + } + }, + // Copy copy: { website: { files: [ // Styles/Themes - { expand: true, cwd: '<%= timeline.compiled %>/css', src: ['*.css', 'themes/**'], dest: '<%= timeline.website %>/static/css'}, - + { expand: true, cwd: '<%= timeline.compiled %>/css', src: ['*.css', 'themes/**'], dest: '<%= timeline.website %>/static/css'}, // Scripts { expand: true, cwd: '<%= timeline.compiled %>/js', src: ['**/*.js'], dest: '<%= timeline.website %>/static/js'}, - // Images { expand: true, cwd: '<%= timeline.compiled %>/css', src: ['*.{png,gif,jpg}'], dest: '<%= timeline.website %>/static/img'} ] + }, + stg: { + files: [ + { + expand: true, + cwd: '<%= timeline.compiled %>', + src: ['css/**', 'js/**', 'lib/**'], + dest: path.join('<%= cdn.path %>', '<%= pkg.version %>') + } + ] + }, + stgLatest: { + files: [ + { + expand: true, + cwd: '<%= timeline.compiled %>', + src: ['css/**', 'js/**', 'lib/**'], + dest: path.join('<%= cdn.path %>', '<%= latest %>') + } + ] } } }); @@ -42,12 +78,16 @@ module.exports = function(grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); // Task aliases - grunt.registerTask('check', 'Check for the timeline.knightlab.com repository', function() { + grunt.registerTask('check-for-cdn', 'Check for the timeline.knightlab.com repository', function() { // Make sure CDN repo exists if(!grunt.file.exists(grunt.config.get('timeline.website'))) { grunt.fatal('Could not find local website repository.') } }); - grunt.registerTask('website', "Copy select files to the timeline.knightlab.com website repository", ['check', 'copy']); + // Define complex tasks + grunt.registerTask('website', "Copy select files to the timeline.knightlab.com website repository", ['check-for-cdn', 'copy:website']); + grunt.registerTask('stage', "Stage the release for deployment to the CDN", ['check-for-cdn', 'clean:stg', 'copy:stg']); + grunt.registerTask('stage-latest', "Stage the release for deployment to the CDN, and copy it to the latest directory", ['stage', 'clean:stgLatest', 'copy:stgLatest']); + }; diff --git a/package.json b/package.json index 71872bb..e8ec603 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "homepage": "https://github.com/NUKnightLab/TimelineJS", "devDependencies": { "grunt": "~0.4.1", + "grunt-contrib-clean": "0.4.0", "grunt-contrib-copy": "~0.4.0", "matchdep": "~0.1.1" }