diff --git a/docs/developer/plugin/external-plugin-functional-tests.asciidoc b/docs/developer/plugin/external-plugin-functional-tests.asciidoc index 7e5b5b79d06e9c3..b39d576d8526859 100644 --- a/docs/developer/plugin/external-plugin-functional-tests.asciidoc +++ b/docs/developer/plugin/external-plugin-functional-tests.asciidoc @@ -13,7 +13,7 @@ To get started copy and paste this example to `test/functional/config.js`: ["source","js"] ----------- import { resolve } from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { MyServiceProvider } from './services/my_service'; import { MyAppPageProvider } from './services/my_app_page'; diff --git a/packages/kbn-dev-utils/package.json b/packages/kbn-dev-utils/package.json index 4f6f995f38f31b3..a3fe8178822aa54 100644 --- a/packages/kbn-dev-utils/package.json +++ b/packages/kbn-dev-utils/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@babel/core": "^7.11.1", + "@kbn/utils": "1.0.0", "axios": "^0.19.0", "chalk": "^4.1.0", "cheerio": "0.22.0", diff --git a/packages/kbn-dev-utils/src/index.ts b/packages/kbn-dev-utils/src/index.ts index 2871fe2ffcf4a00..8217999b01128a9 100644 --- a/packages/kbn-dev-utils/src/index.ts +++ b/packages/kbn-dev-utils/src/index.ts @@ -17,6 +17,7 @@ * under the License. */ +export { REPO_ROOT } from '@kbn/utils'; export { withProcRunner, ProcRunner } from './proc_runner'; export * from './tooling_log'; export * from './serializers'; @@ -33,7 +34,6 @@ export { KBN_P12_PATH, KBN_P12_PASSWORD, } from './certs'; -export { REPO_ROOT } from './repo_root'; export { KbnClient } from './kbn_client'; export * from './run'; export * from './axios'; diff --git a/packages/kbn-dev-utils/src/plugin_list/discover_plugins.ts b/packages/kbn-dev-utils/src/plugin_list/discover_plugins.ts index 783d584656b1776..5d92ddb600aa9ee 100644 --- a/packages/kbn-dev-utils/src/plugin_list/discover_plugins.ts +++ b/packages/kbn-dev-utils/src/plugin_list/discover_plugins.ts @@ -22,8 +22,8 @@ import Fs from 'fs'; import MarkdownIt from 'markdown-it'; import cheerio from 'cheerio'; +import { REPO_ROOT } from '@kbn/utils'; -import { REPO_ROOT } from '../repo_root'; import { simpleKibanaPlatformPluginDiscovery } from '../simple_kibana_platform_plugin_discovery'; import { extractAsciidocInfo } from './extract_asciidoc_info'; diff --git a/packages/kbn-dev-utils/src/plugin_list/generate_plugin_list.ts b/packages/kbn-dev-utils/src/plugin_list/generate_plugin_list.ts index 43dac1cb7d418da..e1a1323553113a1 100644 --- a/packages/kbn-dev-utils/src/plugin_list/generate_plugin_list.ts +++ b/packages/kbn-dev-utils/src/plugin_list/generate_plugin_list.ts @@ -20,8 +20,8 @@ import Path from 'path'; import normalizePath from 'normalize-path'; +import { REPO_ROOT } from '@kbn/utils'; -import { REPO_ROOT } from '../repo_root'; import { Plugins } from './discover_plugins'; function* printPlugins(plugins: Plugins, includes: string[]) { diff --git a/packages/kbn-dev-utils/src/plugin_list/run_plugin_list_cli.ts b/packages/kbn-dev-utils/src/plugin_list/run_plugin_list_cli.ts index 553eb1dd8afa075..613f9c9c264116c 100644 --- a/packages/kbn-dev-utils/src/plugin_list/run_plugin_list_cli.ts +++ b/packages/kbn-dev-utils/src/plugin_list/run_plugin_list_cli.ts @@ -19,10 +19,9 @@ import Path from 'path'; import Fs from 'fs'; +import { REPO_ROOT } from '@kbn/utils'; import { run } from '../run'; -import { REPO_ROOT } from '../repo_root'; - import { discoverPlugins } from './discover_plugins'; import { generatePluginList } from './generate_plugin_list'; diff --git a/packages/kbn-dev-utils/src/precommit_hook/cli.ts b/packages/kbn-dev-utils/src/precommit_hook/cli.ts index a83e8c2b193d9e2..28347f379150f6c 100644 --- a/packages/kbn-dev-utils/src/precommit_hook/cli.ts +++ b/packages/kbn-dev-utils/src/precommit_hook/cli.ts @@ -20,9 +20,9 @@ import Path from 'path'; import { chmod, writeFile } from 'fs'; import { promisify } from 'util'; +import { REPO_ROOT } from '@kbn/utils'; import { run } from '../run'; -import { REPO_ROOT } from '../repo_root'; import { SCRIPT_SOURCE } from './script_source'; import { getGitDir } from './get_git_dir'; diff --git a/packages/kbn-dev-utils/src/precommit_hook/get_git_dir.ts b/packages/kbn-dev-utils/src/precommit_hook/get_git_dir.ts index 5ca7d67d0d4ead0..f75c86f51009521 100644 --- a/packages/kbn-dev-utils/src/precommit_hook/get_git_dir.ts +++ b/packages/kbn-dev-utils/src/precommit_hook/get_git_dir.ts @@ -19,7 +19,7 @@ import execa from 'execa'; -import { REPO_ROOT } from '../repo_root'; +import { REPO_ROOT } from '@kbn/utils'; // Retrieves the correct location for the .git dir for // every git setup (including git worktree) diff --git a/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.ts b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.ts index 4008cf852c3a81b..cc6b8334d76cff5 100644 --- a/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.ts +++ b/packages/kbn-dev-utils/src/serializers/absolute_path_serializer.ts @@ -17,7 +17,7 @@ * under the License. */ -import { REPO_ROOT } from '../repo_root'; +import { REPO_ROOT } from '@kbn/utils'; export function createAbsolutePathSerializer( rootPath: string = REPO_ROOT, diff --git a/packages/kbn-optimizer/README.md b/packages/kbn-optimizer/README.md index 13be836f0ea8855..a666907f0267897 100644 --- a/packages/kbn-optimizer/README.md +++ b/packages/kbn-optimizer/README.md @@ -69,7 +69,8 @@ To run the optimizer from code, you can import the [`OptimizerConfig`][Optimizer Example: ```ts import { runOptimizer, OptimizerConfig, logOptimizerState } from '@kbn/optimizer'; -import { REPO_ROOT, ToolingLog } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { ToolingLog } from '@kbn/dev-utils'; const log = new ToolingLog({ level: 'verbose', diff --git a/packages/kbn-optimizer/src/cli.ts b/packages/kbn-optimizer/src/cli.ts index 542dc7255f22f2d..dcfb56be66efd8d 100644 --- a/packages/kbn-optimizer/src/cli.ts +++ b/packages/kbn-optimizer/src/cli.ts @@ -21,7 +21,8 @@ import 'source-map-support/register'; import Path from 'path'; -import { run, REPO_ROOT, createFlagError, CiStatsReporter } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { run, createFlagError, CiStatsReporter } from '@kbn/dev-utils'; import { logOptimizerState } from './log_optimizer_state'; import { OptimizerConfig } from './optimizer'; diff --git a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts index 12f037f5080fc4f..de3838eb92975c5 100644 --- a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts +++ b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts @@ -25,7 +25,8 @@ import { inspect } from 'util'; import cpy from 'cpy'; import del from 'del'; import { toArray, tap, filter } from 'rxjs/operators'; -import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { ToolingLog } from '@kbn/dev-utils'; import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '@kbn/optimizer'; const TMP_DIR = Path.resolve(__dirname, '../__fixtures__/__tmp__'); diff --git a/packages/kbn-optimizer/src/optimizer/cache_keys.test.ts b/packages/kbn-optimizer/src/optimizer/cache_keys.test.ts index 47d01347a8f7d1f..1b4c9b117c4c30a 100644 --- a/packages/kbn-optimizer/src/optimizer/cache_keys.test.ts +++ b/packages/kbn-optimizer/src/optimizer/cache_keys.test.ts @@ -20,7 +20,8 @@ import Path from 'path'; import jestDiff from 'jest-diff'; -import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; import { reformatJestDiff, getOptimizerCacheKey, diffCacheKey } from './cache_keys'; import { OptimizerConfig } from './optimizer_config'; diff --git a/packages/kbn-optimizer/src/optimizer/cache_keys.ts b/packages/kbn-optimizer/src/optimizer/cache_keys.ts index d0aaad979485d23..8dde67683a73948 100644 --- a/packages/kbn-optimizer/src/optimizer/cache_keys.ts +++ b/packages/kbn-optimizer/src/optimizer/cache_keys.ts @@ -23,7 +23,7 @@ import { promisify } from 'util'; import Chalk from 'chalk'; import execa from 'execa'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import stripAnsi from 'strip-ansi'; import jestDiff from 'jest-diff'; diff --git a/packages/kbn-optimizer/src/optimizer/handle_optimizer_completion.test.ts b/packages/kbn-optimizer/src/optimizer/handle_optimizer_completion.test.ts index 3cc58e744a7b94d..6edcde56e26de9f 100644 --- a/packages/kbn-optimizer/src/optimizer/handle_optimizer_completion.test.ts +++ b/packages/kbn-optimizer/src/optimizer/handle_optimizer_completion.test.ts @@ -18,7 +18,7 @@ */ import * as Rx from 'rxjs'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { Update } from '../common'; diff --git a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts index afc2dc8952c87a2..fd887e8c2c0122c 100644 --- a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts +++ b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts @@ -32,7 +32,8 @@ jest.mock('os', () => { }); import Path from 'path'; -import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; import { OptimizerConfig, ParsedOptions } from './optimizer_config'; import { parseThemeTags } from '../common'; diff --git a/packages/kbn-plugin-generator/src/ask_questions.ts b/packages/kbn-plugin-generator/src/ask_questions.ts index b5983961872454c..732e22b0e22259d 100644 --- a/packages/kbn-plugin-generator/src/ask_questions.ts +++ b/packages/kbn-plugin-generator/src/ask_questions.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import inquirer from 'inquirer'; export interface Answers { diff --git a/packages/kbn-plugin-generator/src/cli.ts b/packages/kbn-plugin-generator/src/cli.ts index f6966a245e46fcd..14c910a943fd5f5 100644 --- a/packages/kbn-plugin-generator/src/cli.ts +++ b/packages/kbn-plugin-generator/src/cli.ts @@ -21,7 +21,8 @@ import Path from 'path'; import Fs from 'fs'; import execa from 'execa'; -import { REPO_ROOT, run, createFailError, createFlagError } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { run, createFailError, createFlagError } from '@kbn/dev-utils'; import { snakeCase } from './casing'; import { askQuestions, getDefaultAnswers } from './ask_questions'; diff --git a/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts b/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts index b48113afc0ca7e0..25669b65e1ac9ca 100644 --- a/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts +++ b/packages/kbn-plugin-generator/src/integration_tests/generate_plugin.test.ts @@ -21,7 +21,8 @@ import Path from 'path'; import del from 'del'; import execa from 'execa'; -import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; import globby from 'globby'; const GENERATED_DIR = Path.resolve(REPO_ROOT, `plugins`); diff --git a/packages/kbn-plugin-generator/src/plugin_types.ts b/packages/kbn-plugin-generator/src/plugin_types.ts index ae5201f4e8dbb2f..778e33353a2aaa6 100644 --- a/packages/kbn-plugin-generator/src/plugin_types.ts +++ b/packages/kbn-plugin-generator/src/plugin_types.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; export interface PluginType { thirdParty: boolean; diff --git a/packages/kbn-plugin-generator/src/render_template.ts b/packages/kbn-plugin-generator/src/render_template.ts index 894088c11965168..ecb168042b1c2be 100644 --- a/packages/kbn-plugin-generator/src/render_template.ts +++ b/packages/kbn-plugin-generator/src/render_template.ts @@ -23,7 +23,8 @@ import { promisify } from 'util'; import vfs from 'vinyl-fs'; import prettier from 'prettier'; -import { REPO_ROOT, transformFileStream } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { transformFileStream } from '@kbn/dev-utils'; import ejs from 'ejs'; import { Minimatch } from 'minimatch'; diff --git a/packages/kbn-plugin-helpers/src/integration_tests/build.test.ts b/packages/kbn-plugin-helpers/src/integration_tests/build.test.ts index be23d8dbde64675..5c1ecc4ee4ee48a 100644 --- a/packages/kbn-plugin-helpers/src/integration_tests/build.test.ts +++ b/packages/kbn-plugin-helpers/src/integration_tests/build.test.ts @@ -21,7 +21,8 @@ import Path from 'path'; import Fs from 'fs'; import execa from 'execa'; -import { createStripAnsiSerializer, REPO_ROOT, createReplaceSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createStripAnsiSerializer, createReplaceSerializer } from '@kbn/dev-utils'; import extract from 'extract-zip'; import del from 'del'; import globby from 'globby'; diff --git a/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts b/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts index 8f48670e49de451..8ed20a26649e7c0 100644 --- a/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts +++ b/packages/kbn-plugin-helpers/src/load_kibana_platform_plugin.ts @@ -19,12 +19,8 @@ import Path from 'path'; -import { - REPO_ROOT, - parseKibanaPlatformPlugin, - KibanaPlatformPlugin, - createFailError, -} from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { parseKibanaPlatformPlugin, KibanaPlatformPlugin, createFailError } from '@kbn/dev-utils'; export type Plugin = KibanaPlatformPlugin; diff --git a/packages/kbn-plugin-helpers/src/tasks/optimize.ts b/packages/kbn-plugin-helpers/src/tasks/optimize.ts index 6cfeda8b2d81ba1..fc1bf48cc0e36e3 100644 --- a/packages/kbn-plugin-helpers/src/tasks/optimize.ts +++ b/packages/kbn-plugin-helpers/src/tasks/optimize.ts @@ -21,7 +21,7 @@ import Fs from 'fs'; import Path from 'path'; import { promisify } from 'util'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { OptimizerConfig, runOptimizer, logOptimizerState } from '@kbn/optimizer'; import { BuildContext } from '../build_context'; diff --git a/packages/kbn-pm/package.json b/packages/kbn-pm/package.json index 914ca2fd65fa24d..1fb94e4c92ce136 100644 --- a/packages/kbn-pm/package.json +++ b/packages/kbn-pm/package.json @@ -66,6 +66,7 @@ "write-pkg": "^4.0.0" }, "dependencies": { + "@kbn/utils": "1.0.0", "tslib": "^2.0.0" } } diff --git a/packages/kbn-release-notes/src/cli.ts b/packages/kbn-release-notes/src/cli.ts index 44b4a7a0282d205..4655abde4d5939f 100644 --- a/packages/kbn-release-notes/src/cli.ts +++ b/packages/kbn-release-notes/src/cli.ts @@ -21,7 +21,8 @@ import Fs from 'fs'; import Path from 'path'; import { inspect } from 'util'; -import { run, createFlagError, createFailError, REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { run, createFlagError, createFailError } from '@kbn/dev-utils'; import { FORMATS, SomeFormat } from './formats'; import { diff --git a/packages/kbn-storybook/lib/constants.js b/packages/kbn-storybook/lib/constants.js index 9d216d347eada9e..4d8ca0adbfe17f4 100644 --- a/packages/kbn-storybook/lib/constants.js +++ b/packages/kbn-storybook/lib/constants.js @@ -17,10 +17,10 @@ * under the License. */ -const { resolve, dirname } = require('path'); +const { resolve } = require('path'); +const { REPO_ROOT } = require('@kbn/utils'); -exports.REPO_ROOT = dirname(require.resolve('../../../package.json')); -exports.ASSET_DIR = resolve(exports.REPO_ROOT, 'built_assets/storybook'); +exports.ASSET_DIR = resolve(REPO_ROOT, 'built_assets/storybook'); exports.CURRENT_CONFIG = resolve(exports.ASSET_DIR, 'current.config.js'); exports.STORY_ENTRY_PATH = resolve(exports.ASSET_DIR, 'stories.entry.js'); exports.DLL_DIST_DIR = resolve(exports.ASSET_DIR, 'dll'); diff --git a/packages/kbn-storybook/lib/dll.js b/packages/kbn-storybook/lib/dll.js index a9154ca972120c3..55bc8e43a02ec8c 100644 --- a/packages/kbn-storybook/lib/dll.js +++ b/packages/kbn-storybook/lib/dll.js @@ -20,7 +20,8 @@ const { resolve } = require('path'); const { existsSync } = require('fs'); -const { REPO_ROOT, DLL_DIST_DIR } = require('./constants'); +const { REPO_ROOT } = require('@kbn/utils'); +const { DLL_DIST_DIR } = require('./constants'); exports.buildDll = async ({ rebuildDll, log, procRunner }) => { if (rebuildDll) { diff --git a/packages/kbn-storybook/lib/storybook_entry.js b/packages/kbn-storybook/lib/storybook_entry.js index 8b8aa4126ad8842..fc970b1ff9d2a78 100644 --- a/packages/kbn-storybook/lib/storybook_entry.js +++ b/packages/kbn-storybook/lib/storybook_entry.js @@ -27,11 +27,12 @@ const { promisify } = require('util'); const watch = require('glob-watcher'); const mkdirp = require('mkdirp'); // eslint-disable-line const glob = require('fast-glob'); +const { REPO_ROOT } = require('@kbn/utils'); const mkdirpAsync = promisify(mkdirp); const writeFileAsync = promisify(Fs.writeFile); -const { REPO_ROOT, STORY_ENTRY_PATH } = require('./constants'); +const { STORY_ENTRY_PATH } = require('./constants'); const STORE_ENTRY_DIR = dirname(STORY_ENTRY_PATH); exports.generateStorybookEntry = ({ log, storyGlobs }) => { diff --git a/packages/kbn-storybook/lib/webpack.dll.config.js b/packages/kbn-storybook/lib/webpack.dll.config.js index 18dbe3bd049d3c9..6e3b4d41bd7f095 100644 --- a/packages/kbn-storybook/lib/webpack.dll.config.js +++ b/packages/kbn-storybook/lib/webpack.dll.config.js @@ -20,8 +20,9 @@ const webpack = require('webpack'); const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const { REPO_ROOT } = require('@kbn/utils'); -const { DLL_NAME, REPO_ROOT, DLL_DIST_DIR } = require('./constants'); +const { DLL_NAME, DLL_DIST_DIR } = require('./constants'); // This is the Webpack config for the DLL of CSS and JS assets that are // not expected to change during development. This saves compile and run diff --git a/packages/kbn-storybook/storybook_config/webpack.config.js b/packages/kbn-storybook/storybook_config/webpack.config.js index d505c4f9a04481e..60b6b6add66d151 100644 --- a/packages/kbn-storybook/storybook_config/webpack.config.js +++ b/packages/kbn-storybook/storybook_config/webpack.config.js @@ -22,7 +22,8 @@ const webpack = require('webpack'); const webpackMerge = require('webpack-merge'); const { stringifyRequest } = require('loader-utils'); const CopyWebpackPlugin = require('copy-webpack-plugin'); -const { REPO_ROOT, DLL_DIST_DIR } = require('../lib/constants'); +const { REPO_ROOT } = require('@kbn/utils'); +const { DLL_DIST_DIR } = require('../lib/constants'); // eslint-disable-next-line import/no-unresolved const { currentConfig } = require('../../../built_assets/storybook/current.config'); diff --git a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts index 3dfb1ea44d9e74e..93616ce78a04a57 100644 --- a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts +++ b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts @@ -19,7 +19,8 @@ import Path from 'path'; -import { REPO_ROOT, run, createFailError, createFlagError } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { run, createFailError, createFlagError } from '@kbn/dev-utils'; import globby from 'globby'; import { getFailures, TestFailure } from './get_failures'; diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js b/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js index 133f4d2feb53e6e..a010d9f0b038eec 100644 --- a/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js +++ b/packages/kbn-test/src/functional_test_runner/__tests__/integration/basic.js @@ -21,7 +21,7 @@ import { spawnSync } from 'child_process'; import { resolve } from 'path'; import expect from '@kbn/expect'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js'); const BASIC_CONFIG = require.resolve('../fixtures/simple_project/config.js'); diff --git a/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js b/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js index 12e28d2702c5a6b..fa4ef88fd3e703e 100644 --- a/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js +++ b/packages/kbn-test/src/functional_test_runner/__tests__/integration/failure_hooks.js @@ -22,7 +22,7 @@ import { resolve } from 'path'; import stripAnsi from 'strip-ansi'; import expect from '@kbn/expect'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; const SCRIPT = resolve(REPO_ROOT, 'scripts/functional_test_runner.js'); const FAILURE_HOOKS_CONFIG = require.resolve('../fixtures/failure_hooks/config.js'); diff --git a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts b/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts index fdf8b3c0ddfa8ed..e5c60f1d208b117 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts @@ -19,7 +19,7 @@ import Path from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { Lifecycle } from './lifecycle'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js b/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js index 5d3d8fe7d759bb5..92137a8c4f841f6 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js @@ -17,7 +17,7 @@ * under the License. */ import { relative } from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { createAssignmentProxy } from './assignment_proxy'; import { wrapFunction } from './wrap_function'; import { wrapRunnableArgs } from './wrap_runnable_args'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js b/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js index 3ac7a50cd28ea00..39eb69a15191899 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/setup_mocha.js @@ -19,7 +19,7 @@ import Mocha from 'mocha'; import { relative } from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { loadTestFiles } from './load_test_files'; import { filterSuitesByTags } from './filter_suites_by_tags'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts index f879408bf2bebbb..5350b2709843d07 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts @@ -21,7 +21,7 @@ import fs from 'fs'; import { join, resolve } from 'path'; jest.mock('fs'); -jest.mock('@kbn/dev-utils', () => { +jest.mock('@kbn/utils', () => { return { REPO_ROOT: '/dev/null/root' }; }); diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts index b346be2d58dad20..6cbd74467106fd7 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts @@ -19,7 +19,7 @@ import fs from 'fs'; import { dirname, relative, resolve } from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { Lifecycle } from './lifecycle'; diff --git a/packages/kbn-test/src/mocha/run_mocha_cli.js b/packages/kbn-test/src/mocha/run_mocha_cli.js index 3c77fef963a76d8..0fc7c762be42521 100644 --- a/packages/kbn-test/src/mocha/run_mocha_cli.js +++ b/packages/kbn-test/src/mocha/run_mocha_cli.js @@ -17,7 +17,7 @@ * under the License. */ -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import getopts from 'getopts'; import globby from 'globby'; diff --git a/packages/kbn-ui-shared-deps/webpack.config.js b/packages/kbn-ui-shared-deps/webpack.config.js index c81da4689052a59..9ed32f23ae84f8e 100644 --- a/packages/kbn-ui-shared-deps/webpack.config.js +++ b/packages/kbn-ui-shared-deps/webpack.config.js @@ -21,7 +21,7 @@ const Path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CompressionPlugin = require('compression-webpack-plugin'); -const { REPO_ROOT } = require('@kbn/dev-utils'); +const { REPO_ROOT } = require('@kbn/utils'); const webpack = require('webpack'); const UiSharedDeps = require('./index'); diff --git a/packages/kbn-utils/package.json b/packages/kbn-utils/package.json new file mode 100644 index 000000000000000..0733b28a453eb61 --- /dev/null +++ b/packages/kbn-utils/package.json @@ -0,0 +1,19 @@ +{ + "name": "@kbn/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" + }, + "dependencies": { + "@kbn/config-schema": "1.0.0", + "elastic-apm-node": "^3.7.0" + }, + "devDependencies": { + "typescript": "3.9.5" + } +} diff --git a/packages/kbn-utils/src/index.ts b/packages/kbn-utils/src/index.ts new file mode 100644 index 000000000000000..7a894d72d5624bb --- /dev/null +++ b/packages/kbn-utils/src/index.ts @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './package_json'; +export * from './path'; +export * from './repo_root'; diff --git a/packages/kbn-utils/src/package_json/index.test.ts b/packages/kbn-utils/src/package_json/index.test.ts new file mode 100644 index 000000000000000..afc84102999fe53 --- /dev/null +++ b/packages/kbn-utils/src/package_json/index.test.ts @@ -0,0 +1,31 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import path from 'path'; +import { kibanaPackageJSON } from './'; + +it('parses package.json', () => { + expect(kibanaPackageJSON.name).toEqual('kibana'); +}); + +it('includes __dirname and __filename', () => { + const root = path.resolve(__dirname, '../../../../'); + expect(kibanaPackageJSON.__filename).toEqual(path.resolve(root, 'package.json')); + expect(kibanaPackageJSON.__dirname).toEqual(root); +}); diff --git a/packages/kbn-utils/src/package_json/index.ts b/packages/kbn-utils/src/package_json/index.ts new file mode 100644 index 000000000000000..f439c0100e19318 --- /dev/null +++ b/packages/kbn-utils/src/package_json/index.ts @@ -0,0 +1,27 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { dirname, resolve } from 'path'; +import { REPO_ROOT } from '../repo_root'; + +export const kibanaPackageJSON = { + __filename: resolve(REPO_ROOT, 'package.json'), + __dirname: dirname(resolve(REPO_ROOT, 'package.json')), + ...require(resolve(REPO_ROOT, 'package.json')), +}; diff --git a/src/core/server/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts similarity index 100% rename from src/core/server/path/index.test.ts rename to packages/kbn-utils/src/path/index.test.ts diff --git a/src/core/server/path/index.ts b/packages/kbn-utils/src/path/index.ts similarity index 91% rename from src/core/server/path/index.ts rename to packages/kbn-utils/src/path/index.ts index 7c1a81643fbc813..3635bf61a9f416d 100644 --- a/src/core/server/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -20,7 +20,7 @@ import { join } from 'path'; import { accessSync, constants } from 'fs'; import { TypeOf, schema } from '@kbn/config-schema'; -import { fromRoot } from '../utils'; +import { REPO_ROOT } from '../repo_root'; const isString = (v: any): v is string => typeof v === 'string'; @@ -28,19 +28,19 @@ 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.CONFIG_PATH, // deprecated - fromRoot('config/kibana.yml'), + join(REPO_ROOT, 'config/kibana.yml'), ].filter(isString); const CONFIG_DIRECTORIES = [ process.env.KBN_PATH_CONF, process.env.KIBANA_PATH_CONF, - fromRoot('config'), + join(REPO_ROOT, 'config'), '/etc/kibana', ].filter(isString); const DATA_PATHS = [ process.env.DATA_PATH, // deprecated - fromRoot('data'), + join(REPO_ROOT, 'data'), '/var/lib/kibana', ].filter(isString); @@ -72,7 +72,9 @@ export const getConfigDirectory = () => findFile(CONFIG_DIRECTORIES); * Get the directory containing runtime data * @internal */ -export const getDataPath = () => findFile(DATA_PATHS); +export const getDataPath = () => { + return findFile(DATA_PATHS); +}; export type PathConfigType = TypeOf; diff --git a/packages/kbn-dev-utils/src/repo_root.ts b/packages/kbn-utils/src/repo_root.ts similarity index 100% rename from packages/kbn-dev-utils/src/repo_root.ts rename to packages/kbn-utils/src/repo_root.ts diff --git a/packages/kbn-utils/tsconfig.json b/packages/kbn-utils/tsconfig.json new file mode 100644 index 000000000000000..0ec058eeb8a2806 --- /dev/null +++ b/packages/kbn-utils/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "target", + "target": "ES2019", + "declaration": true, + "declarationMap": true + }, + "include": [ + "src/**/*" + ] +} diff --git a/packages/kbn-utils/yarn.lock b/packages/kbn-utils/yarn.lock new file mode 120000 index 000000000000000..3f82ebc9cdbae37 --- /dev/null +++ b/packages/kbn-utils/yarn.lock @@ -0,0 +1 @@ +../../yarn.lock \ No newline at end of file diff --git a/src/cli/cluster/cluster_manager.ts b/src/cli/cluster/cluster_manager.ts index eb7db8dac7cb66b..b1d1335eb188854 100644 --- a/src/cli/cluster/cluster_manager.ts +++ b/src/cli/cluster/cluster_manager.ts @@ -21,7 +21,7 @@ import { resolve } from 'path'; import { format as formatUrl } from 'url'; import opn from 'opn'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { FSWatcher } from 'chokidar'; import * as Rx from 'rxjs'; import { startWith, mapTo, filter, map, take, tap } from 'rxjs/operators'; diff --git a/src/cli/cluster/run_kbn_optimizer.ts b/src/cli/cluster/run_kbn_optimizer.ts index c231437da394379..8196cad4a99c733 100644 --- a/src/cli/cluster/run_kbn_optimizer.ts +++ b/src/cli/cluster/run_kbn_optimizer.ts @@ -19,12 +19,12 @@ import Chalk from 'chalk'; import moment from 'moment'; +import { REPO_ROOT } from '@kbn/utils'; import { ToolingLog, pickLevelFromFlags, ToolingLogTextWriter, parseLogLevel, - REPO_ROOT, } from '@kbn/dev-utils'; import { runOptimizer, OptimizerConfig, logOptimizerState } from '@kbn/optimizer'; diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index c08f3aec64335b1..eeb5564667ec4af 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -23,9 +23,9 @@ import { statSync } from 'fs'; import { resolve } from 'path'; import url from 'url'; +import { getConfigPath } from '@kbn/utils'; import { IS_KIBANA_DISTRIBUTABLE } from '../../legacy/utils'; import { fromRoot } from '../../core/server/utils'; -import { getConfigPath } from '../../core/server/path'; import { bootstrap } from '../../core/server'; import { readKeystore } from './read_keystore'; diff --git a/src/cli_keystore/get_keystore.js b/src/cli_keystore/get_keystore.js index e181efe9196b8e6..b97efbb2cbf4db9 100644 --- a/src/cli_keystore/get_keystore.js +++ b/src/cli_keystore/get_keystore.js @@ -21,7 +21,7 @@ import { existsSync } from 'fs'; import { join } from 'path'; import { Logger } from '../cli_plugin/lib/logger'; -import { getConfigDirectory, getDataPath } from '../core/server/path'; +import { getConfigDirectory, getDataPath } from '@kbn/utils'; export function getKeystore() { const configKeystore = join(getConfigDirectory(), 'kibana.keystore'); diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index bc7e95b8489f0ca..eff14906853c182 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -17,10 +17,10 @@ * under the License. */ +import { getConfigPath } from '@kbn/utils'; import { pkg } from '../../core/server/utils'; import { install } from './install'; import { Logger } from '../lib/logger'; -import { getConfigPath } from '../../core/server/path'; import { parse, parseMilliseconds } from './settings'; import { logWarnings } from '../lib/log_warnings'; diff --git a/src/cli_plugin/remove/index.js b/src/cli_plugin/remove/index.js index c3bd96086db9b97..b9c37c0cf802b10 100644 --- a/src/cli_plugin/remove/index.js +++ b/src/cli_plugin/remove/index.js @@ -17,10 +17,10 @@ * under the License. */ +import { getConfigPath } from '@kbn/utils'; import { remove } from './remove'; import { Logger } from '../lib/logger'; import { parse } from './settings'; -import { getConfigPath } from '../../core/server/path'; import { logWarnings } from '../lib/log_warnings'; function processCommand(command, options) { diff --git a/src/core/server/environment/create_data_folder.test.ts b/src/core/server/environment/create_data_folder.test.ts index 2a480a7a3954f4d..25c1d57996e0d97 100644 --- a/src/core/server/environment/create_data_folder.test.ts +++ b/src/core/server/environment/create_data_folder.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PathConfigType } from '../path'; +import { PathConfigType } from '@kbn/utils'; import { createDataFolder } from './create_data_folder'; import { mkdir } from './fs'; import { loggingSystemMock } from '../logging/logging_system.mock'; diff --git a/src/core/server/environment/create_data_folder.ts b/src/core/server/environment/create_data_folder.ts index 641d95cbf941178..f90e9f93694eb22 100644 --- a/src/core/server/environment/create_data_folder.ts +++ b/src/core/server/environment/create_data_folder.ts @@ -17,9 +17,9 @@ * under the License. */ +import { PathConfigType } from '@kbn/utils'; import { mkdir } from './fs'; import { Logger } from '../logging'; -import { PathConfigType } from '../path'; export async function createDataFolder({ pathConfig, diff --git a/src/core/server/environment/environment_service.ts b/src/core/server/environment/environment_service.ts index 6a0b1122c705344..50d872c51f1090a 100644 --- a/src/core/server/environment/environment_service.ts +++ b/src/core/server/environment/environment_service.ts @@ -18,10 +18,10 @@ */ import { take } from 'rxjs/operators'; +import { PathConfigType, config as pathConfigDef } from '@kbn/utils'; import { CoreContext } from '../core_context'; import { Logger } from '../logging'; import { IConfigService } from '../config'; -import { PathConfigType, config as pathConfigDef } from '../path'; import { HttpConfigType, config as httpConfigDef } from '../http'; import { resolveInstanceUuid } from './resolve_uuid'; import { createDataFolder } from './create_data_folder'; diff --git a/src/core/server/environment/resolve_uuid.test.ts b/src/core/server/environment/resolve_uuid.test.ts index d162c9d8e364b7f..c6e8465507123f1 100644 --- a/src/core/server/environment/resolve_uuid.test.ts +++ b/src/core/server/environment/resolve_uuid.test.ts @@ -18,10 +18,10 @@ */ import { join } from 'path'; +import { PathConfigType } from '@kbn/utils'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { readFile, writeFile } from './fs'; import { resolveInstanceUuid, UUID_7_6_0_BUG } from './resolve_uuid'; -import { PathConfigType } from '../path'; import { HttpConfigType } from '../http'; jest.mock('uuid', () => ({ diff --git a/src/core/server/environment/resolve_uuid.ts b/src/core/server/environment/resolve_uuid.ts index 0267e0693999722..a640319e30af479 100644 --- a/src/core/server/environment/resolve_uuid.ts +++ b/src/core/server/environment/resolve_uuid.ts @@ -19,8 +19,8 @@ import uuid from 'uuid'; import { join } from 'path'; +import { PathConfigType } from '@kbn/utils'; import { readFile, writeFile } from './fs'; -import { PathConfigType } from '../path'; import { HttpConfigType } from '../http'; import { Logger } from '../logging'; diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index 7d5557be92b3005..cb36aba20f57dbb 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -20,6 +20,7 @@ import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription } from 'rxjs'; import { first, map, publishReplay, tap } from 'rxjs/operators'; +import { PathConfigType } from '@kbn/utils'; import { CoreService } from '../../types'; import { Config, ConfigDeprecationProvider } from '../config'; import { CoreContext } from '../core_context'; @@ -27,7 +28,6 @@ import { CspConfigType, config as cspConfig } from '../csp'; import { DevConfig, DevConfigType, config as devConfig } from '../dev'; import { BasePathProxyServer, HttpConfig, HttpConfigType, config as httpConfig } from '../http'; import { Logger } from '../logging'; -import { PathConfigType } from '../path'; import { findLegacyPluginSpecs, logLegacyThirdPartyPluginDeprecationWarning } from './plugins'; import { convertLegacyDeprecationProvider } from './config'; import { diff --git a/src/core/server/plugins/plugin_context.ts b/src/core/server/plugins/plugin_context.ts index eb31b2380d177fe..ef50f52902c4311 100644 --- a/src/core/server/plugins/plugin_context.ts +++ b/src/core/server/plugins/plugin_context.ts @@ -19,6 +19,7 @@ import { map, shareReplay } from 'rxjs/operators'; import { combineLatest } from 'rxjs'; +import { PathConfigType, config as pathConfig } from '@kbn/utils'; import { CoreContext } from '../core_context'; import { PluginWrapper } from './plugin'; import { PluginsServiceSetupDeps, PluginsServiceStartDeps } from './plugins_service'; @@ -28,7 +29,6 @@ import { PluginOpaqueId, SharedGlobalConfigKeys, } from './types'; -import { PathConfigType, config as pathConfig } from '../path'; import { KibanaConfigType, config as kibanaConfig } from '../kibana_config'; import { ElasticsearchConfigType, diff --git a/src/core/server/plugins/types.ts b/src/core/server/plugins/types.ts index 517261b5bc9bb19..34d5e044222eb8d 100644 --- a/src/core/server/plugins/types.ts +++ b/src/core/server/plugins/types.ts @@ -20,12 +20,12 @@ import { Observable } from 'rxjs'; import { Type } from '@kbn/config-schema'; import { RecursiveReadonly } from '@kbn/utility-types'; +import { PathConfigType } from '@kbn/utils'; import { ConfigPath, EnvironmentMode, PackageInfo, ConfigDeprecationProvider } from '../config'; import { LoggerFactory } from '../logging'; import { KibanaConfigType } from '../kibana_config'; import { ElasticsearchConfigType } from '../elasticsearch/elasticsearch_config'; -import { PathConfigType } from '../path'; import { CoreSetup, CoreStart } from '..'; /** diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index fb4e4494801ed66..ab87ed54f2ddeae 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -106,6 +106,7 @@ import { NodesStatsParams } from 'elasticsearch'; import { ObjectType } from '@kbn/config-schema'; import { Observable } from 'rxjs'; import { ParsedQuery } from 'query-string'; +import { PathConfigType } from '@kbn/utils'; import { PeerCertificate } from 'tls'; import { PingParams } from 'elasticsearch'; import { PutScriptParams } from 'elasticsearch'; @@ -2958,6 +2959,5 @@ export const validBodyOutput: readonly ["data", "stream"]; // src/core/server/legacy/types.ts:167:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:272:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:272:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/types.ts:274:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts ``` diff --git a/src/core/server/server.ts b/src/core/server/server.ts index e2f77f0551f34cc..78a01f6e351a94d 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -17,6 +17,7 @@ * under the License. */ +import { config as pathConfig } from '@kbn/utils'; import { ConfigService, Env, RawConfigurationProvider, coreDeprecationProvider } from './config'; import { CoreApp } from './core_app'; import { AuditTrailService } from './audit_trail'; @@ -39,7 +40,7 @@ import { config as elasticsearchConfig } from './elasticsearch'; import { config as httpConfig } from './http'; import { config as loggingConfig } from './logging'; import { config as devConfig } from './dev'; -import { config as pathConfig } from './path'; + import { config as kibanaConfig } from './kibana_config'; import { savedObjectsConfig, savedObjectsMigrationConfig } from './saved_objects'; import { config as uiSettingsConfig } from './ui_settings'; diff --git a/src/dev/build/lib/build.test.ts b/src/dev/build/lib/build.test.ts index 9fdf21cee656735..7ccd5b8e13a2cb6 100644 --- a/src/dev/build/lib/build.test.ts +++ b/src/dev/build/lib/build.test.ts @@ -17,7 +17,8 @@ * under the License. */ -import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; import { Config } from './config'; import { Build } from './build'; diff --git a/src/dev/build/lib/config.test.ts b/src/dev/build/lib/config.test.ts index 0539adc840a6a0a..bb4d4c000e9d538 100644 --- a/src/dev/build/lib/config.test.ts +++ b/src/dev/build/lib/config.test.ts @@ -19,7 +19,8 @@ import { resolve } from 'path'; -import { createAbsolutePathSerializer, REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { createAbsolutePathSerializer } from '@kbn/dev-utils'; import pkg from '../../../../package.json'; import { Config } from './config'; diff --git a/src/dev/build/tasks/build_kibana_platform_plugins.ts b/src/dev/build/tasks/build_kibana_platform_plugins.ts index 48625078e9bd151..44b441ad898c353 100644 --- a/src/dev/build/tasks/build_kibana_platform_plugins.ts +++ b/src/dev/build/tasks/build_kibana_platform_plugins.ts @@ -17,7 +17,8 @@ * under the License. */ -import { CiStatsReporter, REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { CiStatsReporter } from '@kbn/dev-utils'; import { runOptimizer, OptimizerConfig, diff --git a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts index a5b9e01714f3845..cd197db2510936b 100644 --- a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts @@ -20,12 +20,12 @@ import { readFileSync } from 'fs'; import Path from 'path'; +import { REPO_ROOT } from '@kbn/utils'; import { ToolingLog, ToolingLogCollectingWriter, createAbsolutePathSerializer, createRecursiveSerializer, - REPO_ROOT, } from '@kbn/dev-utils'; import { Config } from '../../lib'; diff --git a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts index 1a850890a33fed5..9b03dcd828cf9c6 100644 --- a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts @@ -20,12 +20,12 @@ import Path from 'path'; import Fs from 'fs'; +import { REPO_ROOT } from '@kbn/utils'; import { ToolingLog, ToolingLogCollectingWriter, createAnyInstanceSerializer, createRecursiveSerializer, - REPO_ROOT, } from '@kbn/dev-utils'; import { Config, Platform } from '../../lib'; diff --git a/src/dev/constants.ts b/src/dev/constants.ts index d1b89719c69b7da..9ce18ffdc9bcd15 100644 --- a/src/dev/constants.ts +++ b/src/dev/constants.ts @@ -17,10 +17,6 @@ * under the License. */ -import { dirname } from 'path'; - -export const REPO_ROOT = dirname(require.resolve('../../package.json')); - // Files in directories of this name will be treated as Jest integration tests with instances of // Elasticsearch and the Kibana server. export const RESERVED_DIR_JEST_INTEGRATION_TESTS = 'integration_tests'; diff --git a/src/dev/eslint/lint_files.ts b/src/dev/eslint/lint_files.ts index ba16163fc9bd333..ebd6bedb5f56c88 100644 --- a/src/dev/eslint/lint_files.ts +++ b/src/dev/eslint/lint_files.ts @@ -19,9 +19,9 @@ import { CLIEngine } from 'eslint'; +import { REPO_ROOT } from '@kbn/utils'; import { createFailError, ToolingLog } from '@kbn/dev-utils'; import { File } from '../file'; -import { REPO_ROOT } from '../constants'; /** * Lints a list of files with eslint. eslint reports are written to the log diff --git a/src/dev/license_checker/run_check_licenses_cli.ts b/src/dev/license_checker/run_check_licenses_cli.ts index 0267a1a90d4fe1f..70ebb43c788f991 100644 --- a/src/dev/license_checker/run_check_licenses_cli.ts +++ b/src/dev/license_checker/run_check_licenses_cli.ts @@ -17,12 +17,12 @@ * under the License. */ +import { REPO_ROOT } from '@kbn/utils'; import { run } from '@kbn/dev-utils'; import { getInstalledPackages } from '../npm'; import { LICENSE_WHITELIST, DEV_ONLY_LICENSE_WHITELIST, LICENSE_OVERRIDES } from './config'; import { assertLicensesValid } from './valid'; -import { REPO_ROOT } from '../constants'; run( async ({ log, flags }) => { diff --git a/src/dev/notice/cli.js b/src/dev/notice/cli.js index 34217ef48a33b2e..ea0f884bb1ea078 100644 --- a/src/dev/notice/cli.js +++ b/src/dev/notice/cli.js @@ -22,9 +22,9 @@ import { resolve } from 'path'; import getopts from 'getopts'; import dedent from 'dedent'; +import { REPO_ROOT } from '@kbn/utils'; import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils'; -import { REPO_ROOT } from '../constants'; import { generateNoticeFromSource } from './generate_notice_from_source'; const unknownFlags = []; diff --git a/src/dev/npm/integration_tests/installed_packages.test.ts b/src/dev/npm/integration_tests/installed_packages.test.ts index 58c954cbc12f72b..3aeb5b106c2ec07 100644 --- a/src/dev/npm/integration_tests/installed_packages.test.ts +++ b/src/dev/npm/integration_tests/installed_packages.test.ts @@ -21,8 +21,8 @@ import { resolve, sep } from 'path'; import { uniq } from 'lodash'; +import { REPO_ROOT } from '@kbn/utils'; import { getInstalledPackages, InstalledPackage } from '../installed_packages'; -import { REPO_ROOT } from '../../constants'; const FIXTURE1_ROOT = resolve(__dirname, '__fixtures__/fixture1'); diff --git a/src/dev/precommit_hook/get_files_for_commit.js b/src/dev/precommit_hook/get_files_for_commit.js index dc5560be0d1ade0..e700b587821749a 100644 --- a/src/dev/precommit_hook/get_files_for_commit.js +++ b/src/dev/precommit_hook/get_files_for_commit.js @@ -20,7 +20,7 @@ import SimpleGit from 'simple-git'; import { fromNode as fcb } from 'bluebird'; -import { REPO_ROOT } from '../constants'; +import { REPO_ROOT } from '@kbn/utils'; import { File } from '../file'; /** diff --git a/src/dev/run_check_file_casing.js b/src/dev/run_check_file_casing.js index bdbf1827897e760..3acff74430abeb8 100644 --- a/src/dev/run_check_file_casing.js +++ b/src/dev/run_check_file_casing.js @@ -19,9 +19,9 @@ import globby from 'globby'; +import { REPO_ROOT } from '@kbn/utils'; import { run } from '@kbn/dev-utils'; import { File } from './file'; -import { REPO_ROOT } from './constants'; import { checkFileCasing } from './precommit_hook/check_file_casing'; run(async ({ log }) => { diff --git a/src/dev/run_check_lockfile_symlinks.js b/src/dev/run_check_lockfile_symlinks.js index 5ebb7952e2cf329..c4e040c4bffa3d0 100644 --- a/src/dev/run_check_lockfile_symlinks.js +++ b/src/dev/run_check_lockfile_symlinks.js @@ -21,9 +21,9 @@ import { existsSync, lstatSync, readFileSync, readlinkSync } from 'fs'; import globby from 'globby'; import { dirname } from 'path'; +import { REPO_ROOT } from '@kbn/utils'; import { run, createFailError } from '@kbn/dev-utils'; -import { REPO_ROOT } from './constants'; import { File } from './file'; import { matchesAnyGlob } from './globs'; diff --git a/src/dev/storybook/commands/clean.ts b/src/dev/storybook/commands/clean.ts index 328c4d9e2c23c29..539757d0e7ad22b 100644 --- a/src/dev/storybook/commands/clean.ts +++ b/src/dev/storybook/commands/clean.ts @@ -18,7 +18,7 @@ */ import { ToolingLog } from '@kbn/dev-utils'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { join } from 'path'; import del from 'del'; diff --git a/src/dev/storybook/run_storybook_cli.ts b/src/dev/storybook/run_storybook_cli.ts index 7f97cff91aaaafa..b1e8d882e535282 100644 --- a/src/dev/storybook/run_storybook_cli.ts +++ b/src/dev/storybook/run_storybook_cli.ts @@ -19,7 +19,7 @@ import { join } from 'path'; import { run, createFlagError } from '@kbn/dev-utils'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { storybookAliases } from './aliases'; import { clean } from './commands/clean'; diff --git a/src/dev/typescript/get_ts_project_for_absolute_path.ts b/src/dev/typescript/get_ts_project_for_absolute_path.ts index 54d7e950834a4c2..0057263660b7771 100644 --- a/src/dev/typescript/get_ts_project_for_absolute_path.ts +++ b/src/dev/typescript/get_ts_project_for_absolute_path.ts @@ -18,7 +18,7 @@ */ import { relative, resolve } from 'path'; -import { REPO_ROOT } from '../constants'; +import { REPO_ROOT } from '@kbn/utils'; import { File } from '../file'; import { Project } from './project'; import { PROJECTS } from './projects'; diff --git a/src/dev/typescript/project.ts b/src/dev/typescript/project.ts index 4cf87d812a0b388..811c1792f1988e1 100644 --- a/src/dev/typescript/project.ts +++ b/src/dev/typescript/project.ts @@ -23,7 +23,7 @@ import { basename, dirname, relative, resolve } from 'path'; import { IMinimatch, Minimatch } from 'minimatch'; import { parseConfigFileTextToJson } from 'typescript'; -import { REPO_ROOT } from '../constants'; +import { REPO_ROOT } from '@kbn/utils'; function makeMatchers(directory: string, patterns: string[]) { return patterns.map( diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 065321e355256a8..462d9888341f987 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -19,7 +19,7 @@ import glob from 'glob'; import { resolve } from 'path'; -import { REPO_ROOT } from '../constants'; +import { REPO_ROOT } from '@kbn/utils'; import { Project } from './project'; export const PROJECTS = [ diff --git a/src/dev/typescript/run_check_ts_projects_cli.ts b/src/dev/typescript/run_check_ts_projects_cli.ts index b0c125ea478294c..a095bef047711e9 100644 --- a/src/dev/typescript/run_check_ts_projects_cli.ts +++ b/src/dev/typescript/run_check_ts_projects_cli.ts @@ -22,8 +22,8 @@ import { resolve } from 'path'; import execa from 'execa'; import { run } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; -const REPO_ROOT = resolve(__dirname, '../../../'); import { File } from '../file'; import { PROJECTS } from './projects'; diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index 9f114f213200982..68919a4809e2ea4 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -117,6 +117,7 @@ import { NodesHotThreadsParams } from 'elasticsearch'; import { NodesInfoParams } from 'elasticsearch'; import { NodesStatsParams } from 'elasticsearch'; import { Observable } from 'rxjs'; +import { PathConfigType } from '@kbn/utils'; import { PingParams } from 'elasticsearch'; import { Plugin as Plugin_2 } from 'src/core/server'; import { PluginInitializerContext as PluginInitializerContext_2 } from 'src/core/server'; diff --git a/src/plugins/telemetry/server/config.ts b/src/plugins/telemetry/server/config.ts index ae9b70bb9f3672d..f547bf55091a79f 100644 --- a/src/plugins/telemetry/server/config.ts +++ b/src/plugins/telemetry/server/config.ts @@ -18,8 +18,7 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getConfigPath } from '../../../core/server/path'; +import { getConfigPath } from '@kbn/utils'; import { ENDPOINT_VERSION } from '../common/constants'; export const configSchema = schema.object({ diff --git a/x-pack/tasks/build.ts b/x-pack/tasks/build.ts index 085f63206507f7f..41bf9587cad1e48 100644 --- a/x-pack/tasks/build.ts +++ b/x-pack/tasks/build.ts @@ -10,7 +10,8 @@ import { writeFileSync } from 'fs'; import { promisify } from 'util'; import { pipeline } from 'stream'; -import { ToolingLog, REPO_ROOT, transformFileStream, transformFileWithBabel } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; +import { ToolingLog, transformFileStream, transformFileWithBabel } from '@kbn/dev-utils'; import gulp from 'gulp'; import del from 'del'; import fancyLog from 'fancy-log'; diff --git a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts index 5c41945cb88d857..87f94855672a992 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import expect from '@kbn/expect'; import fs from 'fs'; import path from 'path'; diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/constants.ts b/x-pack/test/reporting_api_integration/reporting_and_security/constants.ts index 590ef6325dd5171..c1a518507ec37bc 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/constants.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/constants.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import path from 'path'; export const OSS_KIBANA_ARCHIVE_PATH = path.resolve( diff --git a/x-pack/test/saved_object_api_integration/common/config.ts b/x-pack/test/saved_object_api_integration/common/config.ts index 61884f521cfaf1f..32ece6aa6437a01 100644 --- a/x-pack/test/saved_object_api_integration/common/config.ts +++ b/x-pack/test/saved_object_api_integration/common/config.ts @@ -6,7 +6,7 @@ import path from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { services } from './services'; diff --git a/x-pack/test/spaces_api_integration/common/config.ts b/x-pack/test/spaces_api_integration/common/config.ts index 89fa07566ecbaec..b1da9931f3c9b3d 100644 --- a/x-pack/test/spaces_api_integration/common/config.ts +++ b/x-pack/test/spaces_api_integration/common/config.ts @@ -6,7 +6,7 @@ import path from 'path'; -import { REPO_ROOT } from '@kbn/dev-utils'; +import { REPO_ROOT } from '@kbn/utils'; import { TestInvoker } from './lib/types'; // @ts-ignore diff --git a/yarn.lock b/yarn.lock index c0c2305609f5807..765ae5182628e9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28418,7 +28418,7 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@4.0.2, typescript@^3.0.1, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: +typescript@3.9.5, typescript@4.0.2, typescript@^3.0.1, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: version "4.0.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==