import Path from 'path' ; import { REPO_ROOT } from '@osd/utils' ; import { parseOpenSearchDashboardsPlatformPlugin , OpenSearchDashboardsPlatformPlugin , createFailError , } from '@osd/dev-utils' ; export type Plugin = OpenSearchDashboardsPlatformPlugin ; export function loadOpenSearchDashboardsPlatformPlugin ( 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 parseOpenSearchDashboardsPlatformPlugin ( Path . resolve ( pluginDir , 'opensearch_dashboards.json' ) ) ; } throw createFailError ( `Plugin located at [${ pluginDir }] must be moved to the plugins directory at the root of the OpenSearch Dashboards repo` ) ; }