diff --git a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts index d67b957416753..cc564dd4a8387 100644 --- a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts +++ b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts @@ -146,6 +146,7 @@ describe('OptimizerConfig::parseOptions()', () => { /x-pack/plugins, /plugins, /examples, + /x-pack/examples, -extra, ], "profileWebpack": false, diff --git a/packages/kbn-optimizer/src/optimizer/optimizer_config.ts b/packages/kbn-optimizer/src/optimizer/optimizer_config.ts index 1c8ae265bf6bb..7e1514058446b 100644 --- a/packages/kbn-optimizer/src/optimizer/optimizer_config.ts +++ b/packages/kbn-optimizer/src/optimizer/optimizer_config.ts @@ -91,14 +91,14 @@ export class OptimizerConfig { /** * BEWARE: this needs to stay roughly synchronized with - * `src/core/server/config/env.ts` which determins which paths + * `src/core/server/config/env.ts` which determines which paths * should be searched for plugins to load */ const pluginScanDirs = options.pluginScanDirs || [ Path.resolve(repoRoot, 'src/plugins'), ...(oss ? [] : [Path.resolve(repoRoot, 'x-pack/plugins')]), Path.resolve(repoRoot, 'plugins'), - ...(examples ? [Path.resolve('examples')] : []), + ...(examples ? [Path.resolve('examples'), Path.resolve('x-pack/examples')] : []), Path.resolve(repoRoot, '../kibana-extra'), ]; if (!pluginScanDirs.every(p => Path.isAbsolute(p))) { diff --git a/src/core/server/config/env.test.ts b/src/core/server/config/env.test.ts index c244012e34469..0fffcc44781d9 100644 --- a/src/core/server/config/env.test.ts +++ b/src/core/server/config/env.test.ts @@ -164,6 +164,17 @@ test('pluginSearchPaths contains examples plugins path if --run-examples flag is expect(env.pluginSearchPaths).toContain('/some/home/dir/examples'); }); +test('pluginSearchPaths contains x-pack/examples plugins path if --run-examples flag is true', () => { + const env = new Env( + '/some/home/dir', + getEnvOptions({ + cliArgs: { runExamples: true }, + }) + ); + + expect(env.pluginSearchPaths).toContain('/some/home/dir/x-pack/examples'); +}); + test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => { const env = new Env( '/some/home/dir', @@ -174,3 +185,14 @@ test('pluginSearchPaths does not contains examples plugins path if --run-example expect(env.pluginSearchPaths).not.toContain('/some/home/dir/examples'); }); + +test('pluginSearchPaths does not contains x-pack/examples plugins path if --run-examples flag is false', () => { + const env = new Env( + '/some/home/dir', + getEnvOptions({ + cliArgs: { runExamples: false }, + }) + ); + + expect(env.pluginSearchPaths).not.toContain('/some/home/dir/x-pack/examples'); +}); diff --git a/src/core/server/config/env.ts b/src/core/server/config/env.ts index 05a8f40a09a88..d8068c5b383fa 100644 --- a/src/core/server/config/env.ts +++ b/src/core/server/config/env.ts @@ -109,7 +109,9 @@ export class Env { resolve(this.homeDir, 'src', 'plugins'), ...(options.cliArgs.oss ? [] : [resolve(this.homeDir, 'x-pack', 'plugins')]), resolve(this.homeDir, 'plugins'), - ...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []), + ...(options.cliArgs.runExamples + ? [resolve(this.homeDir, 'examples'), resolve(this.homeDir, 'x-pack', 'examples')] + : []), resolve(this.homeDir, '..', 'kibana-extra'), ]; diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 7214741308262..01d8a30b598c1 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -44,6 +44,9 @@ export const PROJECTS = [ ...glob .sync('examples/*/tsconfig.json', { cwd: REPO_ROOT }) .map(path => new Project(resolve(REPO_ROOT, path))), + ...glob + .sync('x-pack/examples/*/tsconfig.json', { cwd: REPO_ROOT }) + .map(path => new Project(resolve(REPO_ROOT, path))), ...glob .sync('test/plugin_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT }) .map(path => new Project(resolve(REPO_ROOT, path))), diff --git a/x-pack/examples/README.md b/x-pack/examples/README.md new file mode 100644 index 0000000000000..babf744f9777d --- /dev/null +++ b/x-pack/examples/README.md @@ -0,0 +1,7 @@ +## Example plugins + +This folder contains X-Pack example plugins. To run the plugins in this folder, use the `--run-examples` flag, via + +``` +yarn start --run-examples +``` diff --git a/x-pack/examples/ui_actions_enhanced_examples/README.md b/x-pack/examples/ui_actions_enhanced_examples/README.md new file mode 100644 index 0000000000000..c9f53137d8687 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/README.md @@ -0,0 +1,3 @@ +## Ui actions enhanced examples + +To run this example, use the command `yarn start --run-examples`. diff --git a/x-pack/examples/ui_actions_enhanced_examples/kibana.json b/x-pack/examples/ui_actions_enhanced_examples/kibana.json new file mode 100644 index 0000000000000..f75852edced5c --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/kibana.json @@ -0,0 +1,10 @@ +{ + "id": "uiActionsEnhancedExamples", + "version": "0.0.1", + "kibanaVersion": "kibana", + "configPath": ["ui_actions_enhanced_examples"], + "server": false, + "ui": true, + "requiredPlugins": ["uiActions", "data"], + "optionalPlugins": [] +} diff --git a/x-pack/examples/ui_actions_enhanced_examples/package.json b/x-pack/examples/ui_actions_enhanced_examples/package.json new file mode 100644 index 0000000000000..a9f004b075cec --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/package.json @@ -0,0 +1,17 @@ +{ + "name": "ui_actions_enhanced_examples", + "version": "1.0.0", + "main": "target/examples/ui_actions_enhanced_examples", + "kibana": { + "version": "kibana", + "templateVersion": "1.0.0" + }, + "license": "Apache-2.0", + "scripts": { + "kbn": "node ../../scripts/kbn.js", + "build": "rm -rf './target' && tsc" + }, + "devDependencies": { + "typescript": "3.7.2" + } +} diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/index.ts b/x-pack/examples/ui_actions_enhanced_examples/public/index.ts new file mode 100644 index 0000000000000..7f3f36089d576 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/public/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UiActionsEnhancedExamplesPlugin } from './plugin'; + +export const plugin = () => new UiActionsEnhancedExamplesPlugin(); diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts b/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts new file mode 100644 index 0000000000000..a4c43753c8247 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin, CoreSetup, CoreStart } from '../../../../src/core/public'; +import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; +import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public'; + +export interface SetupDependencies { + data: DataPublicPluginSetup; + uiActions: UiActionsSetup; +} + +export interface StartDependencies { + data: DataPublicPluginStart; + uiActions: UiActionsStart; +} + +export class UiActionsEnhancedExamplesPlugin + implements Plugin { + public setup(core: CoreSetup, plugins: SetupDependencies) { + // eslint-disable-next-line + console.log('ui_actions_enhanced_examples'); + } + + public start(core: CoreStart, plugins: StartDependencies) {} + + public stop() {} +} diff --git a/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json new file mode 100644 index 0000000000000..d508076b33199 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "index.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../typings/**/*", + ], + "exclude": [] +}