import Path from 'path' ; import { REPO_ROOT } from '@kbn/utils' ; import { parseKibanaPlatformPlugin , KibanaPlatformPlugin , createFailError } from '@kbn/dev-utils' ; export type Plugin = KibanaPlatformPlugin ; export function loadKibanaPlatformPlugin ( pluginDir ) { const parentDir = Path . resolve ( pluginDir , '..' ) ; const isFixture = pluginDir . includes ( '__fixtures__' ) ; const isExample = Path . basename ( parentDir ) === 'examples' ; const isRootPlugin = parentDir === Path . resolve ( REPO_ROOT , 'plugins' ) ; if ( isFixture || isExample || isRootPlugin ) { return parseKibanaPlatformPlugin ( Path . resolve ( pluginDir , 'kibana.json' ) ) ; } throw createFailError ( `Plugin located at [${ pluginDir }] must be moved to the plugins directory at the root of the Kibana repo` ) ; }