diff --git a/src/cli/plugin/plugin.js b/src/cli/plugin/plugin.js index 1b5763640352..ac5a7996784b 100644 --- a/src/cli/plugin/plugin.js +++ b/src/cli/plugin/plugin.js @@ -34,6 +34,11 @@ module.exports = function (program) { .option('-q, --quiet', 'Disable all process messaging except errors') .option('-s, --silent', 'Disable all process messaging') .option('-u, --url ', 'Specify download url') + .option( + '-c, --config ', + 'Path to the config file', + fromRoot('config/kibana.yml') + ) .option( '-t, --timeout ', 'Length of time before failing; 0 for never fail', diff --git a/src/cli/plugin/pluginInstaller.js b/src/cli/plugin/pluginInstaller.js index 59052045ce7b..f92ade8446a3 100644 --- a/src/cli/plugin/pluginInstaller.js +++ b/src/cli/plugin/pluginInstaller.js @@ -1,5 +1,10 @@ +let _ = require('lodash'); +var utils = require('requirefrom')('src/utils'); +var fromRoot = utils('fromRoot'); var pluginDownloader = require('./pluginDownloader'); var pluginCleaner = require('./pluginCleaner'); +var KbnServer = require('../../server/KbnServer'); +var readYamlConfig = require('../serve/readYamlConfig'); var fs = require('fs'); module.exports = { @@ -25,7 +30,36 @@ function install(settings, logger) { .then(function () { return downloader.download(); }) - .then(function (curious) { + .then(async function() { + logger.log('Optimizing and caching browser bundles...'); + let serverConfig = _.merge( + readYamlConfig(settings.config), + { + env: 'production', + logging: { + silent: settings.silent, + quiet: !settings.silent, + verbose: false + }, + optimize: { + useBundleCache: false + }, + server: { + autoListen: false + }, + plugins: { + initialize: false, + scanDirs: [settings.pluginDir, fromRoot('src/plugins')], + paths: [settings.workingPath] + } + } + ); + + let kbnServer = new KbnServer(serverConfig); + await kbnServer.ready(); + await kbnServer.close(); + }) + .then(function () { fs.renameSync(settings.workingPath, settings.pluginPath); logger.log('Plugin installation complete'); }) diff --git a/src/cli/plugin/settingParser.js b/src/cli/plugin/settingParser.js index acd16b24434b..8272b2ea126b 100644 --- a/src/cli/plugin/settingParser.js +++ b/src/cli/plugin/settingParser.js @@ -54,6 +54,10 @@ module.exports = function (options) { settings.urls.push(options.url); } + if (options.config) { + settings.config = options.config; + } + if (options.install) { settings.action = 'install'; parts = options.install.split('/'); diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index fc9fb3c47271..f8bcffd8adaf 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -32,7 +32,10 @@ module.exports = function (program) { .description('Run the kibana server') .collectUnknownOptions() .option('-e, --elasticsearch ', 'Elasticsearch instance') - .option('-c, --config ', 'Path to the config file') + .option( + '-c, --config ', + 'Path to the config file', + fromRoot('config/kibana.yml')) .option('-p, --port ', 'The port to bind to', parseInt) .option('-q, --quiet', 'Prevent all logging except errors') .option('-Q, --silent', 'Prevent all logging') @@ -76,7 +79,7 @@ module.exports = function (program) { let readYamlConfig = require('./readYamlConfig'); let KbnServer = src('server/KbnServer'); - let settings = readYamlConfig(opts.config || fromRoot('config/kibana.yml')); + let settings = readYamlConfig(opts.config); if (opts.dev) { try { _.merge(settings, readYamlConfig(fromRoot('config/kibana.dev.yml'))); } diff --git a/src/optimize/index.js b/src/optimize/index.js index c55eef3fb47f..1b2cf69e92e4 100644 --- a/src/optimize/index.js +++ b/src/optimize/index.js @@ -19,7 +19,9 @@ module.exports = async (kbnServer, server, config) => { await bundles.writeEntryFiles(); // in prod, only bundle what looks invalid or missing - if (config.get('env.prod')) bundles = await kbnServer.bundles.getInvalidBundles(); + if (config.get('optimize.useBundleCache')) { + bundles = await bundles.getInvalidBundles(); + } // we might not have any work to do if (!bundles.getIds().length) { diff --git a/src/server/config/schema.js b/src/server/config/schema.js index 0121e7d92228..dc960c684189 100644 --- a/src/server/config/schema.js +++ b/src/server/config/schema.js @@ -87,6 +87,7 @@ module.exports = Joi.object({ lazyHost: Joi.string().hostname().default('localhost'), lazyPrebuild: Joi.boolean().default(false), lazyProxyTimeout: Joi.number().default(5 * 60000), + useBundleCache: Joi.boolean().default(Joi.ref('$prod')), unsafeCache: Joi .alternatives() .try(