Kibana default tasks

This commit is contained in:
Rashid Khan 2013-11-14 21:26:20 -07:00 committed by Boaz Leskes
parent da4a6412fb
commit e8d20fe781
8 changed files with 86 additions and 81 deletions

View file

@ -4,91 +4,37 @@ module.exports = function (grunt) {
var config = {
pkg: grunt.file.readJSON('package.json'),
kibanaDir: 'kibana',
baseDir: './kibana',
srcDir: 'kibana/src',
destDir: 'dist',
tempDir: 'tmp',
meta: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= pkg.license %> */\n\n'
},
clean: {
on_start: ['<%= destDir %>', '<%= tempDir %>'],
temp: ['<%= tempDir %>'],
setup: ['<%= kibanaDir %>']
},
gitclone: {
kibana: {
options: {
repository: 'https://github.com/elasticsearch/kibana.git'
}
}
},
copy: {
// copy source to temp, we will minify in place for the dist build
marvel_config: {
cwd: '.',
src: ['config.js'],
dest: '<%= kibanaDir %>/src/'
}
},
tempDir: 'tmp'
};
// Run jshint
grunt.registerTask('default', [
]);
grunt.registerTask('setup', [
'clean:setup',
'gitclone:kibana',
'copy:marvel_config'
]);
// Concat and Minify the src directory into dist
grunt.registerTask('build', [
'jshint:source',
'clean:on_start',
'less:dist',
'copy:everything_but_less_to_temp',
'htmlmin:build',
'cssmin:build',
'ngmin:build',
'requirejs:build',
'clean:temp',
'build:write_revision',
'uglify:dest'
]);
// build, then zip and upload to s3
grunt.registerTask('distribute', [
'distribute:load_s3_config',
'build',
'compress:zip',
'compress:tgz',
's3:dist',
'clean:temp'
]);
// build, then zip and upload to s3
grunt.registerTask('release', [
'distribute:load_s3_config',
'build',
'compress:zip_release',
'compress:tgz_release',
's3:release',
'clean:temp'
]);
// load plugins
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-git');
grunt.loadNpmTasks('grunt-symlink');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-compress');
require('load-grunt-tasks')(grunt);
// load task definitions
grunt.loadTasks('tasks');
// Utility function to load plugin settings into config
function loadConfig(config,path) {
require('glob').sync('*', {cwd: path}).forEach(function(option) {
var key = option.replace(/\.js$/,'');
// If key already exists, extend it. It is your responsibility to avoid naming collisions
config[key] = config[key] || {};
grunt.util._.extend(config[key], require(path + option)(config));
});
// technically not required
return config;
}
// Merge that object with what with whatever we have here
loadConfig(config,'./tasks/options/');
if (grunt.file.exists('kibana')) {
grunt.loadTasks('kibana/tasks');
loadConfig(config,'./kibana/tasks/options/');
}
// pass the config to grunt
grunt.initConfig(config);

View file

@ -17,7 +17,20 @@
"grunt-contrib-clean": "~0.5.0",
"grunt-string-replace": "~0.2.4",
"grunt-contrib-compress": "~0.5.2",
"grunt-git": "~0.1.6"
"grunt-git": "~0.1.6",
"grunt-s3": "~0.2.0-alpha.2",
"grunt-ngmin": "0.0.3",
"grunt-contrib": "~0.8.0",
"grunt-contrib-less": "~0.7.0",
"grunt-git-describe": "~2.3.2",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-angular-templates": "~0.3.12",
"grunt-contrib-uglify": "~0.2.4",
"load-grunt-tasks": "~0.2.0",
"glob": "~3.2.7"
},
"license": "Apache License"
}

4
tasks/default_task.js Normal file
View file

@ -0,0 +1,4 @@
module.exports = function(grunt) {
grunt.registerTask('default', [
]);
};

7
tasks/options/clean.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = function(config) {
return {
on_start: ['<%= destDir %>', '<%= tempDir %>'],
temp: ['<%= tempDir %>'],
setup: ['<%= kibanaDir %>']
};
};

10
tasks/options/copy.js Normal file
View file

@ -0,0 +1,10 @@
module.exports = function(config) {
return {
// copy source to temp, we will minify in place for the dist build
marvel_config: {
cwd: '.',
src: ['config.js'],
dest: '<%= kibanaDir %>/src/'
}
};
};

View file

@ -0,0 +1,9 @@
module.exports = function(config) {
return {
kibana: {
options: {
repository: 'https://github.com/elasticsearch/kibana.git'
}
}
};
};

9
tasks/options/meta.js Normal file
View file

@ -0,0 +1,9 @@
module.exports = function(config) {
return {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= pkg.license %> */\n\n'
};
};

7
tasks/setup_task.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = function(grunt) {
grunt.registerTask('setup', [
'clean:setup',
'gitclone:kibana',
'copy:marvel_config'
]);
};