Permalink
Browse files

Adding build process for the binaries

  • Loading branch information...
simianhacker committed Jan 9, 2015
1 parent df957ac commit 9e28e8bdbd1dc1cf2fc596a0a4bd61e941555ffe
View
@@ -14,8 +14,8 @@ module.exports = function (grunt) {
buildApp: __dirname + '/build/kibana', // build directory for the app
configFile: __dirname + '/src/server/config/kibana.yml',
- jrubyVersion: '1.7.14',
- jrubyPath: __dirname + '/.jruby',
+ nodeVersion: '0.10.35',
+ platforms: ['darwin-x64', 'linux-x64', 'linux-x86', 'windows'],
unitTestDir: __dirname + '/test/unit',
testUtilsDir: __dirname + '/test/utils',
View
@@ -51,6 +51,7 @@
"serve-favicon": "~2.2.0"
},
"devDependencies": {
+ "async": "^0.9.0",
"bluebird": "~2.0.7",
"connect": "~2.19.5",
"event-stream": "~3.1.5",
No changes.
View
No changes.
@@ -1,8 +0,0 @@
-body {
- padding: 50px;
- font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
-}
-
-a {
- color: #00B7FF;
-}
View
@@ -12,16 +12,15 @@ module.exports = function (grunt) {
'requirejs',
'clean:unneeded_source_in_build',
'copy:server_src',
- 'download_jruby',
- 'install_gems',
- 'warble',
'replace:dist',
'copy:dist',
'compile_dist_readme',
'chmod_kibana',
'make_plugin_dir',
'copy:plugin_readme',
'describe_bundled_plugins',
+ 'npm_install_kibana',
+ 'download_node_binaries',
'copy:versioned_dist',
'create_packages'
]);
View
@@ -1,5 +1,6 @@
module.exports = function (grunt) {
var version = grunt.config.get('pkg.version');
+ var platforms = grunt.config.get('platforms');
var config = {
kibana_src: {
@@ -12,16 +13,22 @@ module.exports = function (grunt) {
server_src: {
files: [
{
- src: '<%= server %>/Gemfile',
- dest: '<%= build %>/kibana/Gemfile'
+ src: '<%= root %>/package.json',
+ dest: '<%= build %>/kibana/package.json'
},
{
- src: '<%= server %>/Gemfile.lock',
- dest: '<%= build %>/kibana/Gemfile.lock'
+ src: '<%= server %>/app.js',
+ dest: '<%= build %>/kibana/app.js'
},
{
- src: '<%= server %>/bin/initialize',
- dest: '<%= build %>/kibana/bin/initialize'
+ src: '<%= server %>/index.js',
+ dest: '<%= build %>/kibana/index.js'
+ },
+ {
+ expand: true,
+ cwd: '<%= server %>/bin/',
+ src: '**',
+ dest: '<%= build %>/kibana/bin'
},
{
expand: true,
@@ -40,6 +47,12 @@ module.exports = function (grunt) {
cwd: '<%= server %>/routes/',
src: '**',
dest: '<%= build %>/kibana/routes'
+ },
+ {
+ expand: true,
+ cwd: '<%= server %>/views/',
+ src: '**',
+ dest: '<%= build %>/kibana/views'
}
]
},
@@ -49,9 +62,9 @@ module.exports = function (grunt) {
files: [
{
expand: true,
- cwd: '<%= build %>/kibana/',
- src: '*.jar',
- dest: '<%= build %>/dist/kibana/lib/'
+ cwd: '<%= build %>/kibana',
+ src: '**',
+ dest: '<%= build %>/dist/kibana/src'
},
{
expand: true,
@@ -64,14 +77,7 @@ module.exports = function (grunt) {
versioned_dist: {
options: { mode: true },
- files: [
- {
- expand: true,
- cwd: '<%= build %>/dist/kibana',
- src: '**',
- dest: '<%= build %>/dist/kibana-' + version
- }
- ]
+ files: []
},
plugin_readme: {
@@ -85,5 +91,20 @@ module.exports = function (grunt) {
};
+ platforms.forEach(function (platform) {
+ config.versioned_dist.files.push({
+ expand: true,
+ cwd: '<%= build %>/dist/kibana',
+ src: '**',
+ dest: '<%= build %>/dist/kibana-' + version + '-' + platform
+ });
+ config.versioned_dist.files.push({
+ expand: true,
+ cwd: '<%= build %>/node_binaries/' + platform,
+ src: '**',
+ dest: '<%= build %>/dist/kibana-' + version + '-' + platform + '/node'
+ });
+ });
+
return config;
};
View
@@ -10,22 +10,26 @@ module.exports = function (grunt) {
var target = grunt.config.get('target');
var packageName = grunt.config.get('pkg.name');
var version = grunt.config.get('pkg.version');
- var archiveName = join(target, packageName + '-' + version);
var distPath = join(grunt.config.get('build'), 'dist');
+ var platforms = grunt.config.get('platforms');
- var tgzCmd = 'tar -zcvf ' + archiveName + '.tar.gz kibana-' + version;
- var zipCmd = 'zip -r ' + archiveName + '.zip kibana-' + version;
+ var createPackage = function (platform) {
+ var options = { cwd: distPath };
+ var name = packageName + '-' + version + '-' + platform;
+ var archiveName = join(target, name);
+ var tgzCmd = 'tar -zcf ' + archiveName + '.tar.gz ' + name;
+ var zipCmd = 'zip -rq ' + archiveName + '.zip ' + name;
- var options = { cwd: distPath };
+ return mkdirp.mkdirpAsync(target)
+ .then(function (arg) {
+ return exec(tgzCmd, options);
+ })
+ .then(function (arg) {
+ return exec(zipCmd, options);
+ });
+ };
- mkdirp.mkdirpAsync(target)
- .then(function (arg) {
- return exec(tgzCmd, options);
- })
- .then(function (arg) {
- return exec(zipCmd, options);
- })
- .finally(done);
+ Promise.map(platforms, createPackage).finally(done);
});
};
View
@@ -1,46 +0,0 @@
-var zlib = require('zlib');
-var tar = require('tar');
-var request = require('request');
-var mkdirp = require('mkdirp');
-var ProgressBar = require('progress');
-var fs = require('fs');
-
-module.exports = function (grunt) {
- grunt.registerTask('download_jruby', 'Downloads and installs jruby', function () {
- var done = this.async();
- var jrubyPath = grunt.config.get('jrubyPath');
- var jrubyVersion = grunt.config.get('jrubyVersion');
- var url = 'http://jruby.org.s3.amazonaws.com/downloads/' + jrubyVersion + '/jruby-bin-' + jrubyVersion + '.tar.gz';
-
- fs.stat(jrubyPath, function (err, stat) {
- if (err) {
- mkdirp(jrubyPath, function (err) {
- if (err) return done(err);
- var unzip = zlib.createGunzip();
- var out = tar.Extract({ path: jrubyPath, strip: 1 });
- out.on('close', done).on('error', done);
- var req = request.get(url);
- var bar;
- if (!process.env.JENKINS_HOME) {
- req.on('response', function (resp) {
- var total = parseInt(resp.headers['content-length'], 10);
- bar = new ProgressBar('[:bar] :percent :etas', {
- complete: '=',
- incomplete: ' ',
- width: 80,
- clear: true,
- total: total
- });
- });
- req.on('data', function (buffer) {
- bar.tick(buffer.length);
- });
- }
- req.pipe(unzip).pipe(out);
- });
- } else {
- done();
- }
- });
- });
-};
@@ -0,0 +1,52 @@
+var _ = require('lodash');
+var zlib = require('zlib');
+var tar = require('tar');
+var request = require('request');
+var mkdirp = require('mkdirp');
+var fs = require('fs');
+var join = require('path').join;
+var filesPatern = _.template('node-v<%- version %>-<%- platform %>.tar.gz');
+var urlPattern = _.template('http://nodejs.org/dist/v<%- version %>/<%- file %>');
+var async = require('async');
+
+module.exports = function (grunt) {
+ grunt.registerTask('download_node_binaries', 'Download the node.js binaries', function () {
+ var done = this.async();
+ var platforms = _.without(grunt.config.get('platforms'), 'windows');
+ var buildPath = grunt.config.get('build');
+ var version = grunt.config.get('nodeVersion');
+
+ var downloadWindows = function (cb) {
+ var dest = join(buildPath, 'node_binaries', 'windows');
+ var url = urlPattern({ version: version, file: 'nodex.exe'});
+ mkdirp(dest, function (err) {
+ if (err) return cb(err);
+ var out = fs.createWriteStream(join(dest, 'node.exe'));
+ out.on('close', cb).on('error', cb);
+ var req = request.get(url);
+ req.pipe(out);
+ });
+ };
+
+ var download = function (platform, cb) {
+ var dest = join(buildPath, 'node_binaries', platform);
+ var file = filesPatern({ version: version, platform: platform });
+ var url = urlPattern({ version: version, file: file });
+ mkdirp(dest, function (err) {
+ if (err) return cb(err);
+ var unzip = zlib.createGunzip();
+ var out = tar.Extract({ path: dest, strip: 1 });
+ out.on('close', cb).on('error', cb);
+ var req = request.get(url);
+ req.pipe(unzip).pipe(out);
+ });
+ };
+
+ async.each(platforms, download, function (err) {
+ if (err) return done(err);
+ downloadWindows(done);
+ });
+
+ });
+};
+
View
@@ -1,20 +0,0 @@
-var child_process = require('child_process');
-var join = require('path').join;
-module.exports = function (grunt) {
- grunt.registerTask('install_gems', 'Install Ruby Gems', function () {
- var done = this.async();
- var gemfile = join(grunt.config.get('root'), 'Gemfile');
- var jrubyPath = grunt.config.get('jrubyPath');
- var jruby = jrubyPath + '/bin/jruby -S';
- var command = jruby + ' gem install bundler && ' + jruby + ' bundle install --gemfile ' + gemfile;
- child_process.exec(command, function (err, stdout, stderr) {
- if (err) {
- grunt.log.error(stderr);
- return done(err);
- }
- grunt.log.writeln(stdout);
- return done();
- });
- });
-};
-
@@ -1,13 +1,11 @@
var child_process = require('child_process');
var join = require('path').join;
module.exports = function (grunt) {
- grunt.registerTask('warble', 'Creates an executable jar.', function () {
+ grunt.registerTask('npm_install_kibana', 'NPM isntall kibana server into dist', function () {
var done = this.async();
- var jrubyPath = grunt.config.get('jrubyPath');
- var command = jrubyPath + '/bin/jruby -S warble';
- var options = {
- cwd: join(grunt.config.get('build'), 'kibana')
- };
+ var cwd = join(grunt.config.get('build'), 'dist', 'kibana', 'src');
+ var command = 'npm install --production';
+ var options = { cwd: cwd };
child_process.exec(command, options, function (err, stdout, stderr) {
if (err) {
grunt.log.error(stderr);
@@ -18,3 +16,5 @@ module.exports = function (grunt) {
});
});
};
+
+

0 comments on commit 9e28e8b

Please sign in to comment.