import Path from 'path' ; import { getPluginSearchPaths } from '@kbn/config' ; import { KibanaPlatformPlugin , simpleKibanaPlatformPluginDiscovery } from '@kbn/dev-utils' ; import { REPO_ROOT } from '@kbn/utils' ; export interface SearchOptions { oss : boolean ; examples : boolean ; extraPluginScanDirs : string [ ] ; } export function findPlugins ( { oss , examples , extraPluginScanDirs , } ) { const pluginSearchPaths = getPluginSearchPaths ( { rootDir : REPO_ROOT , oss , examples , } ) ; for ( const extraScanDir of extraPluginScanDirs ) { if ( ! Path . isAbsolute ( extraScanDir ) ) { throw new TypeError ( 'extraPluginScanDirs must all be absolute paths' ) ; } pluginSearchPaths . push ( extraScanDir ) ; } const plugins = simpleKibanaPlatformPluginDiscovery ( pluginSearchPaths , [ ] ) ; return new Map ( plugins . map ( ( p ) => [ p . manifest . id , p ] ) ) ; }