Skip to content

Commit 9ed3fe0

Browse files
author
Stacey Gammon
authored
Add top level examples folder and command to run, --run-examples. (#52027) (#52739)
* Add top level examples folder and command to run, `--run-examples`. * Add comment explaining reason --run-examples flag turns off base path.
1 parent 138e976 commit 9ed3fe0

40 files changed

+155
-40
lines changed

.ci/packer_cache.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ tar -cf "$HOME/.kibana/bootstrap_cache/$branch.tar" \
4444
x-pack/legacy/plugins/*/node_modules \
4545
x-pack/legacy/plugins/reporting/.chromium \
4646
test/plugin_functional/plugins/*/node_modules \
47+
examples/*/node_modules \
4748
.es \
4849
.chromedriver \
4950
.geckodriver;

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Example plugins
2+
3+
This folder contains example plugins. To run the plugins in this folder, use the `--run-examples` flag, via
4+
5+
```
6+
yarn start --run-examples
7+
```
8+

examples/demo_search/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Demo search strategy
2+
3+
This example registers a custom search strategy that simply takes a name string in the request and returns the
4+
string `Hello {name}`
5+
6+
To see the demo search strategy in action, navigate to the `Search explorer` app.
7+
8+
To run these examples, use the command `yarn start --run-examples`.

test/plugin_functional/plugins/demo_search/common/index.ts renamed to examples/demo_search/common/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import {
21-
IKibanaSearchRequest,
22-
IKibanaSearchResponse,
23-
} from '../../../../../src/plugins/data/public';
20+
import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../../src/plugins/data/public';
2421

2522
export const DEMO_SEARCH_STRATEGY = 'DEMO_SEARCH_STRATEGY';
2623

test/plugin_functional/plugins/demo_search/package.json renamed to examples/demo_search/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"license": "Apache-2.0",
1010
"scripts": {
11-
"kbn": "node ../../../../scripts/kbn.js",
11+
"kbn": "node ../../scripts/kbn.js",
1212
"build": "rm -rf './target' && tsc"
1313
},
1414
"devDependencies": {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {
2222
ISearchContext,
2323
SYNC_SEARCH_STRATEGY,
2424
ISearchGeneric,
25-
} from '../../../../../src/plugins/data/public';
26-
import { TSearchStrategyProvider, ISearchStrategy } from '../../../../../src/plugins/data/public';
25+
} from '../../../src/plugins/data/public';
26+
import { TSearchStrategyProvider, ISearchStrategy } from '../../../src/plugins/data/public';
2727

2828
import { DEMO_SEARCH_STRATEGY, IDemoResponse } from '../common';
2929

test/plugin_functional/plugins/demo_search/public/plugin.ts renamed to examples/demo_search/public/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* under the License.
1818
*/
1919

20-
import { DataPublicPluginSetup } from '../../../../../src/plugins/data/public';
21-
import { Plugin, CoreSetup, PluginInitializerContext } from '../../../../../src/core/public';
20+
import { DataPublicPluginSetup } from '../../../src/plugins/data/public';
21+
import { Plugin, CoreSetup, PluginInitializerContext } from '../../../src/core/public';
2222
import { DEMO_SEARCH_STRATEGY } from '../common';
2323
import { demoClientSearchStrategyProvider } from './demo_search_strategy';
2424
import { IDemoRequest, IDemoResponse } from '../common';
@@ -36,7 +36,7 @@ interface DemoDataSearchSetupDependencies {
3636
* If the caller does not pass in the right `request` shape, typescript will
3737
* complain. The caller will also get a typed response.
3838
*/
39-
declare module '../../../../../src/plugins/data/public' {
39+
declare module '../../../src/plugins/data/public' {
4040
export interface IRequestTypesMap {
4141
[DEMO_SEARCH_STRATEGY]: IDemoRequest;
4242
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { TSearchStrategyProvider } from 'src/plugins/data/server';
20+
import { TSearchStrategyProvider } from '../../../src/plugins/data/server';
2121
import { DEMO_SEARCH_STRATEGY } from '../common';
2222

2323
export const demoSearchStrategyProvider: TSearchStrategyProvider<typeof DEMO_SEARCH_STRATEGY> = () => {

0 commit comments

Comments
 (0)