added build props

This commit is contained in:
Spencer Alger 2014-10-09 12:59:09 -07:00
parent 900a26dc8b
commit 032f8a57e8
5 changed files with 38 additions and 5 deletions

View file

@ -12,6 +12,11 @@
<script src="/require.config.js"></script>
<script>require(['kibana'], function (kibana) { kibana.init(); });</script>
<link rel="stylesheet" href="/styles/main.css" >
<script>
window.KIBANA_VERSION='@@version';
window.KIBANA_BUILD_NUM='@@buildNum';
window.KIBANA_COMMIT_SHA='@@commitSha';
</script>
</head>
<body ng-controller="kibana" ng-class="'application-'+activeApp">
<kbn-notifications list="notifList"></kbn-notifications>

View file

@ -25,11 +25,15 @@ define(function (require) {
kibana
// This stores the Kibana revision number, @REV@ is replaced by grunt.
.constant('kbnVersion', '@REV@')
.constant('kbnVersion', window.KIBANA_VERSION)
// The build number is placed by grunt, represents a sequence to provide nothing really but order.
.constant('buildNum', window.KIBANA_BUILD_NUM)
// This stores the build number, @REV@ is replaced by grunt.
.constant('commitSha', window.KIBANA_COMMIT_SHA)
// Use this for cache busting partials
.constant('cacheBust', window.KIBANA_COMMIT_SHA)
// The minimum Elasticsearch version required to run Kibana
.constant('minimumElasticsearchVersion', '1.4.0.Beta1')
// Use this for cache busting partials
.constant('cacheBust', 'cache-bust=' + Date.now())
// When we need to identify the current session of the app, ef shard preference
.constant('sessionId', Date.now())
// attach the route manager's known routes

View file

@ -1,5 +1,6 @@
module.exports = function (grunt) {
grunt.registerTask('build', [
'get_build_props',
'clean:target',
'clean:build',
'require_css_deps:copy',

View file

@ -1,13 +1,16 @@
var join = require('path').join;
module.exports = function (grunt) {
var pkg = grunt.config.get('pkg');
var build = grunt.config.get('build');
var src = grunt.config.get('src');
var app = grunt.config.get('app');
var config = {
dist: {
options: {
patterns: [
{ match: 'version', replacement: pkg.version }
{ match: 'version', replacement: '<%= pkg.version %>' },
{ match: 'buildNum', replacement: '<%= buildNum %>' },
{ match: 'commitSha', replacement: '<%= commitSha %>' }
]
},
files: [
@ -19,6 +22,10 @@ module.exports = function (grunt) {
{
src: [join(src, 'server', 'bin', 'kibana.bat')],
dest: join(build, 'dist', 'kibana', 'bin', 'kibana.bat')
},
{
src: [join(app, 'index.html')],
dest: join(build, 'kibana', 'public', 'index.html')
}
]
}

16
tasks/get_build_props.js Normal file
View file

@ -0,0 +1,16 @@
module.exports = function (grunt) {
var Promise = require('bluebird');
var spawn = require('./utils/spawn');
grunt.registerTask('get_build_props', function () {
Promise.props({
sha: spawn.silent('git', ['log', '--format=%H', '-n1'])(),
num: spawn.silent('sh', ['-c', 'git log --format="%h" | wc -l'])()
})
.then(function (props) {
grunt.config.set('commitSha', props.sha.trim());
grunt.config.set('buildNum', props.num.trim());
})
.nodeify(this.async());
});
};