@ -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' ] ) ;
} ;