Moves common utility functions to obtain the repository root, paths (config/data), and Kibana package.json to a @kbn/utils package. Moving these existing functions allows them to be used in production, in other packages because of Kibana. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> * [@kbn/utils] Adds missing dependency (#77536) Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
de1572f66c
commit
9da8f8aa4a
|
@ -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';
|
||||
|
|
|
@ -287,6 +287,7 @@
|
|||
"@types/hoek": "^4.1.3",
|
||||
"@types/inert": "^5.1.2",
|
||||
"@types/jest": "^25.2.3",
|
||||
"@types/jest-when": "^2.7.1",
|
||||
"@types/joi": "^13.4.2",
|
||||
"@types/jquery": "^3.3.31",
|
||||
"@types/js-yaml": "^3.11.1",
|
||||
|
@ -411,6 +412,7 @@
|
|||
"jest-cli": "^25.5.4",
|
||||
"jest-environment-jsdom-thirteen": "^1.0.1",
|
||||
"jest-raw-loader": "^1.0.1",
|
||||
"jest-when": "^2.7.2",
|
||||
"jimp": "^0.14.0",
|
||||
"jquery": "^3.5.0",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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[]) {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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__');
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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`);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
"write-pkg": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kbn/utils": "1.0.0",
|
||||
"tslib": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"kbn:watch": "tsc --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kbn/utils": "1.0.0",
|
||||
"@kbn/dev-utils": "1.0.0",
|
||||
"axios": "^0.19.2",
|
||||
"cheerio": "0.22.0",
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 }) => {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"dependencies": {
|
||||
"@kbn/babel-preset": "1.0.0",
|
||||
"@kbn/dev-utils": "1.0.0",
|
||||
"@kbn/utils": "1.0.0",
|
||||
"@storybook/addon-actions": "^5.3.19",
|
||||
"@storybook/addon-console": "^1.2.1",
|
||||
"@storybook/addon-info": "^5.3.19",
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"@babel/cli": "^7.10.5",
|
||||
"@kbn/babel-preset": "1.0.0",
|
||||
"@kbn/dev-utils": "1.0.0",
|
||||
"@kbn/utils": "1.0.0",
|
||||
"@types/joi": "^13.4.2",
|
||||
"@types/lodash": "^4.14.159",
|
||||
"@types/parse-link-header": "^1.0.0",
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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' };
|
||||
});
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
3
packages/kbn-utils/README.md
Normal file
3
packages/kbn-utils/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/utils
|
||||
|
||||
Shared server-side utilities shared across packages and plugins.
|
19
packages/kbn-utils/package.json
Normal file
19
packages/kbn-utils/package.json
Normal file
|
@ -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",
|
||||
"load-json-file": "^6.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "4.0.2"
|
||||
}
|
||||
}
|
22
packages/kbn-utils/src/index.ts
Normal file
22
packages/kbn-utils/src/index.ts
Normal file
|
@ -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';
|
31
packages/kbn-utils/src/package_json/index.test.ts
Normal file
31
packages/kbn-utils/src/package_json/index.test.ts
Normal file
|
@ -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);
|
||||
});
|
27
packages/kbn-utils/src/package_json/index.ts
Normal file
27
packages/kbn-utils/src/package_json/index.ts
Normal file
|
@ -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')),
|
||||
};
|
|
@ -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);
|
||||
|
11
packages/kbn-utils/tsconfig.json
Normal file
11
packages/kbn-utils/tsconfig.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target",
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
1
packages/kbn-utils/yarn.lock
Symbolic link
1
packages/kbn-utils/yarn.lock
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../yarn.lock
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 { PidConfigType, config as pidConfigDef } from './pid_config';
|
||||
import { resolveInstanceUuid } from './resolve_uuid';
|
||||
|
|
|
@ -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', () => ({
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 } 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 {
|
||||
ILegacyInternals,
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
import { map, shareReplay } from 'rxjs/operators';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { PathConfigType, config as pathConfig } from '@kbn/utils';
|
||||
import { pick, deepFreeze } from '@kbn/std';
|
||||
|
||||
import { CoreContext } from '../core_context';
|
||||
import { PluginWrapper } from './plugin';
|
||||
import { PluginsServiceSetupDeps, PluginsServiceStartDeps } from './plugins_service';
|
||||
|
@ -30,7 +30,6 @@ import {
|
|||
PluginOpaqueId,
|
||||
SharedGlobalConfigKeys,
|
||||
} from './types';
|
||||
import { PathConfigType, config as pathConfig } from '../path';
|
||||
import { KibanaConfigType, config as kibanaConfig } from '../kibana_config';
|
||||
import {
|
||||
ElasticsearchConfigType,
|
||||
|
|
|
@ -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 '..';
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,6 +106,7 @@ import { NodesInfoParams } from 'elasticsearch';
|
|||
import { NodesStatsParams } from 'elasticsearch';
|
||||
import { ObjectType } from '@kbn/config-schema';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PathConfigType } from '@kbn/utils';
|
||||
import { PeerCertificate } from 'tls';
|
||||
import { PingParams } from 'elasticsearch';
|
||||
import { PutScriptParams } from 'elasticsearch';
|
||||
|
@ -2843,6 +2844,5 @@ export const validBodyOutput: readonly ["data", "stream"];
|
|||
// src/core/server/legacy/types.ts:135: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
|
||||
|
||||
```
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { config as pathConfig } from '@kbn/utils';
|
||||
import { mapToObject } from '@kbn/std';
|
||||
import { ConfigService, Env, RawConfigurationProvider, coreDeprecationProvider } from './config';
|
||||
import { CoreApp } from './core_app';
|
||||
|
@ -40,7 +41,6 @@ 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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }) => {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 = [];
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 }) => {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -37,7 +37,7 @@ import { Executor } from 'selenium-webdriver/lib/http';
|
|||
import { getLogger } from 'selenium-webdriver/lib/logging';
|
||||
import { installDriver } from 'ms-chromium-edge-driver';
|
||||
|
||||
import { REPO_ROOT } from '@kbn/dev-utils';
|
||||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import { pollForLogEntry$ } from './poll_for_log_entry';
|
||||
import { createStdoutSocket } from './create_stdout_stream';
|
||||
import { preventParallelCalls } from './prevent_parallel_calls';
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
import fs from 'fs';
|
||||
import { when } from 'jest-when';
|
||||
import { SHAREABLE_RUNTIME_FILE } from '../../../shareable_runtime/constants';
|
||||
|
||||
import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
|
||||
import { httpServerMock } from 'src/core/server/mocks';
|
||||
import { initializeDownloadShareableWorkpadRoute } from './download';
|
||||
|
@ -14,7 +15,6 @@ import { getMockedRouterDeps } from '../test_helpers';
|
|||
|
||||
const mockRouteContext = {} as RequestHandlerContext;
|
||||
const path = `api/canvas/workpad/find`;
|
||||
const mockRuntime = 'Canvas shareable runtime';
|
||||
|
||||
describe('Download Canvas shareables runtime', () => {
|
||||
let routeHandler: RequestHandler<any, any, any>;
|
||||
|
@ -31,17 +31,18 @@ describe('Download Canvas shareables runtime', () => {
|
|||
});
|
||||
|
||||
it(`returns 200 with canvas shareables runtime`, async () => {
|
||||
const content = 'Canvas shareable runtime';
|
||||
const spy = jest.spyOn(fs, 'readFileSync').mockImplementation();
|
||||
when(spy).calledWith(SHAREABLE_RUNTIME_FILE).mockReturnValue(content);
|
||||
|
||||
const request = httpServerMock.createKibanaRequest({
|
||||
method: 'get',
|
||||
path,
|
||||
});
|
||||
|
||||
const readFileSyncMock = fs.readFileSync as jest.Mock;
|
||||
readFileSyncMock.mockReturnValueOnce(mockRuntime);
|
||||
|
||||
const response = await routeHandler(mockRouteContext, request, kibanaResponseFactory);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.payload).toMatchInlineSnapshot(`"Canvas shareable runtime"`);
|
||||
expect(response.payload).toMatchInlineSnapshot(`"${content}"`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,14 +3,22 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { createConfig, configSchema } from './config';
|
||||
jest.mock('fs', () => {
|
||||
const original = jest.requireActual('fs');
|
||||
|
||||
return {
|
||||
...original,
|
||||
readFileSync: jest.fn().mockImplementation((path: string) => `contents-of-${path}`),
|
||||
};
|
||||
import fs from 'fs';
|
||||
import { when } from 'jest-when';
|
||||
|
||||
import { createConfig, configSchema } from './config';
|
||||
|
||||
const MOCKED_PATHS = [
|
||||
'/proc/self/cgroup',
|
||||
'packages/kbn-dev-utils/certs/ca.crt',
|
||||
'packages/kbn-dev-utils/certs/elasticsearch.crt',
|
||||
'packages/kbn-dev-utils/certs/elasticsearch.key',
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
const spy = jest.spyOn(fs, 'readFileSync').mockImplementation();
|
||||
MOCKED_PATHS.forEach((file) => when(spy).calledWith(file).mockReturnValue(`contents-of-${file}`));
|
||||
});
|
||||
|
||||
describe('config schema', () => {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue