From 9b4bfc168132e4821daa4ddb47a760c6cf42a307 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sat, 30 Mar 2013 00:05:50 -0700 Subject: [PATCH] build for CDNJS --- .gitignore | 1 + Gruntfile.js | 45 ++++++++++++++++++++++++++++++++++++++++----- cdn.json | 3 +++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 cdn.json diff --git a/.gitignore b/.gitignore index 9707025..22eff2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ build/out build/archive build/component +build/cdn dist # for npm diff --git a/Gruntfile.js b/Gruntfile.js index e362f5c..5e6a789 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,7 +15,6 @@ module.exports = function(grunt) { // Parse config files var lumbarConfig = grunt.file.readJSON('lumbar.json'); var packageConfig = grunt.file.readJSON('package.json'); - var componentConfig = grunt.file.readJSON('component.json'); var pluginConfig = grunt.file.readJSON('fullcalendar.jquery.json'); // This will eventually get passed to grunt.initConfig() @@ -28,8 +27,8 @@ module.exports = function(grunt) { clean: {} }; - // Combine configs for the "meta" template variable (<%= meta.whatever %>) - config.meta = _.extend({}, packageConfig, componentConfig, pluginConfig); + // Combine certain configs for the "meta" template variable (<%= meta.whatever %>) + config.meta = _.extend({}, packageConfig, pluginConfig); // The "grunt" command with no arguments grunt.registerTask('default', 'archive'); @@ -179,7 +178,7 @@ module.exports = function(grunt) { expand: true, cwd: 'build/out/', src: [ '*.js', '*.css', '!jquery*' ], - dest: 'build/component/', + dest: 'build/component/' }; // copy the component-specific README @@ -190,10 +189,11 @@ module.exports = function(grunt) { // assemble the component's config from existing configs grunt.registerTask('componentConfig', function() { + var config = grunt.file.readJSON('component.json'); grunt.file.write( 'build/component/component.json', JSON.stringify( - _.extend({}, pluginConfig, componentConfig), // combine 2 configs + _.extend({}, pluginConfig, config), // combine 2 configs null, // replacer 2 // indent ) @@ -204,6 +204,41 @@ module.exports = function(grunt) { + /* CDN (http://cdnjs.com/) + ----------------------------------------------------------------------------------------------------*/ + + grunt.registerTask('cdn', 'Build files for CDNJS\'s hosted version of FullCalendar', [ + 'clean:modules', + 'clean:cdn', + 'modules', + 'copy:cdnModules', + 'cdnConfig' + ]); + + config.copy.cdnModules = { + expand: true, + cwd: 'build/out/', + src: [ '*.js', '*.css', '!jquery*' ], + dest: 'build/cdn/<%= meta.version %>/' + }; + + grunt.registerTask('cdnConfig', function() { + var config = grunt.file.readJSON('cdn.json'); + grunt.file.write( + 'build/cdn/package.json', + JSON.stringify( + _.extend({}, pluginConfig, config), // combine 2 configs + null, // replace + 2 // indent + ) + ); + }); + + config.clean.cdn = 'build/cdn/<%= meta.version %>/'; + // NOTE: not a complete clean. also need to manually worry about package.json and version folders + + + // finally, give grunt the config object... grunt.initConfig(config); }; diff --git a/cdn.json b/cdn.json new file mode 100644 index 0000000..903c09a --- /dev/null +++ b/cdn.json @@ -0,0 +1,3 @@ +{ + "filename": "fullcalendar.min.js" +} \ No newline at end of file