Browse Source

Add clean, stage, stage-latest Grunt taks.

pull/512/head
jenny 12 years ago
parent
commit
79a25828ee
  1. 50
      Gruntfile.js
  2. 1
      package.json

50
Gruntfile.js

@ -7,13 +7,19 @@ module.exports = function(grunt) {
// Project configuration // Project configuration
grunt.initConfig({ grunt.initConfig({
// Configs
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
// timeline configuration
timeline: { timeline: {
compiled: 'compiled', compiled: 'compiled',
website: '../timeline.knightlab.com' 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 // 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 // Note: The existing Timeline repo has its own banner, so we'll ignore this for now
banner: '/* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + banner: '/* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
@ -21,19 +27,49 @@ module.exports = function(grunt) {
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
' */\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
copy: { copy: {
website: { website: {
files: [ files: [
// Styles/Themes // 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 // Scripts
{ expand: true, cwd: '<%= timeline.compiled %>/js', src: ['**/*.js'], dest: '<%= timeline.website %>/static/js'}, { expand: true, cwd: '<%= timeline.compiled %>/js', src: ['**/*.js'], dest: '<%= timeline.website %>/static/js'},
// Images // Images
{ expand: true, cwd: '<%= timeline.compiled %>/css', src: ['*.{png,gif,jpg}'], dest: '<%= timeline.website %>/static/img'} { 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); require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Task aliases // 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 // Make sure CDN repo exists
if(!grunt.file.exists(grunt.config.get('timeline.website'))) { if(!grunt.file.exists(grunt.config.get('timeline.website'))) {
grunt.fatal('Could not find local website repository.') 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']);
}; };

1
package.json

@ -5,6 +5,7 @@
"homepage": "https://github.com/NUKnightLab/TimelineJS", "homepage": "https://github.com/NUKnightLab/TimelineJS",
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-contrib-clean": "0.4.0",
"grunt-contrib-copy": "~0.4.0", "grunt-contrib-copy": "~0.4.0",
"matchdep": "~0.1.1" "matchdep": "~0.1.1"
} }

Loading…
Cancel
Save