kibana/tasks/build
Court Ewing e2dd40e965 Remove package.json dependencies during build
The kibana app itself requires that package.json exist, so removing it
entirely from distributions is a no go. Instead, we remove only the
dependencies themselves from the package.json so people do not try to
reinstall dependencies on an official distribution.
2015-09-18 14:23:24 -04: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 Remove package.json dependencies during build 2015-09-18 14:23:24 -04: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 Revert npm3, go back to npm2 2015-09-14 13:39:17 -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
removePkgJsonDeps.js Remove package.json dependencies during build 2015-09-18 14:23:24 -04:00
shasums.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -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')));
  });

};