From 2cc502e8e82b11c5c56a09a42f5056d5d5f11a43 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Wed, 3 Mar 2021 18:27:34 +0000 Subject: [PATCH 1/3] [Rename] kbn-uitls in packages directory to osd-utils Signed-off-by: Mihir Soni --- packages/{kbn-utils => osd-utils}/README.md | 2 +- .../{kbn-utils => osd-utils}/package.json | 8 +++---- .../{kbn-utils => osd-utils}/src/index.ts | 0 .../src/package_json/index.test.ts | 8 +++---- .../src/package_json/index.ts | 2 +- .../src/path/index.test.ts | 2 +- .../src/path/index.ts | 18 +++++++------- .../{kbn-utils => osd-utils}/src/repo_root.ts | 24 +++++++++---------- .../{kbn-utils => osd-utils}/tsconfig.json | 0 packages/{kbn-utils => osd-utils}/yarn.lock | 0 10 files changed, 32 insertions(+), 32 deletions(-) rename packages/{kbn-utils => osd-utils}/README.md (83%) rename packages/{kbn-utils => osd-utils}/package.json (65%) rename packages/{kbn-utils => osd-utils}/src/index.ts (100%) rename packages/{kbn-utils => osd-utils}/src/package_json/index.test.ts (76%) rename packages/{kbn-utils => osd-utils}/src/package_json/index.ts (95%) rename packages/{kbn-utils => osd-utils}/src/path/index.test.ts (96%) rename packages/{kbn-utils => osd-utils}/src/path/index.ts (79%) rename packages/{kbn-utils => osd-utils}/src/repo_root.ts (67%) rename packages/{kbn-utils => osd-utils}/tsconfig.json (100%) rename packages/{kbn-utils => osd-utils}/yarn.lock (100%) diff --git a/packages/kbn-utils/README.md b/packages/osd-utils/README.md similarity index 83% rename from packages/kbn-utils/README.md rename to packages/osd-utils/README.md index fd132e431248..5b2baccbf024 100644 --- a/packages/kbn-utils/README.md +++ b/packages/osd-utils/README.md @@ -1,3 +1,3 @@ -# @kbn/utils +# @osd/utils Shared server-side utilities shared across packages and plugins. \ No newline at end of file diff --git a/packages/kbn-utils/package.json b/packages/osd-utils/package.json similarity index 65% rename from packages/kbn-utils/package.json rename to packages/osd-utils/package.json index 15fe5c6df564..802b03a0adb0 100644 --- a/packages/kbn-utils/package.json +++ b/packages/osd-utils/package.json @@ -1,16 +1,16 @@ { - "name": "@kbn/utils", + "name": "@osd/utils", "main": "./target/index.js", "version": "1.0.0", "license": "Apache-2.0", "private": true, "scripts": { "build": "tsc", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" + "osd:bootstrap": "yarn build", + "osd:watch": "yarn build --watch" }, "dependencies": { - "@kbn/config-schema": "1.0.0", + "@osd/config-schema": "1.0.0", "load-json-file": "^6.2.0" }, "devDependencies": { diff --git a/packages/kbn-utils/src/index.ts b/packages/osd-utils/src/index.ts similarity index 100% rename from packages/kbn-utils/src/index.ts rename to packages/osd-utils/src/index.ts diff --git a/packages/kbn-utils/src/package_json/index.test.ts b/packages/osd-utils/src/package_json/index.test.ts similarity index 76% rename from packages/kbn-utils/src/package_json/index.test.ts rename to packages/osd-utils/src/package_json/index.test.ts index afc84102999f..82e614f297ba 100644 --- a/packages/kbn-utils/src/package_json/index.test.ts +++ b/packages/osd-utils/src/package_json/index.test.ts @@ -18,14 +18,14 @@ */ import path from 'path'; -import { kibanaPackageJSON } from './'; +import { opensearchDashboardsPackageJSON } from './'; it('parses package.json', () => { - expect(kibanaPackageJSON.name).toEqual('kibana'); + expect(opensearchDashboardsPackageJSON.name).toEqual('opensearch-dashboards'); }); it('includes __dirname and __filename', () => { const root = path.resolve(__dirname, '../../../../'); - expect(kibanaPackageJSON.__filename).toEqual(path.resolve(root, 'package.json')); - expect(kibanaPackageJSON.__dirname).toEqual(root); + expect(opensearchDashboardsPackageJSON.__filename).toEqual(path.resolve(root, 'package.json')); + expect(opensearchDashboardsPackageJSON.__dirname).toEqual(root); }); diff --git a/packages/kbn-utils/src/package_json/index.ts b/packages/osd-utils/src/package_json/index.ts similarity index 95% rename from packages/kbn-utils/src/package_json/index.ts rename to packages/osd-utils/src/package_json/index.ts index f439c0100e19..8069df262005 100644 --- a/packages/kbn-utils/src/package_json/index.ts +++ b/packages/osd-utils/src/package_json/index.ts @@ -20,7 +20,7 @@ import { dirname, resolve } from 'path'; import { REPO_ROOT } from '../repo_root'; -export const kibanaPackageJSON = { +export const opensearchDashboardsPackageJSON = { __filename: resolve(REPO_ROOT, 'package.json'), __dirname: dirname(resolve(REPO_ROOT, 'package.json')), ...require(resolve(REPO_ROOT, 'package.json')), diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/osd-utils/src/path/index.test.ts similarity index 96% rename from packages/kbn-utils/src/path/index.test.ts rename to packages/osd-utils/src/path/index.test.ts index 522e100d85e5..112492530cad 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/osd-utils/src/path/index.test.ts @@ -21,7 +21,7 @@ import { accessSync, constants } from 'fs'; import { getConfigPath, getDataPath, getConfigDirectory } from './'; describe('Default path finder', () => { - it('should find a kibana.yml', () => { + it('should find a opensearch-dashboards.yml', () => { const configPath = getConfigPath(); expect(() => accessSync(configPath, constants.R_OK)).not.toThrow(); }); diff --git a/packages/kbn-utils/src/path/index.ts b/packages/osd-utils/src/path/index.ts similarity index 79% rename from packages/kbn-utils/src/path/index.ts rename to packages/osd-utils/src/path/index.ts index a7eddca5f2fd..89e2351ab27a 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/osd-utils/src/path/index.ts @@ -19,29 +19,29 @@ import { join } from 'path'; import { accessSync, constants } from 'fs'; -import { TypeOf, schema } from '@kbn/config-schema'; +import { TypeOf, schema } from '@osd/config-schema'; import { REPO_ROOT } from '../repo_root'; const isString = (v: any): v is string => typeof v === 'string'; const CONFIG_PATHS = [ - process.env.KBN_PATH_CONF && join(process.env.KBN_PATH_CONF, 'kibana.yml'), - process.env.KIBANA_PATH_CONF && join(process.env.KIBANA_PATH_CONF, 'kibana.yml'), + process.env.OSD_PATH_CONF && join(process.env.OSD_PATH_CONF, 'opensearch-dashboards.yml'), + process.env.OPENSEARCH_DASHBOARDS_PATH_CONF && join(process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, 'opensearch-dashboards.yml'), process.env.CONFIG_PATH, // deprecated - join(REPO_ROOT, 'config/kibana.yml'), + join(REPO_ROOT, 'config/opensearch-dashboards.yml'), ].filter(isString); const CONFIG_DIRECTORIES = [ - process.env.KBN_PATH_CONF, - process.env.KIBANA_PATH_CONF, + process.env.OSD_PATH_CONF, + process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, join(REPO_ROOT, 'config'), - '/etc/kibana', + '/etc/opensearch-dashboards', ].filter(isString); const DATA_PATHS = [ process.env.DATA_PATH, // deprecated join(REPO_ROOT, 'data'), - '/var/lib/kibana', + '/var/lib/opensearch-dashboards', ].filter(isString); function findFile(paths: string[]) { @@ -57,7 +57,7 @@ function findFile(paths: string[]) { } /** - * Get the path of kibana.yml + * Get the path of opensearch-dashboards.yml * @internal */ export const getConfigPath = () => findFile(CONFIG_PATHS); diff --git a/packages/kbn-utils/src/repo_root.ts b/packages/osd-utils/src/repo_root.ts similarity index 67% rename from packages/kbn-utils/src/repo_root.ts rename to packages/osd-utils/src/repo_root.ts index ed3516a7304f..5c14d9d8ae64 100644 --- a/packages/kbn-utils/src/repo_root.ts +++ b/packages/osd-utils/src/repo_root.ts @@ -22,11 +22,11 @@ import Fs from 'fs'; import loadJsonFile from 'load-json-file'; -const readKibanaPkgJson = (dir: string) => { +const readOpenSearchDashboardsPkgJson = (dir: string) => { try { const path = Path.resolve(dir, 'package.json'); const json = loadJsonFile.sync(path); - if (json && typeof json === 'object' && 'name' in json && json.name === 'kibana') { + if (json && typeof json === 'object' && 'name' in json && json.name === 'opensearch-dashboards') { return json; } } catch (error) { @@ -38,19 +38,19 @@ const readKibanaPkgJson = (dir: string) => { } }; -const findKibanaPackageJson = () => { - // search for the kibana directory, since this file is moved around it might +const findOpensearchDashboardsPackageJson = () => { + // search for the opensearch-dashboards directory, since this file is moved around it might // not be where we think but should always be a relatively close parent // of this directory const startDir = Fs.realpathSync(__dirname); const { root: rootDir } = Path.parse(startDir); let cursor = startDir; while (true) { - const kibanaPkgJson = readKibanaPkgJson(cursor); - if (kibanaPkgJson) { + const opensearchDashboardsPkgJson = readOpenSearchDashboardsPkgJson(cursor); + if (opensearchDashboardsPkgJson) { return { - kibanaDir: cursor, - kibanaPkgJson: kibanaPkgJson as { + opensearchDashboardsDir: cursor, + opensearchDashboardsPkgJson: opensearchDashboardsPkgJson as { name: string; branch: string; }, @@ -59,13 +59,13 @@ const findKibanaPackageJson = () => { const parent = Path.dirname(cursor); if (parent === rootDir) { - throw new Error(`unable to find kibana directory from ${startDir}`); + throw new Error(`unable to find opensearch-dashboards directory from ${startDir}`); } cursor = parent; } }; -const { kibanaDir, kibanaPkgJson } = findKibanaPackageJson(); +const { opensearchDashboardsDir, opensearchDashboardsPkgJson } = findOpensearchDashboardsPackageJson(); -export const REPO_ROOT = kibanaDir; -export const UPSTREAM_BRANCH = kibanaPkgJson.branch; +export const REPO_ROOT = opensearchDashboardsDir; +export const UPSTREAM_BRANCH = opensearchDashboardsPkgJson.branch; diff --git a/packages/kbn-utils/tsconfig.json b/packages/osd-utils/tsconfig.json similarity index 100% rename from packages/kbn-utils/tsconfig.json rename to packages/osd-utils/tsconfig.json diff --git a/packages/kbn-utils/yarn.lock b/packages/osd-utils/yarn.lock similarity index 100% rename from packages/kbn-utils/yarn.lock rename to packages/osd-utils/yarn.lock From fb5748a1031176976e4f4925df8893ae05ae39b2 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Thu, 4 Mar 2021 00:53:00 +0000 Subject: [PATCH 2/3] [Rename] in-corporate review comments Signed-off-by: Mihir Soni --- packages/osd-utils/src/path/index.test.ts | 2 +- packages/osd-utils/src/path/index.ts | 8 ++++---- packages/osd-utils/src/repo_root.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/osd-utils/src/path/index.test.ts b/packages/osd-utils/src/path/index.test.ts index 112492530cad..e7375b83332a 100644 --- a/packages/osd-utils/src/path/index.test.ts +++ b/packages/osd-utils/src/path/index.test.ts @@ -21,7 +21,7 @@ import { accessSync, constants } from 'fs'; import { getConfigPath, getDataPath, getConfigDirectory } from './'; describe('Default path finder', () => { - it('should find a opensearch-dashboards.yml', () => { + it('should find a opensearch_dashboards', () => { const configPath = getConfigPath(); expect(() => accessSync(configPath, constants.R_OK)).not.toThrow(); }); diff --git a/packages/osd-utils/src/path/index.ts b/packages/osd-utils/src/path/index.ts index 89e2351ab27a..7543151d59fe 100644 --- a/packages/osd-utils/src/path/index.ts +++ b/packages/osd-utils/src/path/index.ts @@ -25,10 +25,10 @@ import { REPO_ROOT } from '../repo_root'; const isString = (v: any): v is string => typeof v === 'string'; const CONFIG_PATHS = [ - process.env.OSD_PATH_CONF && join(process.env.OSD_PATH_CONF, 'opensearch-dashboards.yml'), - process.env.OPENSEARCH_DASHBOARDS_PATH_CONF && join(process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, 'opensearch-dashboards.yml'), + process.env.OSD_PATH_CONF && join(process.env.OSD_PATH_CONF, 'opensearch_dashboards'), + process.env.OPENSEARCH_DASHBOARDS_PATH_CONF && join(process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, 'opensearch_dashboards'), process.env.CONFIG_PATH, // deprecated - join(REPO_ROOT, 'config/opensearch-dashboards.yml'), + join(REPO_ROOT, 'config/opensearch_dashboards'), ].filter(isString); const CONFIG_DIRECTORIES = [ @@ -57,7 +57,7 @@ function findFile(paths: string[]) { } /** - * Get the path of opensearch-dashboards.yml + * Get the path of opensearch_dashboards * @internal */ export const getConfigPath = () => findFile(CONFIG_PATHS); diff --git a/packages/osd-utils/src/repo_root.ts b/packages/osd-utils/src/repo_root.ts index 5c14d9d8ae64..20da8b52dbcf 100644 --- a/packages/osd-utils/src/repo_root.ts +++ b/packages/osd-utils/src/repo_root.ts @@ -38,7 +38,7 @@ const readOpenSearchDashboardsPkgJson = (dir: string) => { } }; -const findOpensearchDashboardsPackageJson = () => { +const findOpenSearchDashboardsPackageJson = () => { // search for the opensearch-dashboards directory, since this file is moved around it might // not be where we think but should always be a relatively close parent // of this directory @@ -65,7 +65,7 @@ const findOpensearchDashboardsPackageJson = () => { } }; -const { opensearchDashboardsDir, opensearchDashboardsPkgJson } = findOpensearchDashboardsPackageJson(); +const { opensearchDashboardsDir, opensearchDashboardsPkgJson } = findOpenSearchDashboardsPackageJson(); export const REPO_ROOT = opensearchDashboardsDir; export const UPSTREAM_BRANCH = opensearchDashboardsPkgJson.branch; From b5263c8bda544b0da22ea73a63ce07edd1144e31 Mon Sep 17 00:00:00 2001 From: Mihir Soni Date: Thu, 4 Mar 2021 21:17:40 +0000 Subject: [PATCH 3/3] [Rename] in-corporate review comments Signed-off-by: Mihir Soni --- packages/osd-utils/src/path/index.test.ts | 2 +- packages/osd-utils/src/path/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/osd-utils/src/path/index.test.ts b/packages/osd-utils/src/path/index.test.ts index e7375b83332a..9c4472a692d3 100644 --- a/packages/osd-utils/src/path/index.test.ts +++ b/packages/osd-utils/src/path/index.test.ts @@ -21,7 +21,7 @@ import { accessSync, constants } from 'fs'; import { getConfigPath, getDataPath, getConfigDirectory } from './'; describe('Default path finder', () => { - it('should find a opensearch_dashboards', () => { + it('should find a opensearch_dashboards.yml', () => { const configPath = getConfigPath(); expect(() => accessSync(configPath, constants.R_OK)).not.toThrow(); }); diff --git a/packages/osd-utils/src/path/index.ts b/packages/osd-utils/src/path/index.ts index 7543151d59fe..067767b8410b 100644 --- a/packages/osd-utils/src/path/index.ts +++ b/packages/osd-utils/src/path/index.ts @@ -25,10 +25,10 @@ import { REPO_ROOT } from '../repo_root'; const isString = (v: any): v is string => typeof v === 'string'; const CONFIG_PATHS = [ - process.env.OSD_PATH_CONF && join(process.env.OSD_PATH_CONF, 'opensearch_dashboards'), - process.env.OPENSEARCH_DASHBOARDS_PATH_CONF && join(process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, 'opensearch_dashboards'), + process.env.OSD_PATH_CONF && join(process.env.OSD_PATH_CONF, 'opensearch_dashboards.yml'), + process.env.OPENSEARCH_DASHBOARDS_PATH_CONF && join(process.env.OPENSEARCH_DASHBOARDS_PATH_CONF, 'opensearch_dashboards.yml'), process.env.CONFIG_PATH, // deprecated - join(REPO_ROOT, 'config/opensearch_dashboards'), + join(REPO_ROOT, 'config/opensearch_dashboards.yml'), ].filter(isString); const CONFIG_DIRECTORIES = [ @@ -57,7 +57,7 @@ function findFile(paths: string[]) { } /** - * Get the path of opensearch_dashboards + * Get the path of opensearch_dashboards.yml * @internal */ export const getConfigPath = () => findFile(CONFIG_PATHS);