Commit 31c010c5 by spenceralger

Merge pull request #514 from spenceralger/gruntfile-cleanup

Cleaned up the Grunt config a bit, removed an unneeded dep
parents c767ae66 412cefed
...@@ -170,6 +170,9 @@ module.exports = function (grunt) { ...@@ -170,6 +170,9 @@ module.exports = function (grunt) {
}, },
s3: { s3: {
dist: { dist: {
bucket: 'download.elasticsearch.org',
access: 'private',
// debug: true, // uncommment to prevent actual upload
upload: [ upload: [
{ {
src: '<%= tempDir %>/dist.zip', src: '<%= tempDir %>/dist.zip',
...@@ -180,71 +183,56 @@ module.exports = function (grunt) { ...@@ -180,71 +183,56 @@ module.exports = function (grunt) {
} }
}; };
var fs = require('fs'); // setup the modules require will build
var requireModules = [ var requireModules = config.requirejs.compile_temp.options.modules = [
{ {
// main/common module // main/common module
name: 'app', name: 'app',
include: [ include: [
'css',
'kbn', 'kbn',
'text',
'jquery', 'jquery',
'underscore',
'angular', 'angular',
'settings',
'bootstrap', 'bootstrap',
'modernizr', 'modernizr',
'jquery', 'elasticjs',
'angular-sanitize',
'timepicker', 'timepicker',
'datepicker', 'datepicker',
'elasticjs', 'underscore',
'angular-strap',
'directives/all',
'filters/all', 'filters/all',
'services/all',
'jquery.flot', 'jquery.flot',
'services/all',
'angular-strap',
'directives/all',
'jquery.flot.pie', 'jquery.flot.pie',
'text', 'angular-sanitize'
'settings'
] ]
} }
]; ];
// create a module for each directory in src/app/panels/ // create a module for each directory in src/app/panels/
fs.readdirSync(config.srcDir+'/app/panels').forEach(function (panelName) { require('fs')
requireModules.push({ .readdirSync(config.srcDir+'/app/panels')
name: 'panels/'+panelName+'/module', .forEach(function (panelName) {
exclude: ['app'] requireModules.push({
name: 'panels/'+panelName+'/module',
exclude: ['app']
});
}); });
});
// exclude the literal config definition from all modules // exclude the literal config definition from all modules
requireModules.forEach(function (module) { requireModules
module.excludeShallow = module.excludeShallow || []; .forEach(function (module) {
module.excludeShallow.push('config'); module.excludeShallow = module.excludeShallow || [];
}); module.excludeShallow.push('config');
});
config.requirejs.compile_temp.options.modules = requireModules;
// load plugins
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-ngmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-git-describe');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-requirejs');
// Project configuration. // Run jshint
grunt.initConfig(config); grunt.registerTask('default', ['jshint:source', 'less:src']);
// Default task. // Concat and Minify the src directory into dist
grunt.registerTask('default', ['jshint:source','less:src']);
grunt.registerTask('build', [ grunt.registerTask('build', [
'jshint:source', 'jshint:source',
'clean:on_start', 'clean:on_start',
...@@ -255,29 +243,12 @@ module.exports = function (grunt) { ...@@ -255,29 +243,12 @@ module.exports = function (grunt) {
'ngmin', 'ngmin',
'requirejs:compile_temp', 'requirejs:compile_temp',
'clean:temp', 'clean:temp',
'write_revision_to_dest', // runs git-describe and replace:config 'build:write_revision',
'uglify:dest' 'uglify:dest'
]); ]);
grunt.registerTask('distribute', [ // run a string replacement on the require config, using the latest revision number as the cache buster
'load_s3_config', grunt.registerTask('build:write_revision', function() {
'build',
'zip:dist',
's3:dist',
'clean:temp'
]);
grunt.registerTask('load_s3_config', function () {
var config = grunt.file.readJSON('.aws-config.json');
grunt.config('s3.options', {
key: config.key,
secret: config.secret,
bucket: 'download.elasticsearch.org',
access: 'private'
});
});
grunt.registerTask('write_revision_to_dest', function() {
grunt.event.once('git-describe', function (desc) { grunt.event.once('git-describe', function (desc) {
grunt.config('string-replace.config', { grunt.config('string-replace.config', {
src: '<%= destDir %>/app/components/require.config.js', src: '<%= destDir %>/app/components/require.config.js',
...@@ -297,4 +268,40 @@ module.exports = function (grunt) { ...@@ -297,4 +268,40 @@ module.exports = function (grunt) {
grunt.task.run('git-describe'); grunt.task.run('git-describe');
}); });
// build, then zip and upload to s3
grunt.registerTask('distribute', [
'distribute:load_s3_config',
'build',
'zip:dist',
's3:dist',
'clean:temp'
]);
// collect the key and secret from the .aws-config.json file, finish configuring the s3 task
grunt.registerTask('distribute:load_s3_config', function () {
var config = grunt.file.readJSON('.aws-config.json');
grunt.config('s3.options', {
key: config.key,
secret: config.secret
});
});
// load plugins
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-ngmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-git-describe');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-requirejs');
// pass the config to grunt
grunt.initConfig(config);
}; };
\ No newline at end of file
...@@ -6,24 +6,24 @@ ...@@ -6,24 +6,24 @@
"name": "kibana", "name": "kibana",
"version": "3.0.0m3pre", "version": "3.0.0m3pre",
"devDependencies": { "devDependencies": {
"rjs-build-analysis": "0.0.3",
"grunt": "~0.4.0", "grunt": "~0.4.0",
"grunt-s3": "~0.2.0-alpha.2",
"grunt-zip": "~0.9.2",
"grunt-ngmin": "0.0.3",
"grunt-contrib": "~0.7.0", "grunt-contrib": "~0.7.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-less": "~0.7.0", "grunt-contrib-less": "~0.7.0",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-ngmin": "0.0.3",
"cssmin": "~0.4.1",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-copy": "~0.4.1", "grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.1", "grunt-git-describe": "~2.3.2",
"grunt-contrib-clean": "~0.5.0", "grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-contrib-uglify": "~0.2.4", "grunt-contrib-uglify": "~0.2.4",
"rjs-build-analysis": "0.0.3", "grunt-contrib-jshint": "~0.6.0",
"grunt-angular-templates": "~0.3.12",
"grunt-string-replace": "~0.2.4", "grunt-string-replace": "~0.2.4",
"grunt-git-describe": "~2.3.2", "grunt-contrib-htmlmin": "~0.1.3",
"grunt-zip": "~0.9.2", "grunt-contrib-requirejs": "~0.4.1",
"grunt-s3": "~0.2.0-alpha.2" "grunt-angular-templates": "~0.3.12"
}, },
"license": "Apache License" "license": "Apache License"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment