kibana/tasks/build
spalger 8aa0287dd7 [build] expose build specific babel config
During build we transpile the server source to prevent runtime transpilation with babel/register. In order to support untranspiled plugin code, we still use babel/register with special ignore options, which used to be included in cli/index.js and now is moved to src/optimize/babelOptions.js so other code that wants to initialize a server (without the cli) can also configure babel/register.
2015-09-07 17:22:42 -07:00
..
archives.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
babelOptions.js [build] expose build specific babel config 2015-09-07 17:22:42 -07:00
downloadNodeBuilds.js clearer task naming 2015-08-26 18:41:03 -07:00
getProps.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
index.js [build] expose build specific babel config 2015-09-07 17:22:42 -07:00
installedPlugins.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
installNpmDeps.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
osPackages.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
packageJson.js upgrade to npm 3.0 2015-08-26 16:36:19 -07:00
pleaserun.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
readme.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
shasums.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
shrinkwrap.js [build/shrinkwrap] apparently it is loglevel 2015-09-07 17:03:04 -07:00
versionedLinks.js [build] allow installed plugins to use live compiled es7->es5 2015-08-14 16:20:48 -07:00

let marked = require('marked');
let Promise = require('bluebird');
let { join } = require('path');
let TextRenderer = require('marked-text-renderer');
let _ = require('lodash');
let fs = require('fs');
let { AllHtmlEntities } = require('html-entities');
let entities = new AllHtmlEntities();

TextRenderer.prototype.heading = function (text, level, raw) {
  return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n';
};

module.exports = function (grunt) {

  grunt.registerTask('_build:readme', function () {
    let transform = function (input) {
      let output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n');
      output = marked(output);
      return entities.decode(output);
    };

    marked.setOptions({
      renderer: new TextRenderer(),
      tables: true,
      breaks: false,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false
    });

    grunt.file.write('build/kibana/README.txt', transform(grunt.file.read('README.md')));
    grunt.file.write('build/kibana/LICENSE.txt', transform(grunt.file.read('LICENSE.md')));
  });

};