From faf1bc9119ef87159f3838a5bbf1b5df81f178de Mon Sep 17 00:00:00 2001 From: Bishoy Boktor Date: Tue, 9 Feb 2021 21:09:20 +0000 Subject: [PATCH 1/2] Add missing brace lost during merge conflict --- src/plugins/data/kibana.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/data/kibana.json b/src/plugins/data/kibana.json index d110c2613d24..635799d12d9c 100644 --- a/src/plugins/data/kibana.json +++ b/src/plugins/data/kibana.json @@ -7,4 +7,5 @@ "optionalPlugins": [], "extraPublicDirs": ["common", "common/utils/abort_utils"], "requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"] +} From 1fb5a078a9a30e848e1f35aa204847dc7e43f094 Mon Sep 17 00:00:00 2001 From: Bishoy Boktor Date: Thu, 4 Mar 2021 21:13:07 +0000 Subject: [PATCH 2/2] Rename kbn-plugin-helpers to osd-plugin-helpers (#37) Signed-off-by: Bishoy Boktor --- .../README.md | 38 +++++++------- .../package.json | 14 ++--- .../src/build_context.ts | 6 +-- .../src/cli.ts | 42 +++++++-------- .../src/config.ts | 6 +-- .../src/find_opensearch_dashboards_json.ts} | 6 +-- .../src/index.ts | 0 .../src/integration_tests/build.test.ts | 48 ++++++++--------- ..._opensearch_dashboards_platform_plugin.ts} | 12 ++--- .../resolve_opensearch_dashboards_version.ts} | 14 ++--- .../src/tasks/clean.ts | 0 .../src/tasks/create_archive.ts | 8 +-- .../src/tasks/index.ts | 0 .../src/tasks/optimize.ts | 6 +-- .../src/tasks/write_public_assets.ts | 0 .../src/tasks/write_server_files.ts | 52 +++++++++---------- .../src/tasks/yarn_install.ts | 0 .../tsconfig.json | 0 .../yarn.lock | 0 19 files changed, 126 insertions(+), 126 deletions(-) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/README.md (52%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/package.json (67%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/build_context.ts (86%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/cli.ts (64%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/config.ts (92%) rename packages/{kbn-plugin-helpers/src/find_kibana_json.ts => osd-plugin-helpers/src/find_opensearch_dashboards_json.ts} (82%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/index.ts (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/integration_tests/build.test.ts (68%) rename packages/{kbn-plugin-helpers/src/load_kibana_platform_plugin.ts => osd-plugin-helpers/src/load_opensearch_dashboards_platform_plugin.ts} (72%) rename packages/{kbn-plugin-helpers/src/resolve_kibana_version.ts => osd-plugin-helpers/src/resolve_opensearch_dashboards_version.ts} (64%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/clean.ts (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/create_archive.ts (84%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/index.ts (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/optimize.ts (94%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/write_public_assets.ts (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/write_server_files.ts (63%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/src/tasks/yarn_install.ts (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/tsconfig.json (100%) rename packages/{kbn-plugin-helpers => osd-plugin-helpers}/yarn.lock (100%) diff --git a/packages/kbn-plugin-helpers/README.md b/packages/osd-plugin-helpers/README.md similarity index 52% rename from packages/kbn-plugin-helpers/README.md rename to packages/osd-plugin-helpers/README.md index 05eb9f599873..4ad17f40e310 100644 --- a/packages/kbn-plugin-helpers/README.md +++ b/packages/osd-plugin-helpers/README.md @@ -1,10 +1,10 @@ -# @kbn/plugin-helpers +# @osd/plugin-helpers -Just some helpers for kibana plugin devs. +Just some helpers for OpenSearch Dashboards plugin devs. ## Installation -You don't actually need to install the plugin helpers, they are automatically inherited from the Kibana project by building your plugin within the Kibana repo. To use the plugin helpers just create the needed npm scripts on your plugin's `package.json` (as exemplified below) which +You don't actually need to install the plugin helpers, they are automatically inherited from the OpenSearch Dashboards project by building your plugin within the OpenSearch Dashboards repo. To use the plugin helpers just create the needed npm scripts on your plugin's `package.json` (as exemplified below) which is already the case if you use the new `node scripts/generate_plugin` script. ```json @@ -12,7 +12,7 @@ is already the case if you use the new `node scripts/generate_plugin` script. "scripts" : { "build": "yarn plugin-helpers build", "plugin-helpers": "node ../../scripts/plugin_helpers", - "kbn": "node ../../scripts/kbn" + "osd": "node ../../scripts/osd" } } ``` @@ -20,15 +20,15 @@ is already the case if you use the new `node scripts/generate_plugin` script. This will make it easier to execute the `plugin-helpers` script from within your plugin repository. ```sh -yarn kbn bootstrap +yarn osd bootstrap ``` ## Usage -This simple CLI has a build task that plugin devs can run from to easily package Kibana plugins. +This simple CLI has a build task that plugin devs can run from to easily package OpenSearch Dashboards plugins. Previously you could also use that tool to start and test your plugin. Currently you can run -your plugin along with Kibana running `yarn start` in the Kibana repository root folder. Finally to test +your plugin along with OpenSearch Dashboards running `yarn start` in the OpenSearch Dashboards repository root folder. Finally to test your plugin you should now configure and use your own tools. ```sh @@ -39,16 +39,16 @@ $ plugin-helpers help Commands: build Copies files from the source into a zip archive that can be distributed for - installation into production Kibana installs. The archive includes the non- + installation into production OpenSearch Dashboards installs. The archive includes the non- development npm dependencies and builds itself using raw files in the source directory so make sure they are clean/up to date. The resulting archive can be found at: - build/{plugin.id}-{kibanaVersion}.zip + build/{plugin.id}-{opensearchDashboardsVersion}.zip Options: - --skip-archive Don't create the zip file, just create the build/kibana directory - --kibana-version, -v Kibana version that the + --skip-archive Don't create the zip file, just create the build/opensearch-dashboards directory + --opensearch-dashboards-version, -v OpenSearch Dashboards version that the Global options: @@ -62,15 +62,15 @@ $ plugin-helpers help ## Versions -The plugins helpers in the Kibana repo are available for Kibana 6.3 and greater. Just checkout the branch of Kibana you want to build against and the plugin helpers should be up to date for that version of Kibana. +The plugins helpers in the OpenSearch Dashboards repo are available for OpenSearch Dashboards 6.3 and greater. Just checkout the branch of OpenSearch Dashboards you want to build against and the plugin helpers should be up to date for that version of OpenSearch Dashboards. -When you're targeting versions before Kibana 6.3, use the `@elastic/plugin-helpers` from npm. See the [versions](https://github.com/elastic/kibana-plugin-helpers#versions) section of the [`@elastic/plugin-helpers` readme](https://github.com/elastic/kibana-plugin-helpers) for information about version compatibility. +When you're targeting versions before OpenSearch Dashboards 6.3, use the `@elastic/plugin-helpers` from npm. See the [versions](https://github.com/elastic/kibana-plugin-helpers#versions) section of the [`@elastic/plugin-helpers` readme](https://github.com/elastic/kibana-plugin-helpers) for information about version compatibility. ## Configuration -`plugin-helpers` accepts a number of settings, which can be specified at runtime, or included in a `.kibana-plugin-helpers.json` file if you'd like to bundle those settings with your project. +`plugin-helpers` accepts a number of settings, which can be specified at runtime, or included in a `.opensearch-dashboards-plugin-helpers.json` file if you'd like to bundle those settings with your project. -It will also observe a `.kibana-plugin-helpers.dev.json`, much like Kibana does, which we encourage you to add to your `.gitignore` file and use for local settings that you don't intend to share. These "dev" settings will override any settings in the normal json config. +It will also observe a `.opensearch-dashboards-plugin-helpers.dev.json`, much like OpenSearch Dashboards does, which we encourage you to add to your `.gitignore` file and use for local settings that you don't intend to share. These "dev" settings will override any settings in the normal json config. All configuration setting listed below can simply can be included in the json config files. If you intend to inline the command, you will need to convert the setting to snake case (ie. `skipArchive` becomes `--skip-archive`). @@ -80,10 +80,10 @@ All configuration setting listed below can simply can be included in the json co Setting | Description ------- | ----------- -`serverSourcePatterns` | Defines the files that are built with babel and written to your distributable for your server plugin. It is ignored if `kibana.json` has none `server: true` setting defined. +`serverSourcePatterns` | Defines the files that are built with babel and written to your distributable for your server plugin. It is ignored if `opensearch_dashboards.json` has none `server: true` setting defined. `skipArchive` | Don't create the zip file, leave the build path alone `skipInstallDependencies` | Don't install dependencies defined in package.json into build output -`kibanaVersion` | Kibana version for the build output (added to package.json) +`opensearchDashboardsVersion` | OpenSearch Dashboards version for the build output (added to package.json) ## TypeScript support @@ -91,8 +91,8 @@ Plugin code can be written in [TypeScript](http://www.typescriptlang.org/) if de ```js { - // extend Kibana's tsconfig, or use your own settings - "extends": "../../kibana/tsconfig.json", + // extend OpenSearch Dashboards's tsconfig, or use your own settings + "extends": "../../opensearch-dashboards/tsconfig.json", // tell the TypeScript compiler where to find your source files "include": [ diff --git a/packages/kbn-plugin-helpers/package.json b/packages/osd-plugin-helpers/package.json similarity index 67% rename from packages/kbn-plugin-helpers/package.json rename to packages/osd-plugin-helpers/package.json index 1f86122d7e12..447199730184 100644 --- a/packages/kbn-plugin-helpers/package.json +++ b/packages/osd-plugin-helpers/package.json @@ -1,10 +1,10 @@ { - "name": "@kbn/plugin-helpers", + "name": "@osd/plugin-helpers", "version": "1.0.0", "private": true, - "description": "Just some helpers for kibana plugin devs.", + "description": "Just some helpers for OpenSearch Dashboards plugin devs.", "license": "Apache-2.0", - "kibana": { + "opensearchDashboards": { "devOnly": true }, "main": "target/index.js", @@ -12,12 +12,12 @@ "plugin-helpers": "bin/plugin-helpers.js" }, "scripts": { - "kbn:bootstrap": "rm -rf target && tsc", - "kbn:watch": "tsc --watch" + "osd:bootstrap": "rm -rf target && tsc", + "osd:watch": "tsc --watch" }, "dependencies": { - "@kbn/dev-utils": "1.0.0", - "@kbn/optimizer": "1.0.0", + "@osd/dev-utils": "1.0.0", + "@osd/optimizer": "1.0.0", "del": "^5.1.0", "execa": "^4.0.2", "gulp-zip": "^5.0.2", diff --git a/packages/kbn-plugin-helpers/src/build_context.ts b/packages/osd-plugin-helpers/src/build_context.ts similarity index 86% rename from packages/kbn-plugin-helpers/src/build_context.ts rename to packages/osd-plugin-helpers/src/build_context.ts index 62300d5a34e4..63f34c2ba40e 100644 --- a/packages/kbn-plugin-helpers/src/build_context.ts +++ b/packages/osd-plugin-helpers/src/build_context.ts @@ -17,9 +17,9 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; -import { Plugin } from './load_kibana_platform_plugin'; +import { Plugin } from './load_opensearch_dashboards_platform_plugin'; import { Config } from './config'; export interface BuildContext { @@ -28,5 +28,5 @@ export interface BuildContext { config: Config; sourceDir: string; buildDir: string; - kibanaVersion: string; + opensearchDashboardsVersion: string; } diff --git a/packages/kbn-plugin-helpers/src/cli.ts b/packages/osd-plugin-helpers/src/cli.ts similarity index 64% rename from packages/kbn-plugin-helpers/src/cli.ts rename to packages/osd-plugin-helpers/src/cli.ts index 446fa35d5cba..d0ec6b2f6a8e 100644 --- a/packages/kbn-plugin-helpers/src/cli.ts +++ b/packages/osd-plugin-helpers/src/cli.ts @@ -20,13 +20,13 @@ import Path from 'path'; import semver from 'semver'; -import { RunWithCommands, createFlagError, createFailError } from '@kbn/dev-utils'; +import { RunWithCommands, createFlagError, createFailError } from '@osd/dev-utils'; -import { findKibanaJson } from './find_kibana_json'; -import { loadKibanaPlatformPlugin } from './load_kibana_platform_plugin'; +import { findOpenSearchDashboardsJson } from './find_opensearch_dashboards_json'; +import { loadOpenSearchDashboardsPlatformPlugin } from './load_opensearch_dashboards_platform_plugin'; import * as Tasks from './tasks'; import { BuildContext } from './build_context'; -import { resolveKibanaVersion } from './resolve_kibana_version'; +import { resolveOpenSearchDashboardsVersion } from './resolve_opensearch_dashboards_version'; import { loadConfig } from './config'; export function runCli() { @@ -37,29 +37,29 @@ export function runCli() { name: 'build', description: ` Copies files from the source into a zip archive that can be distributed for - installation into production Kibana installs. The archive includes the non- + installation into production OpenSearch Dashboards installs. The archive includes the non- development npm dependencies and builds itself using raw files in the source directory so make sure they are clean/up to date. The resulting archive can be found at: - build/{plugin.id}-{kibanaVersion}.zip + build/{plugin.id}-{opensearchDashboardsVersion}.zip `, flags: { boolean: ['skip-archive'], - string: ['kibana-version'], + string: ['opensearch-dashboards-version'], alias: { - k: 'kibana-version', + k: 'opensearch-dashboards-version', }, help: ` - --skip-archive Don't create the zip file, just create the build/kibana directory - --kibana-version, -v Kibana version that the + --skip-archive Don't create the zip file, just create the build/opensearch-dashboards directory + --opensearch-dashboards-version, -v OpenSearch version that the `, }, async run({ log, flags }) { - const versionFlag = flags['kibana-version']; + const versionFlag = flags['opensearch-dashboards-version']; if (versionFlag !== undefined && typeof versionFlag !== 'string') { - throw createFlagError('expected a single --kibana-version flag'); + throw createFlagError('expected a single --opensearch-dashboards-version flag'); } const skipArchive = flags['skip-archive']; @@ -67,31 +67,31 @@ export function runCli() { throw createFlagError('expected a single --skip-archive flag'); } - const pluginDir = await findKibanaJson(process.cwd()); + const pluginDir = await findOpenSearchDashboardsJson(process.cwd()); if (!pluginDir) { throw createFailError( - `Unable to find Kibana Platform plugin in [${process.cwd()}] or any of its parent directories. Has it been migrated properly? Does it have a kibana.json file?` + `Unable to find OpenSearch Dashboards Platform plugin in [${process.cwd()}] or any of its parent directories. Has it been migrated properly? Does it have a opensearch_dashboards.json file?` ); } - const plugin = loadKibanaPlatformPlugin(pluginDir); + const plugin = loadOpenSearchDashboardsPlatformPlugin(pluginDir); const config = await loadConfig(log, plugin); - const kibanaVersion = await resolveKibanaVersion(versionFlag, plugin); + const opensearchDashboardsVersion = await resolveOpenSearchDashboardsVersion(versionFlag, plugin); - if (semver.satisfies(kibanaVersion, '<7.9')) { + if (semver.satisfies(opensearchDashboardsVersion, '<7.9')) { log.error( - 'These tools are not designed to work with version before 7.9, please checkout an earlier version of Kibana to build your plugin' + 'These tools are not designed to work with version before 7.9, please checkout an earlier version of OpenSearch Dashboards to build your plugin' ); process.exit(1); } - if (semver.satisfies(kibanaVersion, '~7.9.0')) { + if (semver.satisfies(opensearchDashboardsVersion, '~7.9.0')) { log.warning( 'These tools might work with 7.9 versions, but there are known workarounds required. See https://github.com/elastic/kibana/issues/82466 for more info' ); } const sourceDir = plugin.directory; - const buildDir = Path.resolve(plugin.directory, 'build/kibana', plugin.manifest.id); + const buildDir = Path.resolve(plugin.directory, 'build/opensearch-dashboards', plugin.manifest.id); const context: BuildContext = { log, @@ -99,7 +99,7 @@ export function runCli() { config, sourceDir, buildDir, - kibanaVersion, + opensearchDashboardsVersion, }; await Tasks.initTargets(context); diff --git a/packages/kbn-plugin-helpers/src/config.ts b/packages/osd-plugin-helpers/src/config.ts similarity index 92% rename from packages/kbn-plugin-helpers/src/config.ts rename to packages/osd-plugin-helpers/src/config.ts index bd5ad8ab6acc..f3e50d447735 100644 --- a/packages/kbn-plugin-helpers/src/config.ts +++ b/packages/osd-plugin-helpers/src/config.ts @@ -21,8 +21,8 @@ import Path from 'path'; import loadJsonFile from 'load-json-file'; -import { ToolingLog } from '@kbn/dev-utils'; -import { Plugin } from './load_kibana_platform_plugin'; +import { ToolingLog } from '@osd/dev-utils'; +import { Plugin } from './load_opensearch_dashboards_platform_plugin'; export interface Config { skipInstallDependencies: boolean; @@ -34,7 +34,7 @@ const isArrayOfStrings = (v: any): v is string[] => export async function loadConfig(log: ToolingLog, plugin: Plugin): Promise { try { - const path = Path.resolve(plugin.directory, '.kibana-plugin-helpers.json'); + const path = Path.resolve(plugin.directory, '.opensearch-dashboards-plugin-helpers.json'); const file = await loadJsonFile(path); if (!(typeof file === 'object' && file && !Array.isArray(file))) { diff --git a/packages/kbn-plugin-helpers/src/find_kibana_json.ts b/packages/osd-plugin-helpers/src/find_opensearch_dashboards_json.ts similarity index 82% rename from packages/kbn-plugin-helpers/src/find_kibana_json.ts rename to packages/osd-plugin-helpers/src/find_opensearch_dashboards_json.ts index 934030905683..a49b4014eecc 100644 --- a/packages/kbn-plugin-helpers/src/find_kibana_json.ts +++ b/packages/osd-plugin-helpers/src/find_opensearch_dashboards_json.ts @@ -23,8 +23,8 @@ import { promisify } from 'util'; const existsAsync = promisify(Fs.exists); -export async function findKibanaJson(directory: string): Promise { - if (await existsAsync(Path.resolve(directory, 'kibana.json'))) { +export async function findOpenSearchDashboardsJson(directory: string): Promise { + if (await existsAsync(Path.resolve(directory, 'opensearch_dashboards.json'))) { return directory; } @@ -33,5 +33,5 @@ export async function findKibanaJson(directory: string): Promise')); @@ -65,7 +65,7 @@ it('builds a generated plugin into a viable archive', async () => { const buildProc = await execa( process.execPath, - ['../../scripts/plugin_helpers', 'build', '--kibana-version', KIBANA_VERSION], + ['../../scripts/plugin_helpers', 'build', '--opensearch-dashboards-version', OPENSEARCH_DASHBOARDS_VERSION], { cwd: PLUGIN_DIR, all: true, @@ -75,7 +75,7 @@ it('builds a generated plugin into a viable archive', async () => { expect(buildProc.all).toMatchInlineSnapshot(` " warn These tools might work with 7.9 versions, but there are known workarounds required. See https://github.com/elastic/kibana/issues/82466 for more info info deleting the build and target directories - info running @kbn/optimizer + info running @osd/optimizer │ info initialized, 0 bundles cached │ info starting worker [1 bundle] │ warn worker stderr Browserslist: caniuse-lite is outdated. Please run: @@ -87,36 +87,36 @@ it('builds a generated plugin into a viable archive', async () => { info compressing plugin into [fooTestPlugin-7.9.0.zip]" `); - await extract(PLUGIN_ARCHIVE, { dir: TMP_DIR }, () => {}); + await extract(PLUGIN_ARCHIVE, { dir: TMP_DIR }, () => { }); const files = await globby(['**/*'], { cwd: TMP_DIR }); files.sort((a, b) => a.localeCompare(b)); expect(files).toMatchInlineSnapshot(` Array [ - "kibana/fooTestPlugin/common/index.js", - "kibana/fooTestPlugin/kibana.json", - "kibana/fooTestPlugin/package.json", - "kibana/fooTestPlugin/server/index.js", - "kibana/fooTestPlugin/server/plugin.js", - "kibana/fooTestPlugin/server/routes/index.js", - "kibana/fooTestPlugin/server/types.js", - "kibana/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js", - "kibana/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js.br", - "kibana/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js.gz", - "kibana/fooTestPlugin/target/public/fooTestPlugin.plugin.js", - "kibana/fooTestPlugin/target/public/fooTestPlugin.plugin.js.br", - "kibana/fooTestPlugin/target/public/fooTestPlugin.plugin.js.gz", - "kibana/fooTestPlugin/translations/ja-JP.json", - "kibana/fooTestPlugin/tsconfig.json", + "opensearch-dashboards/fooTestPlugin/common/index.js", + "opensearch-dashboards/fooTestPlugin/opensearch_dashboards.json", + "opensearch-dashboards/fooTestPlugin/package.json", + "opensearch-dashboards/fooTestPlugin/server/index.js", + "opensearch-dashboards/fooTestPlugin/server/plugin.js", + "opensearch-dashboards/fooTestPlugin/server/routes/index.js", + "opensearch-dashboards/fooTestPlugin/server/types.js", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js.br", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.chunk.1.js.gz", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.plugin.js", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.plugin.js.br", + "opensearch-dashboards/fooTestPlugin/target/public/fooTestPlugin.plugin.js.gz", + "opensearch-dashboards/fooTestPlugin/translations/ja-JP.json", + "opensearch-dashboards/fooTestPlugin/tsconfig.json", ] `); - expect(loadJsonFile.sync(Path.resolve(TMP_DIR, 'kibana', 'fooTestPlugin', 'kibana.json'))) + expect(loadJsonFile.sync(Path.resolve(TMP_DIR, 'opensearch-dashboards', 'fooTestPlugin', 'opensearch_dashboards.json'))) .toMatchInlineSnapshot(` Object { "id": "fooTestPlugin", - "kibanaVersion": "7.9.0", + "opensearchDashboardsVersion": "7.9.0", "optionalPlugins": Array [], "requiredPlugins": Array [ "navigation", diff --git a/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts b/packages/osd-plugin-helpers/src/load_opensearch_dashboards_platform_plugin.ts similarity index 72% rename from packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts rename to packages/osd-plugin-helpers/src/load_opensearch_dashboards_platform_plugin.ts index 8ed20a26649e..903e36895bd0 100644 --- a/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts +++ b/packages/osd-plugin-helpers/src/load_opensearch_dashboards_platform_plugin.ts @@ -19,12 +19,12 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/utils'; -import { parseKibanaPlatformPlugin, KibanaPlatformPlugin, createFailError } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@osd/utils'; +import { parseOpenSearchDashboardsPlatformPlugin, OpenSearchDashboardsPlatformPlugin, createFailError } from '@osd/dev-utils'; -export type Plugin = KibanaPlatformPlugin; +export type Plugin = OpenSearchDashboardsPlatformPlugin; -export function loadKibanaPlatformPlugin(pluginDir: string) { +export function loadOpenSearchDashboardsPlatformPlugin(pluginDir: string) { const parentDir = Path.resolve(pluginDir, '..'); const isFixture = pluginDir.includes('__fixtures__'); @@ -32,10 +32,10 @@ export function loadKibanaPlatformPlugin(pluginDir: string) { const isRootPlugin = parentDir === Path.resolve(REPO_ROOT, 'plugins'); if (isFixture || isExample || isRootPlugin) { - return parseKibanaPlatformPlugin(Path.resolve(pluginDir, 'kibana.json')); + 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 Kibana repo` + `Plugin located at [${pluginDir}] must be moved to the plugins directory at the root of the OpenSearch Dashboards repo` ); } diff --git a/packages/kbn-plugin-helpers/src/resolve_kibana_version.ts b/packages/osd-plugin-helpers/src/resolve_opensearch_dashboards_version.ts similarity index 64% rename from packages/kbn-plugin-helpers/src/resolve_kibana_version.ts rename to packages/osd-plugin-helpers/src/resolve_opensearch_dashboards_version.ts index 85029d5ffb25..d05cc4493fb6 100644 --- a/packages/kbn-plugin-helpers/src/resolve_kibana_version.ts +++ b/packages/osd-plugin-helpers/src/resolve_opensearch_dashboards_version.ts @@ -19,22 +19,22 @@ import inquirer from 'inquirer'; -import { Plugin } from './load_kibana_platform_plugin'; +import { Plugin } from './load_opensearch_dashboards_platform_plugin'; -export async function resolveKibanaVersion(option: string | undefined, plugin: Plugin) { - const preselectedVersion = option || plugin.manifest.kibanaVersion || plugin.manifest.version; +export async function resolveOpenSearchDashboardsVersion(option: string | undefined, plugin: Plugin) { + const preselectedVersion = option || plugin.manifest.opensearchDashboardsVersion || plugin.manifest.version; - if (preselectedVersion && preselectedVersion !== 'kibana') { + if (preselectedVersion && preselectedVersion !== 'opensearchDashboards') { return preselectedVersion; } const answers = await inquirer.prompt([ { type: 'input', - name: 'kibanaVersion', - message: 'What version of Kibana are you building for?', + name: 'opensearchDashboardsVersion', + message: 'What version of OpenSearch Dashboards are you building for?', }, ]); - return answers.kibanaVersion; + return answers.opensearchDashboardsVersion; } diff --git a/packages/kbn-plugin-helpers/src/tasks/clean.ts b/packages/osd-plugin-helpers/src/tasks/clean.ts similarity index 100% rename from packages/kbn-plugin-helpers/src/tasks/clean.ts rename to packages/osd-plugin-helpers/src/tasks/clean.ts diff --git a/packages/kbn-plugin-helpers/src/tasks/create_archive.ts b/packages/osd-plugin-helpers/src/tasks/create_archive.ts similarity index 84% rename from packages/kbn-plugin-helpers/src/tasks/create_archive.ts rename to packages/osd-plugin-helpers/src/tasks/create_archive.ts index 7656b6119c85..7591919fa2f3 100644 --- a/packages/kbn-plugin-helpers/src/tasks/create_archive.ts +++ b/packages/osd-plugin-helpers/src/tasks/create_archive.ts @@ -29,20 +29,20 @@ import { BuildContext } from '../build_context'; const asyncPipeline = promisify(pipeline); -export async function createArchive({ kibanaVersion, plugin, log }: BuildContext) { +export async function createArchive({ opensearchDashboardsVersion, plugin, log }: BuildContext) { const { manifest: { id }, directory, } = plugin; - const zipName = `${id}-${kibanaVersion}.zip`; + const zipName = `${id}-${opensearchDashboardsVersion}.zip`; log.info(`compressing plugin into [${zipName}]`); const buildDir = Path.resolve(directory, 'build'); // zip up the build files await asyncPipeline( - vfs.src([`kibana/${id}/**/*`], { + vfs.src([`opensearch-dashboards/${id}/**/*`], { cwd: buildDir, base: buildDir, dot: true, @@ -52,5 +52,5 @@ export async function createArchive({ kibanaVersion, plugin, log }: BuildContext ); // delete the files that were zipped - await del(Path.resolve(buildDir, 'kibana')); + await del(Path.resolve(buildDir, 'opensearch-dashboards')); } diff --git a/packages/kbn-plugin-helpers/src/tasks/index.ts b/packages/osd-plugin-helpers/src/tasks/index.ts similarity index 100% rename from packages/kbn-plugin-helpers/src/tasks/index.ts rename to packages/osd-plugin-helpers/src/tasks/index.ts diff --git a/packages/kbn-plugin-helpers/src/tasks/optimize.ts b/packages/osd-plugin-helpers/src/tasks/optimize.ts similarity index 94% rename from packages/kbn-plugin-helpers/src/tasks/optimize.ts rename to packages/osd-plugin-helpers/src/tasks/optimize.ts index fc1bf48cc0e3..4a5d9964dda5 100644 --- a/packages/kbn-plugin-helpers/src/tasks/optimize.ts +++ b/packages/osd-plugin-helpers/src/tasks/optimize.ts @@ -21,8 +21,8 @@ import Fs from 'fs'; import Path from 'path'; import { promisify } from 'util'; -import { REPO_ROOT } from '@kbn/utils'; -import { OptimizerConfig, runOptimizer, logOptimizerState } from '@kbn/optimizer'; +import { REPO_ROOT } from '@osd/utils'; +import { OptimizerConfig, runOptimizer, logOptimizerState } from '@osd/optimizer'; import { BuildContext } from '../build_context'; @@ -33,7 +33,7 @@ export async function optimize({ log, plugin, sourceDir, buildDir }: BuildContex return; } - log.info('running @kbn/optimizer'); + log.info('running @osd/optimizer'); log.indent(2); // build bundles into target diff --git a/packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts b/packages/osd-plugin-helpers/src/tasks/write_public_assets.ts similarity index 100% rename from packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts rename to packages/osd-plugin-helpers/src/tasks/write_public_assets.ts diff --git a/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts b/packages/osd-plugin-helpers/src/tasks/write_server_files.ts similarity index 63% rename from packages/kbn-plugin-helpers/src/tasks/write_server_files.ts rename to packages/osd-plugin-helpers/src/tasks/write_server_files.ts index 88722b8d9e19..8f5afd9ca787 100644 --- a/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts +++ b/packages/osd-plugin-helpers/src/tasks/write_server_files.ts @@ -22,7 +22,7 @@ import { promisify } from 'util'; import semver from 'semver'; import vfs from 'vinyl-fs'; -import { transformFileWithBabel, transformFileStream } from '@kbn/dev-utils'; +import { transformFileWithBabel, transformFileStream } from '@osd/dev-utils'; import { BuildContext } from '../build_context'; @@ -34,28 +34,28 @@ export async function writeServerFiles({ plugin, sourceDir, buildDir, - kibanaVersion, + opensearchDashboardsVersion, }: BuildContext) { log.info('copying server source into the build and converting with babel'); - const KIBANA_VERSION_79 = semver.satisfies(kibanaVersion, '~7.9.0'); + const OPENSEARCH_DASHBOARDS_VERSION_79 = semver.satisfies(opensearchDashboardsVersion, '~7.9.0'); // copy source files and apply some babel transformations in the process await asyncPipeline( vfs.src( [ - 'kibana.json', + 'opensearch_dashboards.json', // always copy over the package.json file if we're building for 7.9 - ...(KIBANA_VERSION_79 ? ['package.json'] : []), - // always copy over server files if we're building for 7.9, otherwise rely on `server: true` in kibana.json manifest - ...(KIBANA_VERSION_79 || plugin.manifest.server + ...(OPENSEARCH_DASHBOARDS_VERSION_79 ? ['package.json'] : []), + // always copy over server files if we're building for 7.9, otherwise rely on `server: true` in opensearch_dashboards.json manifest + ...(OPENSEARCH_DASHBOARDS_VERSION_79 || plugin.manifest.server ? config.serverSourcePatterns || [ - 'yarn.lock', - 'tsconfig.json', - 'package.json', - 'index.{js,ts}', - '{lib,server,common,translations}/**/*', - ] + 'yarn.lock', + 'tsconfig.json', + 'package.json', + 'index.{js,ts}', + '{lib,server,common,translations}/**/*', + ] : []), ], { @@ -72,12 +72,12 @@ export async function writeServerFiles({ } ), - // add kibanaVersion to kibana.json files and kibana.version to package.json files - // we don't check for `kibana.version` in 7.10+ but the plugin helpers can still be used - // to build plugins for older Kibana versions so we do our best to support those needs by + // add opensearchDashboardsVersion to opensearch_dashboards.json files and opensearchDashboards.version to package.json files + // we don't check for `opensearchDashboards.version` in 7.10+ but the plugin helpers can still be used + // to build plugins for older OpenSearch Dashboards versions so we do our best to support those needs by // setting the property if the package.json file is encountered transformFileStream((file) => { - if (file.relative !== 'kibana.json' && file.relative !== 'package.json') { + if (file.relative !== 'opensearch_dashboards.json' && file.relative !== 'package.json') { return; } @@ -86,18 +86,18 @@ export async function writeServerFiles({ file.contents = Buffer.from( JSON.stringify( - file.relative === 'kibana.json' + file.relative === 'opensearch_dashboards.json' ? { - ...parsed, - kibanaVersion, - } + ...parsed, + opensearchDashboardsVersion, + } : { - ...parsed, - kibana: { - ...parsed.kibana, - version: kibanaVersion, - }, + ...parsed, + opensearchDashboards: { + ...parsed.opensearchDashboards, + version: opensearchDashboardsVersion, }, + }, null, 2 ) diff --git a/packages/kbn-plugin-helpers/src/tasks/yarn_install.ts b/packages/osd-plugin-helpers/src/tasks/yarn_install.ts similarity index 100% rename from packages/kbn-plugin-helpers/src/tasks/yarn_install.ts rename to packages/osd-plugin-helpers/src/tasks/yarn_install.ts diff --git a/packages/kbn-plugin-helpers/tsconfig.json b/packages/osd-plugin-helpers/tsconfig.json similarity index 100% rename from packages/kbn-plugin-helpers/tsconfig.json rename to packages/osd-plugin-helpers/tsconfig.json diff --git a/packages/kbn-plugin-helpers/yarn.lock b/packages/osd-plugin-helpers/yarn.lock similarity index 100% rename from packages/kbn-plugin-helpers/yarn.lock rename to packages/osd-plugin-helpers/yarn.lock