mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Added helpers, KIBANA_ROOT environment override (elastic/kibana-plugin-helpers#41)
* run is now a named export, added helpers for interacting with the kibana repo * [config] override the kibana root config with KIBANA_ROOT envvar Original commit: elastic/kibana-plugin-helpers@54a38cd9a2
This commit is contained in:
parent
0dfc60ded1
commit
7331033072
4 changed files with 44 additions and 1 deletions
|
@ -3,6 +3,7 @@ var readFileSync = require('fs').readFileSync;
|
|||
|
||||
var configFiles = [ '.kibana-plugin-helpers.json', '.kibana-plugin-helpers.dev.json' ];
|
||||
var configCache = {};
|
||||
var KIBANA_ROOT_OVERRIDE = process.env.KIBANA_ROOT ? resolve(process.env.KIBANA_ROOT) : null;
|
||||
|
||||
module.exports = function (root) {
|
||||
if (!root) root = process.cwd();
|
||||
|
@ -25,6 +26,7 @@ module.exports = function (root) {
|
|||
|
||||
// if the kibanaRoot is set, use resolve to ensure correct resolution
|
||||
if (config.kibanaRoot) config.kibanaRoot = resolve(root, config.kibanaRoot);
|
||||
if (KIBANA_ROOT_OVERRIDE) config.kibanaRoot = KIBANA_ROOT_OVERRIDE;
|
||||
|
||||
return config;
|
||||
};
|
||||
|
|
13
packages/kbn-plugin-helpers/lib/index.js
Normal file
13
packages/kbn-plugin-helpers/lib/index.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
var run = require('./run');
|
||||
var utils = require('./utils');
|
||||
|
||||
module.exports = function () {
|
||||
console.error(
|
||||
'running tasks with the default export of @elastic/plugin-helpers is deprecated.' +
|
||||
'use `require(\'@elastic/plugin-helpers\').run()` instead'
|
||||
);
|
||||
|
||||
return run.apply(this, arguments);
|
||||
};
|
||||
|
||||
Object.assign(module.exports, { run: run }, utils);
|
28
packages/kbn-plugin-helpers/lib/utils.js
Normal file
28
packages/kbn-plugin-helpers/lib/utils.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
var resolve = require('path').resolve;
|
||||
|
||||
var pluginConfig = require('./config_file');
|
||||
|
||||
function babelRegister() {
|
||||
var plugin = pluginConfig();
|
||||
require(resolve(plugin.kibanaRoot, 'src/optimize/babel/register'));
|
||||
}
|
||||
|
||||
function resolveKibanaPath(path) {
|
||||
var plugin = pluginConfig();
|
||||
return resolve(plugin.kibanaRoot, path);
|
||||
}
|
||||
|
||||
function createToolingLog(level) {
|
||||
return require(resolveKibanaPath('src/utils')).createToolingLog(level);
|
||||
}
|
||||
|
||||
function readFtrConfigFile(log, path, settingOverrides) {
|
||||
return require(resolveKibanaPath('src/functional_test_runner')).readConfigFile(log, path, settingOverrides);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
babelRegister: babelRegister,
|
||||
resolveKibanaPath: resolveKibanaPath,
|
||||
createToolingLog: createToolingLog,
|
||||
readFtrConfigFile: readFtrConfigFile,
|
||||
};
|
|
@ -2,7 +2,7 @@
|
|||
"name": "@elastic/plugin-helpers",
|
||||
"version": "6.0.4",
|
||||
"description": "Just some helpers for kibana plugin devs.",
|
||||
"main": "lib/run.js",
|
||||
"main": "lib/index.js",
|
||||
"bin": {
|
||||
"plugin-helpers": "bin/plugin-helpers.js"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue