Remove kibanaRoot option, require kibana-extra (elastic/kibana-plugin-helpers#58)

* Remove kibanaRoot option, require kibana-extra

* Check location of Kibana on postinstall

* Fix eslint

* Remove 'process.env.KIBANA_ROOT'

Original commit: elastic/kibana-plugin-helpers@3511054dfb
This commit is contained in:
Kim Joar Bekkelund 2017-12-12 13:35:24 +01:00 committed by GitHub
parent eec07c5209
commit b8c9ef2ff9
6 changed files with 42 additions and 26 deletions

View file

@ -46,19 +46,6 @@ All configuration setting listed below can simply can be included in the json co
## Global settings
Setting | Description
------- | -----------
`kibanaRoot` | DEPRECATED. Path to your checkout of Kibana, relative paths are ok.
In the next major version of the plugin helpers the `kibanaRoot` setting can no longer be specified, and plugins must be located within the sibling `kibana-extra` folder, for example:
```sh
.
├── kibana
├── kibana-extra/foo-plugin
└── kibana-extra/bar-plugin
```
### Settings for `start`
Setting | Description

View file

@ -77,5 +77,11 @@ program
});
}));
program
.command('postinstall')
.action(taskRunner(function (command) {
run('postinstall');
}));
program
.parse(process.argv);

View file

@ -3,7 +3,6 @@ const readFileSync = require('fs').readFileSync;
const configFiles = [ '.kibana-plugin-helpers.json', '.kibana-plugin-helpers.dev.json' ];
const configCache = {};
const KIBANA_ROOT_OVERRIDE = process.env.KIBANA_ROOT ? resolve(process.env.KIBANA_ROOT) : null;
module.exports = function (root) {
if (!root) root = process.cwd();
@ -24,27 +23,24 @@ module.exports = function (root) {
}
});
const deprecationMsg = 'has been deprecated and is removed in the next ' +
'major version of `@elastic/plugin-helpers`.\n'
const deprecationMsg = 'has been removed from `@elastic/plugin-helpers`. ' +
'During development your plugin must be located in `../kibana-extra/{pluginName}` ' +
'relative to the Kibana directory to work with this package.\n'
if (config.kibanaRoot) {
process.stdout.write(
'WARNING: The `kibanaRoot` config option ' + deprecationMsg
throw new Error(
'The `kibanaRoot` config option ' + deprecationMsg
);
}
if (process.env.KIBANA_ROOT) {
process.stdout.write(
'WARNING: The `KIBANA_ROOT` environment variable ' + deprecationMsg
throw new Error(
'The `KIBANA_ROOT` environment variable ' + deprecationMsg
);
}
// use resolve to ensure correct resolution of paths
const { kibanaRoot, includePlugins } = config;
if (kibanaRoot) config.kibanaRoot = resolve(root, kibanaRoot);
const { includePlugins } = config;
if (includePlugins) config.includePlugins = includePlugins.map(path => resolve(root, path));
// allow env setting to override kibana root from config
if (KIBANA_ROOT_OVERRIDE) config.kibanaRoot = KIBANA_ROOT_OVERRIDE;
return config;
};

View file

@ -25,7 +25,7 @@ module.exports = function (root) {
return Object.assign({
root: root,
kibanaRoot: resolve(root, '../kibana'),
kibanaRoot: resolve(root, '../../kibana'),
serverTestPatterns: ['server/**/__tests__/**/*.js'],
buildSourcePatterns: buildSourcePatterns,
id: pkg.name,

View file

@ -3,6 +3,7 @@ const startTask = require('../tasks/start');
const testAllTask = require('../tasks/test/all');
const testBrowserTask = require('../tasks/test/browser');
const testServerTask = require('../tasks/test/server');
const postinstallTask = require('../tasks/postinstall');
module.exports = {
build: buildTask,
@ -10,4 +11,5 @@ module.exports = {
testAll: testAllTask,
testBrowser: testBrowserTask,
testServer: testServerTask,
postinstall: postinstallTask
};

View file

@ -0,0 +1,25 @@
const resolve = require('path').resolve;
const statSync = require('fs').statSync;
module.exports = function (plugin) {
if (
fileExists(resolve(plugin.root, '../kibana/package.json')) &&
!fileExists(resolve(plugin.root, '../../kibana/package.json'))
) {
process.stdout.write(
'\nWARNING: Kibana now requires that plugins must be located in ' +
'`../kibana-extra/{pluginName}` relative to the Kibana folder ' +
'during development. We found a Kibana in `../kibana`, but not in ' +
'`../../kibana`.\n'
);
}
};
function fileExists(path) {
try {
const stat = statSync(path);
return stat.isFile();
} catch (e) {
return false;
}
}