diff --git a/packages/kbn-plugin-helpers/README.md b/packages/kbn-plugin-helpers/README.md index 56df483b8819..c9f7772a5a6d 100644 --- a/packages/kbn-plugin-helpers/README.md +++ b/packages/kbn-plugin-helpers/README.md @@ -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 diff --git a/packages/kbn-plugin-helpers/cli.js b/packages/kbn-plugin-helpers/cli.js index b2db60531d2e..bbd9c47e758a 100644 --- a/packages/kbn-plugin-helpers/cli.js +++ b/packages/kbn-plugin-helpers/cli.js @@ -77,5 +77,11 @@ program }); })); +program + .command('postinstall') + .action(taskRunner(function (command) { + run('postinstall'); + })); + program .parse(process.argv); diff --git a/packages/kbn-plugin-helpers/lib/config_file.js b/packages/kbn-plugin-helpers/lib/config_file.js index bcf4f7657ded..df1bbce98e00 100644 --- a/packages/kbn-plugin-helpers/lib/config_file.js +++ b/packages/kbn-plugin-helpers/lib/config_file.js @@ -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; }; diff --git a/packages/kbn-plugin-helpers/lib/plugin_config.js b/packages/kbn-plugin-helpers/lib/plugin_config.js index d544106dce0e..eb30e9ee03ce 100644 --- a/packages/kbn-plugin-helpers/lib/plugin_config.js +++ b/packages/kbn-plugin-helpers/lib/plugin_config.js @@ -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, diff --git a/packages/kbn-plugin-helpers/lib/tasks.js b/packages/kbn-plugin-helpers/lib/tasks.js index 69f195131a91..ab9ef3df6243 100644 --- a/packages/kbn-plugin-helpers/lib/tasks.js +++ b/packages/kbn-plugin-helpers/lib/tasks.js @@ -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 }; \ No newline at end of file diff --git a/packages/kbn-plugin-helpers/tasks/postinstall/index.js b/packages/kbn-plugin-helpers/tasks/postinstall/index.js new file mode 100644 index 000000000000..c575100d1360 --- /dev/null +++ b/packages/kbn-plugin-helpers/tasks/postinstall/index.js @@ -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; + } +}