mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Moved plugin to a subfolder
Tweaked build system to allow serving both marvel and kibana content without building and without symlinks
This commit is contained in:
parent
1d7390f5cc
commit
31ba5de2df
28 changed files with 252 additions and 79 deletions
20
.gitignore
vendored
20
.gitignore
vendored
|
@ -1,16 +1,16 @@
|
|||
/data
|
||||
/work
|
||||
/logs
|
||||
/.idea
|
||||
/target
|
||||
/shipper/logs
|
||||
.idea
|
||||
/shipper/data
|
||||
/shipper/target
|
||||
.DS_Store
|
||||
*.iml
|
||||
/.project
|
||||
/.classpath
|
||||
/.settings
|
||||
/config
|
||||
/lib
|
||||
/kibana
|
||||
/shipper/.project
|
||||
/shipper/.classpath
|
||||
/shipper/.settings
|
||||
/shipper/config
|
||||
/shipper/lib
|
||||
/vendor/kibana
|
||||
/node_modules
|
||||
/build
|
||||
/packages
|
||||
|
|
34
.jshintrc
Normal file
34
.jshintrc
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"browser": true,
|
||||
|
||||
"bitwise":false,
|
||||
"curly": true,
|
||||
"eqnull": true,
|
||||
"globalstrict": true,
|
||||
"devel": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"supernew": true,
|
||||
"expr": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"undef": true,
|
||||
"boss": true,
|
||||
"trailing": false,
|
||||
"laxbreak": true,
|
||||
"laxcomma": true,
|
||||
"sub": true,
|
||||
"unused": true,
|
||||
|
||||
"maxlen": 140,
|
||||
|
||||
"globals": {
|
||||
"define": true,
|
||||
"require": true,
|
||||
"Chromath": false
|
||||
}
|
||||
}
|
42
Gruntfile.js
42
Gruntfile.js
|
@ -4,43 +4,43 @@ module.exports = function (grunt) {
|
|||
|
||||
var config = {
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
baseDir: './kibana',
|
||||
srcDir: 'kibana/src',
|
||||
buildDir: 'build',
|
||||
kibanaCheckoutDir: './vendor/kibana',
|
||||
shipperDir: 'shipper',
|
||||
buildDir: 'build',
|
||||
packageDir: 'packages',
|
||||
destDir: 'build/_site',
|
||||
tempDir: 'tmp',
|
||||
port: {
|
||||
dev : '"9200"',
|
||||
dist : "(window.location.port !== '' ? ':'+window.location.port : '')"
|
||||
}
|
||||
tempDir: 'tmp',
|
||||
esPort: {
|
||||
dev: '"9200"',
|
||||
dist: "(window.location.port !== '' ? ':'+window.location.port : '')"
|
||||
},
|
||||
kibanaPort: 5601,
|
||||
kibanaHost: 'localhost'
|
||||
|
||||
};
|
||||
|
||||
// more detailed config
|
||||
config['buildMergeDir'] = config['buildDir'] + '/merge'; // kibana and custom panels will be merged here
|
||||
config['buildSiteDir'] = config['buildDir'] + '/_site'; // compressed minified marvel site will be outputted here
|
||||
|
||||
// Utility function to load plugin settings into the above config object
|
||||
function loadConfig(config,path) {
|
||||
require('glob').sync('*', {cwd: path}).forEach(function(option) {
|
||||
var key = option.replace(/\.js$/,'');
|
||||
function loadConfig(config, path) {
|
||||
require('glob').sync('*', {cwd: path}).forEach(function (option) {
|
||||
var key = option.replace(/\.js$/, '');
|
||||
// Merge duplicate plugin configs. It is your responsibility to avoid naming collisions
|
||||
// in tasks
|
||||
config[key] = config[key] || {};
|
||||
grunt.util._.extend(config[key], require(path + option)(config,grunt));
|
||||
grunt.util._.extend(config[key], require(path + option)(config, grunt));
|
||||
});
|
||||
return config;
|
||||
}
|
||||
|
||||
// load plugins
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// Load Kibana tasks if they exist. Should probably want the user if they don't.
|
||||
if (grunt.file.exists(config.baseDir)) {
|
||||
grunt.loadTasks(config.baseDir+'/tasks');
|
||||
loadConfig(config,config.baseDir+'/tasks/options/');
|
||||
grunt.task.renameTask('build', 'build-kibana');
|
||||
}
|
||||
grunt.loadNpmTasks('grunt-connect-rewrite');
|
||||
|
||||
// Load Marvel tasks. Identical task names will override kibana tasks
|
||||
grunt.loadTasks('tasks');
|
||||
loadConfig(config,'./tasks/options/');
|
||||
loadConfig(config, './tasks/options/');
|
||||
|
||||
// pass the config to grunt
|
||||
grunt.initConfig(config);
|
||||
|
|
44
README.md
44
README.md
|
@ -0,0 +1,44 @@
|
|||
|
||||
|
||||
## Grunt build system
|
||||
This grunt-based build system handles Kibana development environment setup for Marvel as well as building, packaging and distribution of the Marvel plugin. Note that you **must** run *grunt setup* before any other tasks as this build system reuses parts of the Kibana build system that must be fetched
|
||||
|
||||
### Installing
|
||||
You will need node.js+npm and grunt. Node is available via brew, install grunt with the command below. Once grunt is installed you may run grunt tasks to setup your environment and build Marvel
|
||||
|
||||
```npm install -g grunt```
|
||||
```npm install```
|
||||
|
||||
### Tasks
|
||||
|
||||
```grunt setup```
|
||||
|
||||
**Run this first.** It will download the right Kibana version to ./vendor/kibana, copies the appropriate config.js to the right place and make any symlinks needed for a proper marvel/kibana environment
|
||||
|
||||
```grunt server```
|
||||
|
||||
Starts a web server on http://127.0.0.1:5601 pointing at the kibana directory, while also serving custom marvel panels
|
||||
|
||||
```grunt jshint```
|
||||
|
||||
Lints code without building
|
||||
|
||||
```grunt build```
|
||||
|
||||
Merges kibana and marvel code, builds Kibana and the plugin (via mvn) and puts them in ./build.
|
||||
|
||||
```grunt package```
|
||||
|
||||
Zips and tar+gzips the build in ./packages. Includes grunt build
|
||||
|
||||
```grunt release```
|
||||
|
||||
Uploads archives to download.elasticsearch.org/elasticsearch/marvel/marvel-VERSION.extention. Includes grunt build and grunt package. You will need S3 credentials in .aws-config.json. Format as so:
|
||||
|
||||
```
|
||||
{
|
||||
"key":"MY_KEY_HERE",
|
||||
"secret":"your/long/secret/string"
|
||||
}
|
||||
|
||||
```
|
|
@ -25,7 +25,7 @@ function (Settings) {
|
|||
* such as stored dashboards
|
||||
* @type {String}
|
||||
*/
|
||||
kibana_index: "kibana-int",
|
||||
kibana_index: ".kibana-int",
|
||||
|
||||
/**
|
||||
* Panel modules available. Panels will only be loaded when they are defined in the
|
||||
|
@ -49,7 +49,8 @@ function (Settings) {
|
|||
'bettermap',
|
||||
'query',
|
||||
'terms',
|
||||
'sparklines'
|
||||
'sparklines',
|
||||
'marvel/stats_table'
|
||||
]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
"grunt-replace": "~0.5.1",
|
||||
"grunt-string-replace": "~0.2.4",
|
||||
"grunt-shell": "~0.6.0",
|
||||
"grunt-contrib-connect": "~0.5.0"
|
||||
"grunt-contrib-connect": "~0.5.0",
|
||||
"grunt-connect-rewrite": "~0.1.1"
|
||||
},
|
||||
"license": "Apache License"
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
|
||||
grunt.registerTask('build', [
|
||||
'clean:setup',
|
||||
'clean:build',
|
||||
'shell:maven_clean',
|
||||
'shell:maven_package',
|
||||
'setup',
|
||||
'build-kibana',
|
||||
'copy:merge_kibana',
|
||||
'copy:merge_marvel',
|
||||
'replace:dist_marvel_config',
|
||||
'symlink:build_npm',
|
||||
'shell:build_kibana',
|
||||
'copy:plugin_to_marvel',
|
||||
]);
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
setup: ['<%= destDir %>','<%= baseDir %>','<%= buildDir %>'],
|
||||
default_dashboard: ['<%= srcDir %>/app/dashboards/default.json'],
|
||||
dist: ['<%= destDir %>']
|
||||
setup: [ '<%= kibanaCheckoutDir %>', '<%= buildDir %>' ],
|
||||
build: [ '<%= buildDir %>' ],
|
||||
package: ['<%= packageDir %>']
|
||||
};
|
||||
};
|
|
@ -1,14 +1,20 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
zip: {
|
||||
options: {
|
||||
archive: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.zip'
|
||||
},
|
||||
files : [
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= buildMergeDir %>/dist',
|
||||
src: ['**/*'],
|
||||
dest: '_site'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= buildDir %>',
|
||||
src: ['**/*'],
|
||||
src: ['*.jar'],
|
||||
dest: ''
|
||||
}
|
||||
]
|
||||
|
@ -17,11 +23,17 @@ module.exports = function(config) {
|
|||
options: {
|
||||
archive: '<%= packageDir %>/<%= pkg.name %>-<%= pkg.version %>.tar.gz'
|
||||
},
|
||||
files : [
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= buildMergeDir %>/dist',
|
||||
src: ['**/*'],
|
||||
dest: '_site'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= buildDir %>',
|
||||
src: ['**/*'],
|
||||
src: ['*.jar'],
|
||||
dest: ''
|
||||
}
|
||||
]
|
||||
|
|
24
tasks/options/connect.js
Normal file
24
tasks/options/connect.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
module.exports = function(config) {
|
||||
var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
|
||||
return {
|
||||
options: {
|
||||
port: '<%= kibanaPort %>',
|
||||
hostname: '<%= kibanaHost %>',
|
||||
base: '.',
|
||||
keepalive: true,
|
||||
middleware: function (connect, options) {
|
||||
return [
|
||||
rewriteRulesSnippet, // RewriteRules support
|
||||
connect.static(require('path').resolve(options.base)) // mount filesystem
|
||||
];
|
||||
}
|
||||
}
|
||||
,
|
||||
rules: {
|
||||
'^/app/dashboards/marvel/(.*)$': '/dashboards/$1',
|
||||
'^/app/panels/marvel/(.*)$': '/panels/$1',
|
||||
'^/config.js$': '/<%= buildMergeDir %>/config.js',
|
||||
'^(.*)$': '<%= kibanaCheckoutDir %>/src/$1'
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,10 +1,32 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
plugin_to_marvel: {
|
||||
cwd: 'target',
|
||||
cwd: '<%= shipperDir %>/target',
|
||||
expand: true,
|
||||
src: ['<%= pkg.name %>-<%= pkg.version %>.jar'],
|
||||
dest: '<%= buildDir %>'
|
||||
},
|
||||
merge_kibana: {
|
||||
expand: true,
|
||||
cwd: '<%= kibanaCheckoutDir %>',
|
||||
src: [ '**', '.jshintrc'],
|
||||
dest: '<%= buildMergeDir %>'
|
||||
},
|
||||
merge_marvel: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'dashboards',
|
||||
src: '**',
|
||||
dest: '<%= buildMergeDir %>/src/app/dashboards/marvel'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'panels',
|
||||
src: '**',
|
||||
dest: '<%= buildMergeDir %>/src/app/panels/marvel'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,8 +1,9 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
kibana: {
|
||||
options: {
|
||||
repository: 'https://github.com/elasticsearch/kibana.git'
|
||||
repository: 'https://github.com/elasticsearch/kibana.git',
|
||||
directory: '<%= kibanaCheckoutDir %>'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
13
tasks/options/jshint.js
Normal file
13
tasks/options/jshint.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
module.exports = function (config) {
|
||||
return {
|
||||
// just lint the source dir
|
||||
source: {
|
||||
files: {
|
||||
src: ['Gruntfile.js', 'panels/**/*.js', 'dashboards/**/*.js']
|
||||
}
|
||||
},
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
// copy source to temp, we will minify in place for the dist build
|
||||
dev_marvel_config: {
|
||||
|
@ -6,12 +6,12 @@ module.exports = function(config) {
|
|||
patterns: [
|
||||
{
|
||||
match: 'port',
|
||||
replacement: '<%= port.dev %>',
|
||||
replacement: '<%= esPort.dev %>',
|
||||
}
|
||||
]
|
||||
},
|
||||
files: [
|
||||
{expand: true, flatten: true, src: ['./config.js'], dest: 'src/'}
|
||||
{expand: true, flatten: true, src: ['./config.js'], dest: '<%= buildMergeDir %>'}
|
||||
]
|
||||
},
|
||||
dist_marvel_config: {
|
||||
|
@ -19,12 +19,12 @@ module.exports = function(config) {
|
|||
patterns: [
|
||||
{
|
||||
match: 'port',
|
||||
replacement: '<%= port.dist %>',
|
||||
replacement: '<%= esPort.dist %>',
|
||||
}
|
||||
]
|
||||
},
|
||||
files: [
|
||||
{expand: true, flatten: true, src: ['./config.js'], dest: 'src/'}
|
||||
{expand: true, flatten: true, src: ['./config.js'], dest: '<%= buildMergeDir %>'}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
release: {
|
||||
bucket: 'download.elasticsearch.org',
|
||||
|
|
|
@ -1,15 +1,34 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
maven_clean: {
|
||||
command: 'mvn clean',
|
||||
cwd: '<%= shipperDir %>',
|
||||
options: {
|
||||
stdout: true
|
||||
}
|
||||
stdout: true,
|
||||
failOnError: true,
|
||||
execOptions: {
|
||||
cwd: '<%= shipperDir %>',
|
||||
}
|
||||
},
|
||||
},
|
||||
maven_package: {
|
||||
command: 'mvn package',
|
||||
options: {
|
||||
stdout: true
|
||||
stdout: true,
|
||||
failOnError: true,
|
||||
execOptions: {
|
||||
cwd: '<%= shipperDir %>',
|
||||
}
|
||||
},
|
||||
},
|
||||
build_kibana: {
|
||||
command: [ 'npm install', 'grunt build'].join("&&"),
|
||||
options: {
|
||||
stdout: true,
|
||||
failOnError: true,
|
||||
execOptions: {
|
||||
cwd: '<%= buildMergeDir %>',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
module.exports = function(config) {
|
||||
module.exports = function (config) {
|
||||
return {
|
||||
explicit: {
|
||||
build_npm: {
|
||||
files: [
|
||||
{
|
||||
src: 'panels',
|
||||
dest: '<%= baseDir %>/src/app/panels/marvel'
|
||||
},
|
||||
{
|
||||
src: 'dashboards',
|
||||
dest: '<%= baseDir %>/src/app/dashboards/marvel'
|
||||
},
|
||||
{
|
||||
src: 'dashboards/overview.json',
|
||||
dest: '<%= baseDir %>/src/app/dashboards/default.json'
|
||||
}
|
||||
{
|
||||
src: 'node_modules',
|
||||
dest: '<%= buildMergeDir %>/node_modules'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
8
tasks/server_task.js
Normal file
8
tasks/server_task.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = function (grunt) {
|
||||
grunt.registerTask('server', function () {
|
||||
grunt.task.run([
|
||||
'configureRewriteRules',
|
||||
'connect'
|
||||
]);
|
||||
});
|
||||
};
|
|
@ -1,9 +1,7 @@
|
|||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
grunt.registerTask('setup', [
|
||||
'clean:setup',
|
||||
'gitclone:kibana',
|
||||
'clean:default_dashboard',
|
||||
'replace:dev_marvel_config',
|
||||
'symlink'
|
||||
'replace:dev_marvel_config'
|
||||
]);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue