diff --git a/packages/kbn-plugin-generator/README.md b/packages/kbn-plugin-generator/README.md deleted file mode 100644 index 9ff9a8aa95ca..000000000000 --- a/packages/kbn-plugin-generator/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# Kibana Plugin Generator - -This package can be used to generate a Kibana plugin from the Kibana repo. - -## Setup - -Before you can use this plugin generator you must setup your [Kibana development environment](../../CONTRIBUTING.md#development-environment-setup). If you can successfully run `yarn kbn bootstrap` then you are ready to generate plugins! - -## Compatibility - -The plugin generator became a part of the Kibana project as of Kibana 6.3. If you are targeting versions **before Kibana 6.3** then use the [Kibana plugin sao template](https://github.com/elastic/template-kibana-plugin). - -If you are targeting **Kibana 6.3 or greater** then checkout the corresponding Kibana branch and run the plugin generator. - -## Quick Start - -To target the current development version of Kibana just use the default `master` branch. - -```sh -node scripts/generate_plugin --name my_plugin_name -y -# generates a plugin in `plugins/my_plugin_name` -``` - -To target 6.8, use the `6.8` branch. - -```sh -git checkout 6.x -yarn kbn bootstrap # always bootstrap when switching branches -node scripts/generate_plugin --name my_plugin_name -y -# generates a plugin for Kibana 6.8 in `../kibana-extra/my_plugin_name` -``` - -The generate script supports a few flags; run it with the `--help` flag to learn more. - -```sh -node scripts/generate_plugin --help -``` - -## Updating - -Since the Plugin Generator is now a part of the Kibana repo, when you update your local checkout of the Kibana repository and `bootstrap` everything should be up to date! - -> ***NOTE:*** These commands should be run from the Kibana repo, and `upstream` is our convention for the git remote that references https://github.com/elastic/kibana.git, unless you added this remote you might need to use `origin`. - -```sh -git pull upstream master -yarn kbn bootstrap -``` - -## Plugin Development Scripts - -Generated plugins receive a handful of scripts that can be used during development. Those scripts are detailed in the [README.md](template/README.md) file in each newly generated plugin, and expose the scripts provided by the [Kibana plugin helpers](../kbn-plugin-helpers), but here is a quick reference in case you need it: - -> ***NOTE:*** All of these scripts should be run from the generated plugin. - - - `yarn kbn bootstrap` - - Install dependencies and crosslink Kibana and all projects/plugins. - - > ***IMPORTANT:*** Use this script instead of `yarn` to install dependencies when switching branches, and re-run it whenever your dependencies change. - - - `yarn start` - - Start kibana and have it include this plugin. You can pass any arguments that you would normally send to `bin/kibana` - - ``` - yarn start --elasticsearch.hosts http://localhost:9220 - ``` - - - `yarn build` - - Build a distributable archive of your plugin. - - - `yarn test:mocha` - - Run the server tests using mocha. - -For more information about any of these commands run `yarn ${task} --help`. For a full list of tasks run `yarn run` or take a look in the `package.json` file. diff --git a/packages/kbn-plugin-generator/template/.eslintrc.js.ejs b/packages/kbn-plugin-generator/template/.eslintrc.js.ejs deleted file mode 100644 index d063fc481b71..000000000000 --- a/packages/kbn-plugin-generator/template/.eslintrc.js.ejs +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - root: true, - extends: [ - '@elastic/eslint-config-kibana', - 'plugin:@elastic/eui/recommended' - ], - rules: { - '@kbn/eslint/require-license-header': 'off', - }, -}; diff --git a/packages/kbn-plugin-generator/template/README.md.ejs b/packages/kbn-plugin-generator/template/README.md.ejs deleted file mode 100755 index 2cd19c904263..000000000000 --- a/packages/kbn-plugin-generator/template/README.md.ejs +++ /dev/null @@ -1,20 +0,0 @@ -# <%= name %> - -A Kibana plugin - ---- - -## Development - -See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. - -<% if (thirdPartyPlugin) { %> -## Scripts -
-
yarn kbn bootstrap
-
Execute this to install node_modules and setup the dependencies in your plugin and in Kibana
- -
yarn plugin-helpers build
-
Execute this to create a distributable version of this plugin that can be installed in Kibana
-
-<% } %> diff --git a/packages/kbn-plugin-generator/template/kibana.json.ejs b/packages/kbn-plugin-generator/template/kibana.json.ejs deleted file mode 100644 index 698a394e0d0b..000000000000 --- a/packages/kbn-plugin-generator/template/kibana.json.ejs +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "<%= camelCase(name) %>", - "version": "1.0.0", - "kibanaVersion": "kibana", - "server": <%= hasServer %>, - "ui": <%= hasUi %>, - "requiredPlugins": ["navigation"], - "optionalPlugins": [] -} diff --git a/packages/kbn-plugin-generator/template/package.json.ejs b/packages/kbn-plugin-generator/template/package.json.ejs deleted file mode 100644 index ab234b1df2bc..000000000000 --- a/packages/kbn-plugin-generator/template/package.json.ejs +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "<%= camelCase(name) %>", - "version": "0.0.0", - "private": true, - "scripts": { - "build": "yarn plugin-helpers build", - "plugin-helpers": "node ../../scripts/plugin_helpers", - "kbn": "node ../../scripts/kbn" - } -} diff --git a/packages/kbn-plugin-generator/template/public/components/app.tsx.ejs b/packages/kbn-plugin-generator/template/public/components/app.tsx.ejs deleted file mode 100644 index c3e33788464f..000000000000 --- a/packages/kbn-plugin-generator/template/public/components/app.tsx.ejs +++ /dev/null @@ -1,113 +0,0 @@ -import React, { useState } from 'react'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { BrowserRouter as Router } from 'react-router-dom'; - -import { - EuiButton, - EuiHorizontalRule, - EuiPage, - EuiPageBody, - EuiPageContent, - EuiPageContentBody, - EuiPageContentHeader, - EuiPageHeader, - EuiTitle, - EuiText, -} from '@elastic/eui'; - -import { CoreStart } from '<%= importFromRoot('src/core/public') %>'; -import { NavigationPublicPluginStart } from '<%= importFromRoot('src/plugins/navigation/public') %>'; - -import { PLUGIN_ID, PLUGIN_NAME } from '../../common'; - -interface <%= upperCamelCase(name) %>AppDeps { - basename: string; - notifications: CoreStart['notifications']; - http: CoreStart['http']; - navigation: NavigationPublicPluginStart; -} - -export const <%= upperCamelCase(name) %>App = ({ basename, notifications, http, navigation }: <%= upperCamelCase(name) %>AppDeps) => { - // Use React hooks to manage state. - const [timestamp, setTimestamp] = useState(); - - const onClickHandler = () => { - <% if (hasServer) { %> - // Use the core http service to make a response to the server API. - http.get('/api/<%= snakeCase(name) %>/example').then(res => { - setTimestamp(res.time); - // Use the core notifications service to display a success message. - notifications.toasts.addSuccess(i18n.translate('<%= camelCase(name) %>.dataUpdated', { - defaultMessage: 'Data updated', - })); - }); - <% } else { %> - setTimestamp(new Date().toISOString()); - notifications.toasts.addSuccess(PLUGIN_NAME); - <% } %> - }; - - // Render the application DOM. - // Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` plugin's start contract. - return ( - - - <> - - - - - -

- -

-
-
- - - -

- -

-
-
- - -

- -

- -

- -

- - - -
-
-
-
-
- -
-
- ); -}; diff --git a/packages/kbn-plugin-generator/template/public/index.ts.ejs b/packages/kbn-plugin-generator/template/public/index.ts.ejs deleted file mode 100644 index f859f34bee2e..000000000000 --- a/packages/kbn-plugin-generator/template/public/index.ts.ejs +++ /dev/null @@ -1,14 +0,0 @@ -import './index.scss'; - -import { <%= upperCamelCase(name) %>Plugin } from './plugin'; - -// This exports static code and TypeScript types, -// as well as, Kibana Platform `plugin()` initializer. -export function plugin() { - return new <%= upperCamelCase(name) %>Plugin(); -} -export { - <%= upperCamelCase(name) %>PluginSetup, - <%= upperCamelCase(name) %>PluginStart, -} from './types'; - diff --git a/packages/kbn-plugin-generator/template/public/plugin.ts.ejs b/packages/kbn-plugin-generator/template/public/plugin.ts.ejs deleted file mode 100644 index 1090430ab7f8..000000000000 --- a/packages/kbn-plugin-generator/template/public/plugin.ts.ejs +++ /dev/null @@ -1,42 +0,0 @@ -import { i18n } from '@kbn/i18n'; -import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '<%= importFromRoot('src/core/public') %>'; -import { <%= upperCamelCase(name) %>PluginSetup, <%= upperCamelCase(name) %>PluginStart, AppPluginStartDependencies } from './types'; -import { PLUGIN_NAME } from '../common'; - -export class <%= upperCamelCase(name) %>Plugin - implements Plugin<<%= upperCamelCase(name) %>PluginSetup, <%= upperCamelCase(name) %>PluginStart> { - - public setup(core: CoreSetup): <%= upperCamelCase(name) %>PluginSetup { - // Register an application into the side navigation menu - core.application.register({ - id: '<%= camelCase(name) %>', - title: PLUGIN_NAME, - async mount(params: AppMountParameters) { - // Load application bundle - const { renderApp } = await import('./application'); - // Get start services as specified in kibana.json - const [coreStart, depsStart] = await core.getStartServices(); - // Render the application - return renderApp(coreStart, depsStart as AppPluginStartDependencies, params); - }, - }); - - // Return methods that should be available to other plugins - return { - getGreeting() { - return i18n.translate('<%= camelCase(name) %>.greetingText', { - defaultMessage: 'Hello from {name}!', - values: { - name: PLUGIN_NAME, - }, - }); - }, - }; - } - - public start(core: CoreStart): <%= upperCamelCase(name) %>PluginStart { - return {}; - } - - public stop() {} -} diff --git a/packages/kbn-plugin-generator/template/server/index.ts.ejs b/packages/kbn-plugin-generator/template/server/index.ts.ejs deleted file mode 100644 index f6b40f2ee064..000000000000 --- a/packages/kbn-plugin-generator/template/server/index.ts.ejs +++ /dev/null @@ -1,15 +0,0 @@ -import { PluginInitializerContext } from '<%= importFromRoot('src/core/server') %>'; -import { <%= upperCamelCase(name) %>Plugin } from './plugin'; - - -// This exports static code and TypeScript types, -// as well as, Kibana Platform `plugin()` initializer. - - export function plugin(initializerContext: PluginInitializerContext) { - return new <%= upperCamelCase(name) %>Plugin(initializerContext); -} - -export { - <%= upperCamelCase(name) %>PluginSetup, - <%= upperCamelCase(name) %>PluginStart, -} from './types'; diff --git a/packages/osd-plugin-generator/README.md b/packages/osd-plugin-generator/README.md new file mode 100644 index 000000000000..3abfeeee3b2b --- /dev/null +++ b/packages/osd-plugin-generator/README.md @@ -0,0 +1,78 @@ +# OpenSearch Dashboards Plugin Generator + +This package can be used to generate a OpenSearch Dashboards plugin from the OpenSearch Dashboards repo. + +## Setup + +Before you can use this plugin generator you must setup your [OpenSearch Dashboards development environment](../../CONTRIBUTING.md#development-environment-setup). If you can successfully run `yarn osd bootstrap` then you are ready to generate plugins! + +## Compatibility + +The plugin generator became a part of the OpenSearch Dashboards project as of OpenSearch Dashboards 6.3. If you are targeting versions **before OpenSearch Dashboards 6.3** then use the [Kibana plugin sao template](https://github.com/elastic/template-kibana-plugin). + +If you are targeting **OpenSearch Dashboards 6.3 or greater** then checkout the corresponding OpenSearch Dashboards branch and run the plugin generator. + +## Quick Start + +To target the current development version of OpenSearch Dashboards just use the default `master` branch. + +```sh +node scripts/generate_plugin --name my_plugin_name -y +# generates a plugin in `plugins/my_plugin_name` +``` + +To target 6.8, use the `6.8` branch. + +```sh +git checkout 6.x +yarn osd bootstrap # always bootstrap when switching branches +node scripts/generate_plugin --name my_plugin_name -y +# generates a plugin for OpenSearch Dashboards 6.8 in `../opensearch-dashboards-extra/my_plugin_name` +``` + +The generate script supports a few flags; run it with the `--help` flag to learn more. + +```sh +node scripts/generate_plugin --help +``` + +## Updating + +Since the Plugin Generator is now a part of the OpenSearch Dashboards repo, when you update your local checkout of the OpenSearch Dashboards repository and `bootstrap` everything should be up to date! + +> ***NOTE:*** These commands should be run from the OpenSearch Dashboards repo, and `upstream` is our convention for the git remote that references https://github.com/elastic/kibana.git, unless you added this remote you might need to use `origin`. + +```sh +git pull upstream master +yarn osd bootstrap +``` + +## Plugin Development Scripts + +Generated plugins receive a handful of scripts that can be used during development. Those scripts are detailed in the [README.md](template/README.md) file in each newly generated plugin, and expose the scripts provided by the [OpenSearch Dashboards plugin helpers](../osd-plugin-helpers), but here is a quick reference in case you need it: + +> ***NOTE:*** All of these scripts should be run from the generated plugin. + + - `yarn osd bootstrap` + + Install dependencies and crosslink OpenSearch Dashboards and all projects/plugins. + + > ***IMPORTANT:*** Use this script instead of `yarn` to install dependencies when switching branches, and re-run it whenever your dependencies change. + + - `yarn start` + + Start OpenSearch Dashboards and have it include this plugin. You can pass any arguments that you would normally send to `bin/opensearch-dashboards` + + ``` + yarn start --opensearch.hosts http://localhost:9220 + ``` + + - `yarn build` + + Build a distributable archive of your plugin. + + - `yarn test:mocha` + + Run the server tests using mocha. + +For more information about any of these commands run `yarn ${task} --help`. For a full list of tasks run `yarn run` or take a look in the `package.json` file. diff --git a/packages/kbn-plugin-generator/package.json b/packages/osd-plugin-generator/package.json similarity index 74% rename from packages/kbn-plugin-generator/package.json rename to packages/osd-plugin-generator/package.json index 1d9637c8279d..9c9c1f26177d 100644 --- a/packages/kbn-plugin-generator/package.json +++ b/packages/osd-plugin-generator/package.json @@ -1,15 +1,15 @@ { - "name": "@kbn/plugin-generator", + "name": "@osd/plugin-generator", "version": "1.0.0", "private": true, "license": "Apache-2.0", "main": "target/index.js", "scripts": { - "kbn:bootstrap": "node scripts/build", - "kbn:watch": "node scripts/build --watch" + "osd:bootstrap": "node scripts/build", + "osd:watch": "node scripts/build --watch" }, "dependencies": { - "@kbn/dev-utils": "1.0.0", + "@osd/dev-utils": "1.0.0", "ejs": "^3.1.5", "execa": "^4.0.2", "inquirer": "^7.3.3", diff --git a/packages/kbn-plugin-generator/scripts/build.js b/packages/osd-plugin-generator/scripts/build.js similarity index 96% rename from packages/kbn-plugin-generator/scripts/build.js rename to packages/osd-plugin-generator/scripts/build.js index 2c252a064866..d9600e856607 100644 --- a/packages/kbn-plugin-generator/scripts/build.js +++ b/packages/osd-plugin-generator/scripts/build.js @@ -19,7 +19,7 @@ const Path = require('path'); -const { run } = require('@kbn/dev-utils'); +const { run } = require('@osd/dev-utils'); const del = require('del'); const execa = require('execa'); diff --git a/packages/kbn-plugin-generator/src/ask_questions.ts b/packages/osd-plugin-generator/src/ask_questions.ts similarity index 90% rename from packages/kbn-plugin-generator/src/ask_questions.ts rename to packages/osd-plugin-generator/src/ask_questions.ts index 732e22b0e222..06c9f6827ed5 100644 --- a/packages/kbn-plugin-generator/src/ask_questions.ts +++ b/packages/osd-plugin-generator/src/ask_questions.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; import inquirer from 'inquirer'; export interface Answers { @@ -32,15 +32,15 @@ export interface Answers { export const INTERNAL_PLUGIN_LOCATIONS: Array<{ name: string; value: string }> = [ { - name: 'Kibana Example', + name: 'OpenSearch Dashboards Example', value: Path.resolve(REPO_ROOT, 'examples'), }, { - name: 'Kibana OSS', + name: 'OpenSearch Dashboards OSS', value: Path.resolve(REPO_ROOT, 'src/plugins'), }, { - name: 'Kibana OSS Functional Testing', + name: 'OpenSearch Dashboards OSS Functional Testing', value: Path.resolve(REPO_ROOT, 'test/plugin_functional/plugins'), }, { @@ -63,7 +63,7 @@ export const QUESTIONS = [ { name: 'internal', type: 'confirm', - message: 'Will this plugin be part of the Kibana repository?', + message: 'Will this plugin be part of the OpenSearch Dashboards repository?', default: false, }, { diff --git a/packages/kbn-plugin-generator/src/casing.test.ts b/packages/osd-plugin-generator/src/casing.test.ts similarity index 100% rename from packages/kbn-plugin-generator/src/casing.test.ts rename to packages/osd-plugin-generator/src/casing.test.ts diff --git a/packages/kbn-plugin-generator/src/casing.ts b/packages/osd-plugin-generator/src/casing.ts similarity index 100% rename from packages/kbn-plugin-generator/src/casing.ts rename to packages/osd-plugin-generator/src/casing.ts diff --git a/packages/kbn-plugin-generator/src/cli.ts b/packages/osd-plugin-generator/src/cli.ts similarity index 94% rename from packages/kbn-plugin-generator/src/cli.ts rename to packages/osd-plugin-generator/src/cli.ts index 14c910a943fd..2a57828da3b6 100644 --- a/packages/kbn-plugin-generator/src/cli.ts +++ b/packages/osd-plugin-generator/src/cli.ts @@ -21,8 +21,8 @@ import Path from 'path'; import Fs from 'fs'; import execa from 'execa'; -import { REPO_ROOT } from '@kbn/utils'; -import { run, createFailError, createFlagError } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@osd/utils'; +import { run, createFailError, createFlagError } from '@osd/dev-utils'; import { snakeCase } from './casing'; import { askQuestions, getDefaultAnswers } from './ask_questions'; @@ -73,7 +73,7 @@ export function runCli() { { usage: 'node scripts/generate_plugin', description: ` - Generate a fresh Kibana plugin in the plugins/ directory + Generate a fresh OpenSearch Dashboards plugin in the plugins/ directory `, flags: { string: ['name'], diff --git a/packages/kbn-plugin-generator/src/index.ts b/packages/osd-plugin-generator/src/index.ts similarity index 100% rename from packages/kbn-plugin-generator/src/index.ts rename to packages/osd-plugin-generator/src/index.ts diff --git a/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts b/packages/osd-plugin-generator/src/integration_tests/generate_plugin.test.ts similarity index 94% rename from packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts rename to packages/osd-plugin-generator/src/integration_tests/generate_plugin.test.ts index 25669b65e1ac..87b2f90f029e 100644 --- a/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts +++ b/packages/osd-plugin-generator/src/integration_tests/generate_plugin.test.ts @@ -21,8 +21,8 @@ import Path from 'path'; import del from 'del'; import execa from 'execa'; -import { REPO_ROOT } from '@kbn/utils'; -import { createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@osd/utils'; +import { createAbsolutePathSerializer } from '@osd/dev-utils'; import globby from 'globby'; const GENERATED_DIR = Path.resolve(REPO_ROOT, `plugins`); @@ -57,7 +57,7 @@ it('generates a plugin', async () => { /plugins/foo/.gitignore, /plugins/foo/.i18nrc.json, /plugins/foo/common/index.ts, - /plugins/foo/kibana.json, + /plugins/foo/opensearch_dashboards.json, /plugins/foo/package.json, /plugins/foo/public/application.tsx, /plugins/foo/public/components/app.tsx, @@ -96,7 +96,7 @@ it('generates a plugin without UI', async () => { /plugins/bar/.gitignore, /plugins/bar/.i18nrc.json, /plugins/bar/common/index.ts, - /plugins/bar/kibana.json, + /plugins/bar/opensearch_dashboards.json, /plugins/bar/package.json, /plugins/bar/README.md, /plugins/bar/server/index.ts, @@ -128,7 +128,7 @@ it('generates a plugin without server plugin', async () => { /plugins/baz/.gitignore, /plugins/baz/.i18nrc.json, /plugins/baz/common/index.ts, - /plugins/baz/kibana.json, + /plugins/baz/opensearch_dashboards.json, /plugins/baz/package.json, /plugins/baz/public/application.tsx, /plugins/baz/public/components/app.tsx, diff --git a/packages/kbn-plugin-generator/src/plugin_types.ts b/packages/osd-plugin-generator/src/plugin_types.ts similarity index 90% rename from packages/kbn-plugin-generator/src/plugin_types.ts rename to packages/osd-plugin-generator/src/plugin_types.ts index 778e33353a2a..53cdf96a7183 100644 --- a/packages/kbn-plugin-generator/src/plugin_types.ts +++ b/packages/osd-plugin-generator/src/plugin_types.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/utils'; +import { REPO_ROOT } from '@osd/utils'; export interface PluginType { thirdParty: boolean; @@ -32,15 +32,15 @@ export const PLUGIN_TYPE_OPTIONS: Array<{ name: string; value: PluginType }> = [ value: { thirdParty: true, installDir: Path.resolve(REPO_ROOT, 'plugins') }, }, { - name: 'Kibana Example', + name: 'OpenSearch Dashboards Example', value: { thirdParty: false, installDir: Path.resolve(REPO_ROOT, 'examples') }, }, { - name: 'Kibana OSS', + name: 'OpenSearch Dashboards OSS', value: { thirdParty: false, installDir: Path.resolve(REPO_ROOT, 'src/plugins') }, }, { - name: 'Kibana OSS Functional Testing', + name: 'OpenSearch Dashboards OSS Functional Testing', value: { thirdParty: false, installDir: Path.resolve(REPO_ROOT, 'test/plugin_functional/plugins'), diff --git a/packages/kbn-plugin-generator/src/render_template.ts b/packages/osd-plugin-generator/src/render_template.ts similarity index 97% rename from packages/kbn-plugin-generator/src/render_template.ts rename to packages/osd-plugin-generator/src/render_template.ts index ecb168042b1c..003c8537f97f 100644 --- a/packages/kbn-plugin-generator/src/render_template.ts +++ b/packages/osd-plugin-generator/src/render_template.ts @@ -23,8 +23,8 @@ import { promisify } from 'util'; import vfs from 'vinyl-fs'; import prettier from 'prettier'; -import { REPO_ROOT } from '@kbn/utils'; -import { transformFileStream } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@osd/utils'; +import { transformFileStream } from '@osd/dev-utils'; import ejs from 'ejs'; import { Minimatch } from 'minimatch'; diff --git a/packages/osd-plugin-generator/template/.eslintrc.js.ejs b/packages/osd-plugin-generator/template/.eslintrc.js.ejs new file mode 100644 index 000000000000..45a5c8e230a7 --- /dev/null +++ b/packages/osd-plugin-generator/template/.eslintrc.js.ejs @@ -0,0 +1,10 @@ +module.exports = { +root: true, +extends: [ +'@elastic/eslint-config-kibana', +'plugin:@elastic/eui/recommended' +], +rules: { +'@osd/eslint/require-license-header': 'off', +}, +}; \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/.gitignore b/packages/osd-plugin-generator/template/.gitignore similarity index 100% rename from packages/kbn-plugin-generator/template/.gitignore rename to packages/osd-plugin-generator/template/.gitignore diff --git a/packages/kbn-plugin-generator/template/.i18nrc.json.ejs b/packages/osd-plugin-generator/template/.i18nrc.json.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/.i18nrc.json.ejs rename to packages/osd-plugin-generator/template/.i18nrc.json.ejs diff --git a/packages/osd-plugin-generator/template/README.md.ejs b/packages/osd-plugin-generator/template/README.md.ejs new file mode 100755 index 000000000000..71f3e609a42c --- /dev/null +++ b/packages/osd-plugin-generator/template/README.md.ejs @@ -0,0 +1,23 @@ +# <%= name %> + + A OpenSearch Dashboards plugin + + --- + + ## Development + + See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions + setting up your development environment. + + <% if (thirdPartyPlugin) { %> + ## Scripts +
+
yarn osd bootstrap
+
Execute this to install node_modules and setup the dependencies in your plugin and in OpenSearch Dashboards +
+ +
yarn plugin-helpers build
+
Execute this to create a distributable version of this plugin that can be installed in OpenSearch Dashboards +
+
+ <% } %> \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/common/index.ts.ejs b/packages/osd-plugin-generator/template/common/index.ts.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/common/index.ts.ejs rename to packages/osd-plugin-generator/template/common/index.ts.ejs diff --git a/packages/osd-plugin-generator/template/opensearch_dashboards.json.ejs b/packages/osd-plugin-generator/template/opensearch_dashboards.json.ejs new file mode 100644 index 000000000000..2e046313cb5f --- /dev/null +++ b/packages/osd-plugin-generator/template/opensearch_dashboards.json.ejs @@ -0,0 +1,9 @@ +{ +"id": "<%= camelCase(name) %>", + "version": "1.0.0", + "opensearchDashboardsVersion": "opensearchDashboards", + "server": <%= hasServer %>, + "ui": <%= hasUi %>, + "requiredPlugins": ["navigation"], + "optionalPlugins": [] + } \ No newline at end of file diff --git a/packages/osd-plugin-generator/template/package.json.ejs b/packages/osd-plugin-generator/template/package.json.ejs new file mode 100644 index 000000000000..649fe19073c8 --- /dev/null +++ b/packages/osd-plugin-generator/template/package.json.ejs @@ -0,0 +1,10 @@ +{ +"name": "<%= camelCase(name) %>", + "version": "0.0.0", + "private": true, + "scripts": { + "build": "yarn plugin-helpers build", + "plugin-helpers": "node ../../scripts/plugin_helpers", + "osd": "node ../../scripts/osd" + } + } \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/public/application.tsx.ejs b/packages/osd-plugin-generator/template/public/application.tsx.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/public/application.tsx.ejs rename to packages/osd-plugin-generator/template/public/application.tsx.ejs diff --git a/packages/osd-plugin-generator/template/public/components/app.tsx.ejs b/packages/osd-plugin-generator/template/public/components/app.tsx.ejs new file mode 100644 index 000000000000..f6dfe2cc3eb2 --- /dev/null +++ b/packages/osd-plugin-generator/template/public/components/app.tsx.ejs @@ -0,0 +1,105 @@ +import React, { useState } from 'react'; +import { i18n } from '@osd/i18n'; +import { FormattedMessage, I18nProvider } from '@osd/i18n/react'; +import { BrowserRouter as Router } from 'react-router-dom'; + +import { +EuiButton, +EuiHorizontalRule, +EuiPage, +EuiPageBody, +EuiPageContent, +EuiPageContentBody, +EuiPageContentHeader, +EuiPageHeader, +EuiTitle, +EuiText, +} from '@elastic/eui'; + +import { CoreStart } from '<%= importFromRoot('src/core/public') %>'; + import { NavigationPublicPluginStart } from '<%= importFromRoot('src/plugins/navigation/public') %>'; + + import { PLUGIN_ID, PLUGIN_NAME } from '../../common'; + + interface <%= upperCamelCase(name) %>AppDeps { + basename: string; + notifications: CoreStart['notifications']; + http: CoreStart['http']; + navigation: NavigationPublicPluginStart; + } + + export const <%= upperCamelCase(name) %>App = ({ basename, notifications, http, navigation }: <%= + upperCamelCase(name) %>AppDeps) => { + // Use React hooks to manage state. + const [timestamp, setTimestamp] = useState(); + + const onClickHandler = () => { + <% if (hasServer) { %> + // Use the core http service to make a response to the server API. + http.get('/api/<%= snakeCase(name) %>/example').then(res => { + setTimestamp(res.time); + // Use the core notifications service to display a success message. + notifications.toasts.addSuccess(i18n.translate('<%= camelCase(name) %>.dataUpdated', { + defaultMessage: 'Data updated', + })); + }); + <% } else { %> + setTimestamp(new Date().toISOString()); + notifications.toasts.addSuccess(PLUGIN_NAME); + <% } %> + }; + + // Render the application DOM. + // Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` + plugin's start contract. + return ( + + + <> + + + + + +

+ +

+
+
+ + + +

+ +

+
+
+ + +

+ +

+ +

+ +

+ + + +
+
+
+
+
+ +
+
+ ); + }; \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/public/index.scss b/packages/osd-plugin-generator/template/public/index.scss similarity index 100% rename from packages/kbn-plugin-generator/template/public/index.scss rename to packages/osd-plugin-generator/template/public/index.scss diff --git a/packages/osd-plugin-generator/template/public/index.ts.ejs b/packages/osd-plugin-generator/template/public/index.ts.ejs new file mode 100644 index 000000000000..200d4b2c25c0 --- /dev/null +++ b/packages/osd-plugin-generator/template/public/index.ts.ejs @@ -0,0 +1,13 @@ +import './index.scss'; + +import { <%= upperCamelCase(name) %>Plugin } from './plugin'; + + // This exports static code and TypeScript types, + // as well as, OpenSearch Dashboards Platform `plugin()` initializer. + export function plugin() { + return new <%= upperCamelCase(name) %>Plugin(); + } + export { + <%= upperCamelCase(name) %>PluginSetup, + <%= upperCamelCase(name) %>PluginStart, + } from './types'; \ No newline at end of file diff --git a/packages/osd-plugin-generator/template/public/plugin.ts.ejs b/packages/osd-plugin-generator/template/public/plugin.ts.ejs new file mode 100644 index 000000000000..e6b801c0d85f --- /dev/null +++ b/packages/osd-plugin-generator/template/public/plugin.ts.ejs @@ -0,0 +1,43 @@ +import { i18n } from '@osd/i18n'; +import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '<%= importFromRoot('src/core/public') %>'; + import { <%= upperCamelCase(name) %>PluginSetup, <%= upperCamelCase(name) %>PluginStart, AppPluginStartDependencies } + from './types'; + import { PLUGIN_NAME } from '../common'; + + export class <%= upperCamelCase(name) %>Plugin + implements Plugin<<%= upperCamelCase(name) %>PluginSetup, <%= upperCamelCase(name) %>PluginStart> { + + public setup(core: CoreSetup): <%= upperCamelCase(name) %>PluginSetup { + // Register an application into the side navigation menu + core.application.register({ + id: '<%= camelCase(name) %>', + title: PLUGIN_NAME, + async mount(params: AppMountParameters) { + // Load application bundle + const { renderApp } = await import('./application'); + // Get start services as specified in opensearch_dashboards.json + const [coreStart, depsStart] = await core.getStartServices(); + // Render the application + return renderApp(coreStart, depsStart as AppPluginStartDependencies, params); + }, + }); + + // Return methods that should be available to other plugins + return { + getGreeting() { + return i18n.translate('<%= camelCase(name) %>.greetingText', { + defaultMessage: 'Hello from {name}!', + values: { + name: PLUGIN_NAME, + }, + }); + }, + }; + } + + public start(core: CoreStart): <%= upperCamelCase(name) %>PluginStart { + return {}; + } + + public stop() {} + } \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/public/types.ts.ejs b/packages/osd-plugin-generator/template/public/types.ts.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/public/types.ts.ejs rename to packages/osd-plugin-generator/template/public/types.ts.ejs diff --git a/packages/osd-plugin-generator/template/server/index.ts.ejs b/packages/osd-plugin-generator/template/server/index.ts.ejs new file mode 100644 index 000000000000..70f0d2010c6a --- /dev/null +++ b/packages/osd-plugin-generator/template/server/index.ts.ejs @@ -0,0 +1,15 @@ +import { PluginInitializerContext } from '<%= importFromRoot('src/core/server') %>'; + import { <%= upperCamelCase(name) %>Plugin } from './plugin'; + + + // This exports static code and TypeScript types, + // as well as, OpenSearch Dashboards Platform `plugin()` initializer. + + export function plugin(initializerContext: PluginInitializerContext) { + return new <%= upperCamelCase(name) %>Plugin(initializerContext); + } + + export { + <%= upperCamelCase(name) %>PluginSetup, + <%= upperCamelCase(name) %>PluginStart, + } from './types'; \ No newline at end of file diff --git a/packages/kbn-plugin-generator/template/server/plugin.ts.ejs b/packages/osd-plugin-generator/template/server/plugin.ts.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/server/plugin.ts.ejs rename to packages/osd-plugin-generator/template/server/plugin.ts.ejs diff --git a/packages/kbn-plugin-generator/template/server/routes/index.ts.ejs b/packages/osd-plugin-generator/template/server/routes/index.ts.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/server/routes/index.ts.ejs rename to packages/osd-plugin-generator/template/server/routes/index.ts.ejs diff --git a/packages/kbn-plugin-generator/template/server/types.ts.ejs b/packages/osd-plugin-generator/template/server/types.ts.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/server/types.ts.ejs rename to packages/osd-plugin-generator/template/server/types.ts.ejs diff --git a/packages/kbn-plugin-generator/template/translations/ja-JP.json.ejs b/packages/osd-plugin-generator/template/translations/ja-JP.json.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/translations/ja-JP.json.ejs rename to packages/osd-plugin-generator/template/translations/ja-JP.json.ejs diff --git a/packages/kbn-plugin-generator/template/tsconfig.json.ejs b/packages/osd-plugin-generator/template/tsconfig.json.ejs similarity index 100% rename from packages/kbn-plugin-generator/template/tsconfig.json.ejs rename to packages/osd-plugin-generator/template/tsconfig.json.ejs diff --git a/packages/kbn-plugin-generator/tsconfig.json b/packages/osd-plugin-generator/tsconfig.json similarity index 100% rename from packages/kbn-plugin-generator/tsconfig.json rename to packages/osd-plugin-generator/tsconfig.json diff --git a/packages/kbn-plugin-generator/yarn.lock b/packages/osd-plugin-generator/yarn.lock similarity index 100% rename from packages/kbn-plugin-generator/yarn.lock rename to packages/osd-plugin-generator/yarn.lock