removed the dev server and cleaned up package.json
This commit is contained in:
parent
89e082b2c4
commit
94ff1e9ead
18
package.json
18
package.json
|
@ -24,11 +24,10 @@
|
||||||
"Lukas Olson <lukas.olson@elasticsearch.com>"
|
"Lukas Olson <lukas.olson@elasticsearch.com>"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"test": "grunt test",
|
||||||
"start": "node ./src/server/bin/kibana.js",
|
"start": "node ./src/server/bin/kibana.js",
|
||||||
"test": "grunt test --use-jruby",
|
"server": "node ./src/server/bin/kibana.js",
|
||||||
"server": "grunt server",
|
"precommit": "grunt hintStagedFiles"
|
||||||
"precommit": "grunt hintStagedFiles",
|
|
||||||
"prepush": "echo"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -93,17 +92,6 @@
|
||||||
"simple-git": "^0.11.0",
|
"simple-git": "^0.11.0",
|
||||||
"tar": "^1.0.1"
|
"tar": "^1.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
|
||||||
"test": "grunt test --use-jruby",
|
|
||||||
"server": "grunt server",
|
|
||||||
"precommit": "grunt hintStagedFiles",
|
|
||||||
"prepush": "echo"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git@github.com:elasticsearch/kibana.git"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "Apache 2.0",
|
"license": "Apache 2.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/elasticsearch/kibana/issues"
|
"url": "https://github.com/elasticsearch/kibana/issues"
|
||||||
|
|
|
@ -19,6 +19,10 @@ app.set('view engine', 'jade');
|
||||||
app.use(favicon(path.join(config.public_folder, 'styles', 'theme', 'elk.ico')));
|
app.use(favicon(path.join(config.public_folder, 'styles', 'theme', 'elk.ico')));
|
||||||
app.use(requestLogger());
|
app.use(requestLogger());
|
||||||
|
|
||||||
|
if (app.get('env') === 'development') {
|
||||||
|
require('./dev')(app);
|
||||||
|
}
|
||||||
|
|
||||||
// The proxy must be set up before all the other middleware.
|
// The proxy must be set up before all the other middleware.
|
||||||
// TODO: WE might want to move the middleware to each of the individual routes
|
// TODO: WE might want to move the middleware to each of the individual routes
|
||||||
// so we don't have weird conflicts in the future.
|
// so we don't have weird conflicts in the future.
|
||||||
|
|
56
src/server/dev/index.js
Normal file
56
src/server/dev/index.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/* jshint node:true */
|
||||||
|
|
||||||
|
var express = require('express');
|
||||||
|
var instrumentationMiddleware = require('./_instrumentation');
|
||||||
|
var amdRapperMiddleware = require('./_amd_rapper');
|
||||||
|
|
||||||
|
var glob = require('glob');
|
||||||
|
var path = require('path');
|
||||||
|
var join = path.join;
|
||||||
|
var rel = join.bind(null, __dirname);
|
||||||
|
var ROOT = rel('../../../');
|
||||||
|
var SRC = join(ROOT, 'src');
|
||||||
|
var APP = join(SRC, 'kibana');
|
||||||
|
var TEST = join(ROOT, 'test');
|
||||||
|
|
||||||
|
module.exports = function (app) {
|
||||||
|
app.use(instrumentationMiddleware({
|
||||||
|
root: SRC,
|
||||||
|
displayRoot: SRC,
|
||||||
|
filter: function (filename) {
|
||||||
|
return filename.match(/.*\/src\/.*\.js$/)
|
||||||
|
&& !filename.match(/.*\/src\/kibana\/bower_components\/.*\.js$/)
|
||||||
|
&& !filename.match(/.*\/src\/kibana\/utils\/(event_emitter|next_tick|rison)\.js$/);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
app.use(instrumentationMiddleware({
|
||||||
|
root: APP,
|
||||||
|
displayRoot: SRC,
|
||||||
|
filter: function (filename) {
|
||||||
|
return filename.match(/.*\/src\/.*\.js$/)
|
||||||
|
&& !filename.match(/.*\/src\/kibana\/bower_components\/.*\.js$/)
|
||||||
|
&& !filename.match(/.*\/src\/kibana\/utils\/(event_emitter|next_tick|rison)\.js$/);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
app.use(amdRapperMiddleware({
|
||||||
|
root: ROOT
|
||||||
|
}));
|
||||||
|
|
||||||
|
app.use('/test', express.static(TEST));
|
||||||
|
app.use('/specs', function (req, res) {
|
||||||
|
var unit = join(ROOT, '/test/unit/');
|
||||||
|
glob(join(unit, 'specs/**/*.js'), function (er, files) {
|
||||||
|
var moduleIds = files
|
||||||
|
.filter(function (filename) {
|
||||||
|
return path.basename(filename).charAt(0) !== '_';
|
||||||
|
})
|
||||||
|
.map(function (filename) {
|
||||||
|
return path.relative(unit, filename).replace(/\.js$/, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
res.end(JSON.stringify(moduleIds));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
|
@ -7,7 +7,6 @@ module.exports = function (grunt) {
|
||||||
'jade',
|
'jade',
|
||||||
'esvm:dev',
|
'esvm:dev',
|
||||||
'maybe_start_kibana',
|
'maybe_start_kibana',
|
||||||
'maybe_start_server',
|
|
||||||
'watch'
|
'watch'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,6 @@ module.exports = function (grunt) {
|
||||||
req.end();
|
req.end();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
grunt.registerTask('maybe_start_server', maybeStartServer({
|
|
||||||
name: 'connect-server',
|
|
||||||
port: 8000,
|
|
||||||
tasks: ['server']
|
|
||||||
}));
|
|
||||||
grunt.registerTask('maybe_start_kibana', maybeStartServer({
|
grunt.registerTask('maybe_start_kibana', maybeStartServer({
|
||||||
name: 'kibana-server',
|
name: 'kibana-server',
|
||||||
port: 5601,
|
port: 5601,
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
var request = require('request');
|
|
||||||
module.exports = function (grunt) {
|
|
||||||
grunt.registerTask('ruby_server', function () {
|
|
||||||
var done = this.async();
|
|
||||||
|
|
||||||
request.get('http://localhost:5601/config', function (err, resp, body) {
|
|
||||||
// err is a failed response, no server is running
|
|
||||||
if (err) {
|
|
||||||
// run mri_server by default
|
|
||||||
var tasks = ['run:mri_server'];
|
|
||||||
grunt.config.set('ruby_server', 'mri_server');
|
|
||||||
|
|
||||||
// if jruby flag is set, use jruby
|
|
||||||
if (grunt.option('use-jruby')) {
|
|
||||||
tasks = [
|
|
||||||
'download_jruby',
|
|
||||||
'install_gems',
|
|
||||||
'run:jruby_server',
|
|
||||||
'wait_for_jruby'
|
|
||||||
];
|
|
||||||
grunt.config.set('ruby_server', 'jruby_server');
|
|
||||||
}
|
|
||||||
|
|
||||||
grunt.task.run(tasks);
|
|
||||||
|
|
||||||
// response means server is already running
|
|
||||||
} else {
|
|
||||||
grunt.log.error('Another ruby server is running on localhost:5601.');
|
|
||||||
}
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,15 +0,0 @@
|
||||||
module.exports = function (grunt) {
|
|
||||||
grunt.registerTask('server', function (keepalive) {
|
|
||||||
var done = this.async();
|
|
||||||
var DevServer = require('../test/utils/dev_server');
|
|
||||||
var server = new DevServer();
|
|
||||||
|
|
||||||
server.listen(8000).then(function () {
|
|
||||||
console.log('visit http://localhost:8000');
|
|
||||||
|
|
||||||
if (keepalive !== 'keepalive') {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -25,7 +25,6 @@ module.exports = function (grunt) {
|
||||||
var tasks = [
|
var tasks = [
|
||||||
'jshint',
|
'jshint',
|
||||||
'maybe_start_kibana',
|
'maybe_start_kibana',
|
||||||
'maybe_start_server',
|
|
||||||
'jade',
|
'jade',
|
||||||
'less',
|
'less',
|
||||||
getTestTask()
|
getTestTask()
|
||||||
|
@ -36,7 +35,6 @@ module.exports = function (grunt) {
|
||||||
grunt.registerTask('quick-test', function () {
|
grunt.registerTask('quick-test', function () {
|
||||||
var tasks = [
|
var tasks = [
|
||||||
'maybe_start_kibana',
|
'maybe_start_kibana',
|
||||||
'maybe_start_server',
|
|
||||||
getTestTask()
|
getTestTask()
|
||||||
];
|
];
|
||||||
grunt.task.run(tasks);
|
grunt.task.run(tasks);
|
||||||
|
@ -45,13 +43,11 @@ module.exports = function (grunt) {
|
||||||
grunt.registerTask('coverage', [
|
grunt.registerTask('coverage', [
|
||||||
'blanket',
|
'blanket',
|
||||||
'maybe_start_kibana',
|
'maybe_start_kibana',
|
||||||
'maybe_start_server',
|
|
||||||
'mocha:coverage'
|
'mocha:coverage'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
grunt.registerTask('test:watch', [
|
grunt.registerTask('test:watch', [
|
||||||
'maybe_start_kibana',
|
'maybe_start_kibana',
|
||||||
'maybe_start_server',
|
|
||||||
'watch:test'
|
'watch:test'
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
/* jshint node:true */
|
|
||||||
|
|
||||||
var connect = require('connect');
|
|
||||||
var http = require('http');
|
|
||||||
var Promise = require('bluebird');
|
|
||||||
|
|
||||||
var instrumentationMiddleware = require('./_instrumentation');
|
|
||||||
var amdRapperMiddleware = require('./_amd_rapper');
|
|
||||||
var proxy = require('http-proxy').createProxyServer({});
|
|
||||||
|
|
||||||
var glob = require('glob');
|
|
||||||
var path = require('path');
|
|
||||||
var join = path.join;
|
|
||||||
var rel = join.bind(null, __dirname);
|
|
||||||
var ROOT = rel('../../../');
|
|
||||||
var SRC = join(ROOT, 'src');
|
|
||||||
var APP = join(SRC, 'kibana');
|
|
||||||
var TEST = join(ROOT, 'test');
|
|
||||||
var PLUGINS = join(SRC, 'plugins');
|
|
||||||
|
|
||||||
module.exports = function DevServer(opts) {
|
|
||||||
opts = opts || {};
|
|
||||||
|
|
||||||
var server = this;
|
|
||||||
var app = connect();
|
|
||||||
var httpServer = http.createServer(app);
|
|
||||||
|
|
||||||
// Kibana Backend Proxy
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
// Proxy config and es requests to the Kibana Backend
|
|
||||||
if (/^\/(config|elasticsearch\/)/.test(req.url)) {
|
|
||||||
return proxy.web(req, res, { target: 'http://localhost:5601' });
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(instrumentationMiddleware({
|
|
||||||
root: SRC,
|
|
||||||
displayRoot: SRC,
|
|
||||||
filter: function (filename) {
|
|
||||||
return filename.match(/.*\/src\/.*\.js$/)
|
|
||||||
&& !filename.match(/.*\/src\/kibana\/bower_components\/.*\.js$/)
|
|
||||||
&& !filename.match(/.*\/src\/kibana\/utils\/(event_emitter|next_tick|rison)\.js$/);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
app.use(instrumentationMiddleware({
|
|
||||||
root: APP,
|
|
||||||
displayRoot: SRC,
|
|
||||||
filter: function (filename) {
|
|
||||||
return filename.match(/.*\/src\/.*\.js$/)
|
|
||||||
&& !filename.match(/.*\/src\/kibana\/bower_components\/.*\.js$/)
|
|
||||||
&& !filename.match(/.*\/src\/kibana\/utils\/(event_emitter|next_tick|rison)\.js$/);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
app.use(amdRapperMiddleware({
|
|
||||||
root: ROOT
|
|
||||||
}));
|
|
||||||
|
|
||||||
app.use(connect.static(ROOT));
|
|
||||||
app.use(connect.static(APP));
|
|
||||||
app.use('/test', connect.static(TEST));
|
|
||||||
app.use('/plugins', connect.static(PLUGINS));
|
|
||||||
|
|
||||||
app.use('/specs', function (req, res) {
|
|
||||||
var unit = join(ROOT, '/test/unit/');
|
|
||||||
glob(join(unit, 'specs/**/*.js'), function (er, files) {
|
|
||||||
var moduleIds = files
|
|
||||||
.filter(function (filename) {
|
|
||||||
return path.basename(filename).charAt(0) !== '_';
|
|
||||||
})
|
|
||||||
.map(function (filename) {
|
|
||||||
return path.relative(unit, filename).replace(/\.js$/, '');
|
|
||||||
});
|
|
||||||
|
|
||||||
res.end(JSON.stringify(moduleIds));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// respond to the "maybe_start_server" pings
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
if (req.method !== 'HEAD' || req.url !== '/') return next();
|
|
||||||
res.statusCode === 200;
|
|
||||||
res.setHeader('Pong', 'Kibana 4 Dev Server');
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
if (req.url !== '/') return next();
|
|
||||||
res.statusCode = 303;
|
|
||||||
res.setHeader('Location', '/src/');
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
// prevent chrome's stupid "this page is in spanish" on the directories page
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
res.setHeader('Content-Language', 'en');
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
// allow browsing directories
|
|
||||||
app.use(connect.directory(ROOT));
|
|
||||||
|
|
||||||
server.listenOnFirstOpenPort = function (ports) {
|
|
||||||
var options = ports.slice(0);
|
|
||||||
|
|
||||||
// wrap this logic in an IIFE so that we can call it again later
|
|
||||||
return (function attempt() {
|
|
||||||
var port = options.shift();
|
|
||||||
if (!port) return Promise.reject(new Error('None of the supplied options succeeded'));
|
|
||||||
|
|
||||||
return server.listen(port)
|
|
||||||
// filter out EADDRINUSE errors and call attempt again
|
|
||||||
.catch(function (err) {
|
|
||||||
if (err.code === 'EADDRINUSE') return attempt();
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
};
|
|
||||||
|
|
||||||
server.listen = function (port) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
var done = function (err) {
|
|
||||||
httpServer.removeListener('error', done);
|
|
||||||
httpServer.removeListener('listening', done);
|
|
||||||
|
|
||||||
// pass the error along
|
|
||||||
if (err) return reject(err);
|
|
||||||
|
|
||||||
resolve(server.port = httpServer.address().port);
|
|
||||||
};
|
|
||||||
|
|
||||||
// call done with an error
|
|
||||||
httpServer.on('error', done, true);
|
|
||||||
// call done without any args
|
|
||||||
httpServer.on('listening', done, true);
|
|
||||||
|
|
||||||
httpServer.listen(port);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
server.close = httpServer.close.bind(httpServer);
|
|
||||||
};
|
|
Loading…
Reference in a new issue