Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
|
@ -18,15 +18,12 @@ target
|
|||
|
||||
# plugin overrides
|
||||
/src/core/lib/kbn_internal_native_observable
|
||||
/src/legacy/core_plugins/console/public/tests/webpackShims
|
||||
/src/legacy/core_plugins/console/public/webpackShims
|
||||
/src/legacy/plugin_discovery/plugin_pack/__tests__/fixtures/plugins/broken
|
||||
/src/legacy/ui/public/flot-charts
|
||||
/src/legacy/ui/public/utils/decode_geo_hash.js
|
||||
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
|
||||
/src/plugins/vis_type_timelion/public/_generated_/**
|
||||
/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.*
|
||||
/src/plugins/timelion/public/webpackShims/jquery.flot.*
|
||||
/src/plugins/vis_type_timelion/public/flot/jquery.flot.*
|
||||
/src/plugins/timelion/public/flot/jquery.flot.*
|
||||
/x-pack/legacy/plugins/**/__tests__/fixtures/**
|
||||
/x-pack/plugins/apm/e2e/**/snapshots.js
|
||||
/x-pack/plugins/apm/e2e/tmp/*
|
||||
|
|
|
@ -404,7 +404,7 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
target: ['(src|x-pack)/plugins/*/public/**/*'],
|
||||
from: ['ui/**/*', 'uiExports/**/*'],
|
||||
from: ['ui/**/*'],
|
||||
errorMessage: 'Plugins cannot import legacy UI code.',
|
||||
},
|
||||
{
|
||||
|
@ -461,14 +461,13 @@ module.exports = {
|
|||
{
|
||||
files: [
|
||||
'**/public/**/*.js',
|
||||
'**/webpackShims/**/*.js',
|
||||
'packages/kbn-ui-framework/doc_site/src/**/*.js',
|
||||
'src/fixtures/**/*.js', // TODO: this directory needs to be more obviously "public" (or go away)
|
||||
],
|
||||
settings: {
|
||||
// instructs import/no-extraneous-dependencies to treat certain modules
|
||||
// as core modules, even if they aren't listed in package.json
|
||||
'import/core-modules': ['plugins', 'legacy/ui', 'uiExports'],
|
||||
'import/core-modules': ['plugins', 'legacy/ui'],
|
||||
|
||||
'import/resolver': {
|
||||
'@kbn/eslint-import-resolver-kibana': {
|
||||
|
@ -609,7 +608,6 @@ module.exports = {
|
|||
{
|
||||
files: [
|
||||
'.eslintrc.js',
|
||||
'**/webpackShims/**/*.js',
|
||||
'packages/kbn-plugin-generator/**/*.js',
|
||||
'packages/kbn-eslint-import-resolver-kibana/**/*.js',
|
||||
'packages/kbn-eslint-plugin-eslint/**/*',
|
||||
|
|
|
@ -32,7 +32,6 @@ out an open PR:
|
|||
|
||||
- [CONTRIBUTING.md](CONTRIBUTING.md) will help you get Kibana up and running.
|
||||
- If you would like to contribute code, please follow our [STYLEGUIDE.md](STYLEGUIDE.md).
|
||||
- Learn more about our UI code with [UI_SYSTEMS.md](src/legacy/ui/public/UI_SYSTEMS.md).
|
||||
- For all other questions, check out the [FAQ.md](FAQ.md) and
|
||||
[wiki](https://github.com/elastic/kibana/wiki).
|
||||
|
||||
|
|
|
@ -593,7 +593,7 @@ Do not use setters, they cause more problems than they can solve.
|
|||
|
||||
When writing a new component, create a sibling SASS file of the same name and import directly into the **top** of the JS/TS component file. Doing so ensures the styles are never separated or lost on import and allows for better modularization (smaller individual plugin asset footprint).
|
||||
|
||||
All SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`globals_[theme].scss` file](src/legacy/ui/public/styles/_globals_v7light.scss).
|
||||
All SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`globals_[theme].scss` file](src/core/public/core_app/styles/_globals_v7light.scss).
|
||||
|
||||
While the styles for this component will only be loaded if the component exists on the page,
|
||||
the styles **will** be global and so it is recommended to use a three letter prefix on your
|
||||
|
|
|
@ -214,12 +214,6 @@ locations for a Debian-based system:
|
|||
| /var/log/kibana
|
||||
| path.logs
|
||||
|
||||
| optimize
|
||||
| Transpiled source code. Certain administrative actions (e.g. plugin install)
|
||||
result in the source code being retranspiled on the fly.
|
||||
| /usr/share/kibana/optimize
|
||||
d|
|
||||
|
||||
| plugins
|
||||
| Plugin files location. Each plugin will be contained in a subdirectory.
|
||||
| /usr/share/kibana/plugins
|
||||
|
|
|
@ -206,12 +206,6 @@ locations for an RPM-based system:
|
|||
| /var/log/kibana
|
||||
| path.logs
|
||||
|
||||
| optimize
|
||||
| Transpiled source code. Certain administrative actions (e.g. plugin install)
|
||||
result in the source code being retranspiled on the fly.
|
||||
| /usr/share/kibana/optimize
|
||||
d|
|
||||
|
||||
| plugins
|
||||
| Plugin files location. Each plugin will be contained in a subdirectory.
|
||||
| /usr/share/kibana/plugins
|
||||
|
|
|
@ -149,12 +149,6 @@ important data later on.
|
|||
| $KIBANA_HOME\data
|
||||
d|
|
||||
|
||||
| optimize
|
||||
| Transpiled source code. Certain administrative actions (e.g. plugin install)
|
||||
result in the source code being retranspiled on the fly.
|
||||
| $KIBANA_HOME\optimize
|
||||
d|
|
||||
|
||||
| plugins
|
||||
| Plugin files location. Each plugin will be contained in a subdirectory.
|
||||
| $KIBANA_HOME\plugins
|
||||
|
|
|
@ -96,12 +96,6 @@ important data later on.
|
|||
| $KIBANA_HOME\data
|
||||
d|
|
||||
|
||||
| optimize
|
||||
| Transpiled source code. Certain administrative actions (e.g. plugin install)
|
||||
result in the source code being retranspiled on the fly.
|
||||
| $KIBANA_HOME\optimize
|
||||
d|
|
||||
|
||||
| plugins
|
||||
| Plugin files location. Each plugin will be contained in a subdirectory.
|
||||
| $KIBANA_HOME\plugins
|
||||
|
|
23
package.json
|
@ -115,7 +115,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.11.1",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
|
||||
"@babel/register": "^7.10.5",
|
||||
"@elastic/apm-rum": "^5.4.0",
|
||||
"@elastic/charts": "19.8.1",
|
||||
|
@ -151,12 +150,9 @@
|
|||
"angular-route": "^1.8.0",
|
||||
"angular-sanitize": "^1.8.0",
|
||||
"angular-sortable-view": "^0.0.17",
|
||||
"autoprefixer": "^9.7.4",
|
||||
"babel-loader": "^8.0.6",
|
||||
"bluebird": "3.5.5",
|
||||
"boom": "^7.2.0",
|
||||
"brace": "0.11.1",
|
||||
"cache-loader": "^4.1.0",
|
||||
"chalk": "^2.4.2",
|
||||
"check-disk-space": "^2.1.0",
|
||||
"chokidar": "3.2.1",
|
||||
|
@ -164,7 +160,6 @@
|
|||
"commander": "3.0.2",
|
||||
"compare-versions": "3.5.1",
|
||||
"core-js": "^3.6.4",
|
||||
"css-loader": "^3.4.2",
|
||||
"d3": "3.5.17",
|
||||
"d3-cloud": "1.2.5",
|
||||
"deep-freeze-strict": "^1.1.1",
|
||||
|
@ -176,7 +171,6 @@
|
|||
"execa": "^4.0.2",
|
||||
"expiry-js": "0.1.7",
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
"file-loader": "4.2.0",
|
||||
"font-awesome": "4.7.0",
|
||||
"fp-ts": "^2.3.1",
|
||||
"getos": "^3.1.0",
|
||||
|
@ -208,11 +202,9 @@
|
|||
"leaflet-vega": "^0.8.6",
|
||||
"leaflet.heat": "0.2.0",
|
||||
"less": "npm:@elastic/less@2.7.3-kibana",
|
||||
"less-loader": "5.0.0",
|
||||
"lodash": "^4.17.15",
|
||||
"lru-cache": "4.1.5",
|
||||
"markdown-it": "^10.0.0",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"moment": "^2.24.0",
|
||||
"moment-timezone": "^0.5.27",
|
||||
|
@ -224,12 +216,9 @@
|
|||
"opn": "^5.5.0",
|
||||
"oppsy": "^2.0.0",
|
||||
"pegjs": "0.10.0",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"prop-types": "15.6.0",
|
||||
"proxy-from-env": "1.0.0",
|
||||
"pug": "^2.0.4",
|
||||
"query-string": "5.1.1",
|
||||
"raw-loader": "3.1.0",
|
||||
"re2": "^1.15.4",
|
||||
"react": "^16.12.0",
|
||||
"react-color": "^2.13.8",
|
||||
|
@ -255,30 +244,22 @@
|
|||
"resize-observer-polyfill": "^1.5.0",
|
||||
"rison-node": "1.0.2",
|
||||
"rxjs": "^6.5.5",
|
||||
"script-loader": "0.7.2",
|
||||
"seedrandom": "^3.0.5",
|
||||
"semver": "^5.5.0",
|
||||
"style-loader": "^1.1.3",
|
||||
"symbol-observable": "^1.2.0",
|
||||
"tar": "4.4.13",
|
||||
"terser-webpack-plugin": "^2.3.4",
|
||||
"thread-loader": "^2.1.3",
|
||||
"tinygradient": "0.4.3",
|
||||
"tinymath": "1.2.1",
|
||||
"topojson-client": "3.0.0",
|
||||
"tslib": "^2.0.0",
|
||||
"type-detect": "^4.0.8",
|
||||
"ui-select": "0.19.8",
|
||||
"url-loader": "2.2.0",
|
||||
"uuid": "3.3.2",
|
||||
"val-loader": "^1.1.1",
|
||||
"vega": "^5.13.0",
|
||||
"vega-lite": "^4.13.1",
|
||||
"vega-schema-url-parser": "^1.1.0",
|
||||
"vega-tooltip": "^0.12.0",
|
||||
"vision": "^5.3.3",
|
||||
"webpack": "^4.41.5",
|
||||
"webpack-merge": "4.2.2",
|
||||
"whatwg-fetch": "^3.0.0",
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
|
@ -445,8 +426,6 @@
|
|||
"has-ansi": "^3.0.0",
|
||||
"iedriver": "^3.14.2",
|
||||
"intl-messageformat-parser": "^1.4.0",
|
||||
"is-path-inside": "^2.1.0",
|
||||
"istanbul-instrumenter-loader": "3.0.1",
|
||||
"jest": "^25.5.4",
|
||||
"jest-canvas-mock": "^2.2.0",
|
||||
"jest-circus": "^25.5.4",
|
||||
|
@ -467,14 +446,12 @@
|
|||
"murmurhash3js": "3.0.1",
|
||||
"mutation-observer": "^1.0.3",
|
||||
"nock": "12.0.3",
|
||||
"node-sass": "^4.13.1",
|
||||
"normalize-path": "^3.0.0",
|
||||
"nyc": "^14.1.1",
|
||||
"pixelmatch": "^5.1.0",
|
||||
"pkg-up": "^2.0.0",
|
||||
"pngjs": "^3.4.0",
|
||||
"postcss": "^7.0.32",
|
||||
"postcss-url": "^8.0.0",
|
||||
"prettier": "^2.0.5",
|
||||
"proxyquire": "1.8.0",
|
||||
"react-popper-tooltip": "^2.10.1",
|
||||
|
|
|
@ -29,6 +29,6 @@
|
|||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
"eslint-plugin-react": "^7.17.0",
|
||||
"eslint-plugin-react-hooks": "^2.3.0"
|
||||
"eslint-plugin-react-hooks": "^4.0.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
"babel-plugin-filter-imports": "^3.0.0",
|
||||
"babel-plugin-styled-components": "^1.10.7",
|
||||
"babel-plugin-transform-define": "^1.3.1",
|
||||
"babel-plugin-transform-imports": "^2.0.0"
|
||||
"babel-plugin-transform-imports": "^2.0.0",
|
||||
"react-is": "^16.8.0",
|
||||
"styled-components": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ const {
|
|||
getProjectRoot,
|
||||
getWebpackConfig,
|
||||
isFile,
|
||||
isProbablyWebpackShim,
|
||||
getIsPathRequest,
|
||||
resolveWebpackAlias,
|
||||
} = require('./lib');
|
||||
|
@ -73,15 +72,6 @@ exports.resolve = function resolveKibanaPath(importRequest, file, config) {
|
|||
return tryNodeResolver(importRequest, file, config);
|
||||
}
|
||||
|
||||
// these modules are simulated by webpack, so there is no
|
||||
// path to resolve to and no reason to do any more work
|
||||
if (importRequest.startsWith('uiExports/')) {
|
||||
return {
|
||||
found: true,
|
||||
path: null,
|
||||
};
|
||||
}
|
||||
|
||||
const { webpackConfig, aliasEntries } = initContext(file, config);
|
||||
let isPathRequest = getIsPathRequest(importRequest);
|
||||
|
||||
|
@ -110,16 +100,9 @@ exports.resolve = function resolveKibanaPath(importRequest, file, config) {
|
|||
}
|
||||
}
|
||||
|
||||
// only use the node resolver if the importRequest is a path, or is
|
||||
// a module request but not one that's probably a webpackShim. This
|
||||
// prevents false positives as webpackShims are likely to be resolved
|
||||
// to the node_modules directory by the node resolver, but we want
|
||||
// them to resolve to the actual shim
|
||||
if (isPathRequest || !isProbablyWebpackShim(importRequest, file)) {
|
||||
const nodeResult = tryNodeResolver(importRequest, file, config);
|
||||
if (nodeResult && nodeResult.found) {
|
||||
return nodeResult;
|
||||
}
|
||||
const nodeResult = tryNodeResolver(importRequest, file, config);
|
||||
if (nodeResult && nodeResult.found) {
|
||||
return nodeResult;
|
||||
}
|
||||
|
||||
return webpackResolver.resolve(importRequest, file, {
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const { dirname, resolve } = require('path');
|
||||
|
||||
const glob = require('glob-all');
|
||||
|
||||
exports.getPlugins = function (config, kibanaPath, projectRoot) {
|
||||
const resolveToRoot = (path) => resolve(projectRoot, path);
|
||||
|
||||
const pluginDirs = [
|
||||
...(config.pluginDirs || []).map(resolveToRoot),
|
||||
resolve(kibanaPath, 'plugins'),
|
||||
resolve(kibanaPath, 'src/legacy/core_plugins'),
|
||||
];
|
||||
|
||||
const pluginPaths = [
|
||||
...(config.pluginPaths || []).map(resolveToRoot),
|
||||
|
||||
// when the rootPackageName is specified we assume that the root of the project
|
||||
// is not a plugin, so don't include it automatically
|
||||
...(config.rootPackageName ? [] : [projectRoot]),
|
||||
];
|
||||
|
||||
const globPatterns = [
|
||||
...pluginDirs.map((dir) => resolve(dir, '*/package.json')),
|
||||
...pluginPaths.map((path) => resolve(path, 'package.json')),
|
||||
];
|
||||
|
||||
const pluginsFromMap = Object.keys(config.pluginMap || {}).map((name) => {
|
||||
const directory = resolveToRoot(config.pluginMap[name]);
|
||||
return {
|
||||
name,
|
||||
directory,
|
||||
publicDirectory: resolve(directory, 'public'),
|
||||
};
|
||||
});
|
||||
|
||||
return pluginsFromMap.concat(
|
||||
glob.sync(globPatterns).map((pkgJsonPath) => {
|
||||
const path = dirname(pkgJsonPath);
|
||||
const pkg = require(pkgJsonPath); // eslint-disable-line import/no-dynamic-require
|
||||
return {
|
||||
name: pkg.name,
|
||||
directory: path,
|
||||
publicDirectory: resolve(path, 'public'),
|
||||
};
|
||||
})
|
||||
);
|
||||
};
|
|
@ -19,40 +19,22 @@
|
|||
|
||||
const { resolve } = require('path');
|
||||
|
||||
const { debug } = require('./debug');
|
||||
const { getPlugins } = require('./get_plugins');
|
||||
|
||||
exports.getWebpackConfig = function (kibanaPath, projectRoot, config) {
|
||||
const fromKibana = (...path) => resolve(kibanaPath, ...path);
|
||||
|
||||
const alias = {
|
||||
// Kibana defaults https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/legacy/ui/ui_bundler_env.js#L30-L36
|
||||
ui: fromKibana('src/legacy/ui/public'),
|
||||
|
||||
// Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78
|
||||
ng_mock$: fromKibana('src/test_utils/public/ng_mock'),
|
||||
fixtures: fromKibana('src/fixtures'),
|
||||
test_utils: fromKibana('src/test_utils/public'),
|
||||
};
|
||||
|
||||
getPlugins(config, kibanaPath, projectRoot).forEach((plugin) => {
|
||||
alias[`plugins/${plugin.name}`] = plugin.publicDirectory;
|
||||
});
|
||||
|
||||
debug('Webpack resolved aliases', alias);
|
||||
|
||||
exports.getWebpackConfig = function (kibanaPath) {
|
||||
return {
|
||||
context: kibanaPath,
|
||||
resolve: {
|
||||
extensions: ['.js', '.json', '.ts', '.tsx'],
|
||||
mainFields: ['browser', 'main'],
|
||||
modules: [
|
||||
'webpackShims',
|
||||
'node_modules',
|
||||
fromKibana('webpackShims'),
|
||||
fromKibana('node_modules'),
|
||||
],
|
||||
alias,
|
||||
modules: ['node_modules', resolve(kibanaPath, 'node_modules')],
|
||||
alias: {
|
||||
// Kibana defaults https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/legacy/ui/ui_bundler_env.js#L30-L36
|
||||
ui: resolve(kibanaPath, 'src/legacy/ui/public'),
|
||||
|
||||
// Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78
|
||||
ng_mock$: resolve(kibanaPath, 'src/test_utils/public/ng_mock'),
|
||||
fixtures: resolve(kibanaPath, 'src/fixtures'),
|
||||
test_utils: resolve(kibanaPath, 'src/test_utils/public'),
|
||||
},
|
||||
unsafeCache: true,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -23,7 +23,6 @@ module.exports = Object.assign(
|
|||
require('./get_project_root'),
|
||||
require('./get_webpack_config'),
|
||||
require('./get_path_type'),
|
||||
require('./is_probably_webpack_shim'),
|
||||
require('./get_is_path_request'),
|
||||
require('./resolve_webpack_alias')
|
||||
);
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const { readdirSync } = require('fs');
|
||||
const { join, dirname } = require('path');
|
||||
|
||||
const LRU = require('lru-cache');
|
||||
|
||||
const { isDirectory } = require('./get_path_type');
|
||||
|
||||
const cache = process.env.KIBANA_RESOLVER_HARD_CACHE ? new Map() : new LRU({ max: 1000 });
|
||||
|
||||
function readShimNames(shimDirectory) {
|
||||
if (!isDirectory(shimDirectory)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return readdirSync(shimDirectory)
|
||||
.filter((name) => !name.startsWith('.') && !name.startsWith('_'))
|
||||
.map((name) => (name.endsWith('.js') ? name.slice(0, -3) : name));
|
||||
}
|
||||
|
||||
function findRelativeWebpackShims(directory) {
|
||||
const cached = cache.get(directory);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const ownShims = readShimNames(join(directory, 'webpackShims'));
|
||||
|
||||
const parent = dirname(directory);
|
||||
const parentShims = parent !== directory ? findRelativeWebpackShims(parent) : [];
|
||||
|
||||
const allShims = !ownShims.length ? parentShims : ownShims.concat(parentShims);
|
||||
|
||||
cache.set(directory, allShims);
|
||||
return allShims;
|
||||
}
|
||||
|
||||
exports.isProbablyWebpackShim = function (source, file) {
|
||||
const shims = findRelativeWebpackShims(dirname(file));
|
||||
return shims.some((shim) => source === shim || source.startsWith(shim + '/'));
|
||||
};
|
|
@ -36,7 +36,6 @@
|
|||
"postcss": "^7.0.32",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"raw-loader": "^3.1.0",
|
||||
"resolve-url-loader": "^3.1.1",
|
||||
"rxjs": "^6.5.5",
|
||||
"sass-loader": "^8.0.2",
|
||||
"style-loader": "^1.1.3",
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
body {
|
||||
width: $globalStyleConstant;
|
||||
background-image: url("ui/icon.svg");
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" version="1.1"><circle cx="50" cy="50" r="25"/></svg>
|
Before Width: | Height: | Size: 117 B |
|
@ -154,7 +154,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
bar.cache.refresh();
|
||||
expect(bar.cache.getModuleCount()).toBe(
|
||||
// code + styles + style/css-loader runtimes + public path updater
|
||||
18
|
||||
16
|
||||
);
|
||||
|
||||
expect(bar.cache.getReferencedFiles()).toMatchInlineSnapshot(`
|
||||
|
@ -168,9 +168,8 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/legacy/_other_styles.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/legacy/styles.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/lib.ts,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/legacy/ui/public/icon.svg,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/legacy/ui/public/styles/_globals_v7dark.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/legacy/ui/public/styles/_globals_v7light.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v7dark.scss,
|
||||
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v7light.scss,
|
||||
<absolute path>/packages/kbn-optimizer/target/worker/entry_point_creator.js,
|
||||
<absolute path>/packages/kbn-ui-shared-deps/public_path_module_creator.js,
|
||||
]
|
||||
|
|
|
@ -29,7 +29,7 @@ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|||
import CompressionPlugin from 'compression-webpack-plugin';
|
||||
import * as UiSharedDeps from '@kbn/ui-shared-deps';
|
||||
|
||||
import { Bundle, BundleRefs, WorkerConfig, parseDirPath } from '../common';
|
||||
import { Bundle, BundleRefs, WorkerConfig } from '../common';
|
||||
import { BundleRefsPlugin } from './bundle_refs_plugin';
|
||||
|
||||
const BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset');
|
||||
|
@ -153,48 +153,15 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'resolve-url-loader',
|
||||
options: {
|
||||
join: (_: string, __: any) => (uri: string, base?: string) => {
|
||||
// apply only to legacy platform styles
|
||||
if (!base || !parseDirPath(base).dirs.includes('legacy')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (uri.startsWith('ui/assets')) {
|
||||
return Path.resolve(
|
||||
worker.repoRoot,
|
||||
'src/core/server/core_app/',
|
||||
uri.replace('ui/', '')
|
||||
);
|
||||
}
|
||||
|
||||
// manually force ui/* urls in legacy styles to resolve to ui/legacy/public
|
||||
if (uri.startsWith('ui/')) {
|
||||
return Path.resolve(
|
||||
worker.repoRoot,
|
||||
'src/legacy/ui/public',
|
||||
uri.replace('ui/', '')
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
// must always be enabled as long as we're using the `resolve-url-loader` to
|
||||
// rewrite `ui/*` urls. They're dropped by subsequent loaders though
|
||||
sourceMap: true,
|
||||
prependData(loaderContext: webpack.loader.LoaderContext) {
|
||||
return `@import ${stringifyRequest(
|
||||
loaderContext,
|
||||
Path.resolve(
|
||||
worker.repoRoot,
|
||||
`src/legacy/ui/public/styles/_globals_${theme}.scss`
|
||||
`src/core/public/core_app/styles/_globals_${theme}.scss`
|
||||
)
|
||||
)};\n`;
|
||||
},
|
||||
|
@ -250,6 +217,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
|
|||
mainFields: ['browser', 'main'],
|
||||
alias: {
|
||||
tinymath: require.resolve('tinymath/lib/tinymath.es5.js'),
|
||||
core_app_image_assets: Path.resolve(worker.repoRoot, 'src/core/public/core_app/images'),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
"gulp-zip": "5.0.1",
|
||||
"inquirer": "^1.2.2",
|
||||
"minimatch": "^3.0.4",
|
||||
"node-sass": "^4.13.1",
|
||||
"through2": "^2.0.3",
|
||||
"through2-map": "^3.0.0",
|
||||
"vinyl": "^2.2.0",
|
||||
|
@ -33,7 +32,6 @@
|
|||
"@types/gulp-rename": "^0.0.33",
|
||||
"@types/gulp-zip": "^4.0.1",
|
||||
"@types/inquirer": "^6.5.0",
|
||||
"@types/node-sass": "^4.11.0",
|
||||
"@types/through2": "^2.0.35",
|
||||
"@types/through2-map": "^3.0.0",
|
||||
"@types/vinyl": "^2.0.4",
|
||||
|
|
|
@ -43,7 +43,7 @@ export function pluginConfig(root: string = process.cwd()): PluginConfig {
|
|||
'tsconfig.json',
|
||||
'package.json',
|
||||
'index.{js,ts}',
|
||||
'{lib,public,server,webpackShims,translations}/**/*',
|
||||
'{lib,public,server,translations}/**/*',
|
||||
];
|
||||
|
||||
const kibanaExtraDir = resolve(root, '../../kibana');
|
||||
|
|
|
@ -22,7 +22,6 @@ import path from 'path';
|
|||
|
||||
import { readFileSync, writeFileSync, unlinkSync, existsSync } from 'fs';
|
||||
import execa from 'execa';
|
||||
import sass from 'node-sass';
|
||||
import del from 'del';
|
||||
import File from 'vinyl';
|
||||
import vfs from 'vinyl-fs';
|
||||
|
@ -135,22 +134,6 @@ export async function createBuild(
|
|||
});
|
||||
}
|
||||
|
||||
// compile stylesheet
|
||||
if (typeof plugin.styleSheetToCompile === 'string') {
|
||||
const file = path.resolve(plugin.root, plugin.styleSheetToCompile);
|
||||
if (!existsSync(file)) {
|
||||
throw new Error(`Path provided for styleSheetToCompile does not exist: ${file}`);
|
||||
}
|
||||
|
||||
const outputFileName = path.basename(file, path.extname(file)) + '.css';
|
||||
const output = path.join(buildRoot, path.dirname(plugin.styleSheetToCompile), outputFileName);
|
||||
|
||||
const rendered = sass.renderSync({ file, output });
|
||||
writeFileSync(output, rendered.css);
|
||||
|
||||
del.sync([path.join(buildRoot, '**', '*.s{a,c}ss')]);
|
||||
}
|
||||
|
||||
// transform typescript to js and clean out typescript
|
||||
const tsConfigPath = path.join(buildRoot, 'tsconfig.json');
|
||||
if (existsSync(tsConfigPath)) {
|
||||
|
|
|
@ -17,9 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
module.exports = (kibana) =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
module.exports = (kibana) => new kibana.Plugin({});
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
console.log('this is my hack');
|
|
@ -17,9 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
module.exports = (kibana) =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
module.exports = (kibana) => new kibana.Plugin({});
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
body {
|
||||
background-color: red;
|
||||
}
|
|
@ -17,9 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
module.exports = (kibana) =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
module.exports = (kibana) => new kibana.Plugin({});
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
console.log('this is my hack');
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { readdirSync, existsSync, unlinkSync } from 'fs';
|
||||
import { readdirSync } from 'fs';
|
||||
import del from 'del';
|
||||
import { createBuild } from '../create_build';
|
||||
import { pluginConfig } from '../../../lib';
|
||||
|
@ -84,28 +84,4 @@ describe('creating the build', () => {
|
|||
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET))).not.toContain('node_modules');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with styleSheetToCompile', () => {
|
||||
const sassPath = 'public/styles.scss';
|
||||
const cssPath = resolve(PLUGIN_BUILD_TARGET, 'public/styles.css');
|
||||
|
||||
beforeEach(() => {
|
||||
PLUGIN.skipInstallDependencies = true;
|
||||
PLUGIN.styleSheetToCompile = sassPath;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
PLUGIN.skipInstallDependencies = false;
|
||||
PLUGIN.styleSheetToCompile = undefined;
|
||||
unlinkSync(cssPath);
|
||||
});
|
||||
|
||||
it('produces CSS', async () => {
|
||||
expect(PLUGIN.styleSheetToCompile).toBe(sassPath);
|
||||
|
||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
|
||||
expect(existsSync(cssPath)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
5397
packages/kbn-pm/dist/index.js
vendored
|
@ -24,7 +24,7 @@ const { first } = require('rxjs/operators');
|
|||
const storybook = require('@storybook/react/standalone');
|
||||
const { run } = require('@kbn/dev-utils');
|
||||
const { generateStorybookEntry } = require('./lib/storybook_entry');
|
||||
const { REPO_ROOT, ASSET_DIR, CURRENT_CONFIG } = require('./lib/constants');
|
||||
const { ASSET_DIR, CURRENT_CONFIG } = require('./lib/constants');
|
||||
const { buildDll } = require('./lib/dll');
|
||||
|
||||
exports.runStorybookCli = (config) => {
|
||||
|
@ -45,14 +45,6 @@ exports.runStorybookCli = (config) => {
|
|||
procRunner,
|
||||
});
|
||||
|
||||
// Build sass and continue when initial build complete
|
||||
await procRunner.run('watch sass', {
|
||||
cmd: process.execPath,
|
||||
args: ['scripts/build_sass', '--watch'],
|
||||
cwd: REPO_ROOT,
|
||||
wait: /scss bundles created/,
|
||||
});
|
||||
|
||||
const subj = new Rx.ReplaySubject(1);
|
||||
generateStorybookEntry({ log, storyGlobs }).subscribe(subj);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const { REPO_ROOT, STORY_ENTRY_PATH } = require('./constants');
|
|||
const STORE_ENTRY_DIR = dirname(STORY_ENTRY_PATH);
|
||||
|
||||
exports.generateStorybookEntry = ({ log, storyGlobs }) => {
|
||||
const globs = ['built_assets/css/**/*.light.css', ...storyGlobs];
|
||||
const globs = [...storyGlobs];
|
||||
log.info('Storybook globs:\n', globs);
|
||||
const norm = (p) => normalize(relative(STORE_ENTRY_DIR, p));
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ module.exports = {
|
|||
'rxjs',
|
||||
'sinon',
|
||||
'tinycolor2',
|
||||
'./src/legacy/ui/public/styles/bootstrap/bootstrap_light.less',
|
||||
],
|
||||
plugins: [
|
||||
// Produce the DLL and its manifest
|
||||
|
@ -118,22 +117,6 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
{ loader: 'style-loader' },
|
||||
{ loader: 'css-loader', options: { importLoaders: 2 } },
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
config: {
|
||||
path: require.resolve('@kbn/optimizer/postcss.config.js'),
|
||||
},
|
||||
},
|
||||
},
|
||||
{ loader: 'less-loader' },
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(woff|woff2|ttf|eot|svg|ico)(\?|$)/,
|
||||
loader: 'file-loader',
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"@storybook/addon-storyshots": "^5.3.19",
|
||||
"@storybook/react": "^5.3.19",
|
||||
"@storybook/theming": "^5.3.19",
|
||||
"babel-loader": "^8.0.6",
|
||||
"copy-webpack-plugin": "^6.0.2",
|
||||
"fast-glob": "2.2.7",
|
||||
"glob-watcher": "5.0.3",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
const { parse, resolve } = require('path');
|
||||
const { resolve } = require('path');
|
||||
const webpack = require('webpack');
|
||||
const webpackMerge = require('webpack-merge');
|
||||
const { stringifyRequest } = require('loader-utils');
|
||||
|
@ -73,34 +73,13 @@ module.exports = async ({ config: storybookConfig }) => {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'resolve-url-loader',
|
||||
options: {
|
||||
// If you don't have arguments (_, __) to the join function, the
|
||||
// resolve-url-loader fails with a loader misconfiguration error.
|
||||
//
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
join: (_, __) => (uri, base) => {
|
||||
if (!base || !parse(base).dir.includes('legacy')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// URIs on mixins in src/legacy/public/styles need to be resolved.
|
||||
if (uri.startsWith('ui/assets')) {
|
||||
return resolve(REPO_ROOT, 'src/core/server/core_app/', uri.replace('ui/', ''));
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
prependData(loaderContext) {
|
||||
return `@import ${stringifyRequest(
|
||||
loaderContext,
|
||||
resolve(REPO_ROOT, 'src/legacy/ui/public/styles/_globals_v7light.scss')
|
||||
resolve(REPO_ROOT, 'src/core/public/core_app/styles/_globals_v7light.scss')
|
||||
)};\n`;
|
||||
},
|
||||
sassOptions: {
|
||||
|
@ -137,6 +116,9 @@ module.exports = async ({ config: storybookConfig }) => {
|
|||
resolve: {
|
||||
// Tell Webpack about the ts/x extensions
|
||||
extensions: ['.ts', '.tsx', '.scss'],
|
||||
alias: {
|
||||
core_app_image_assets: resolve(REPO_ROOT, 'src/core/public/core_app/images'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -32,4 +32,3 @@ export const KIBANA_FTR_SCRIPT = resolve(KIBANA_ROOT, 'scripts/functional_test_r
|
|||
export const PROJECT_ROOT = resolve(__dirname, '../../../../../../');
|
||||
export const FUNCTIONAL_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/functional/config');
|
||||
export const API_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/api_integration/config');
|
||||
export const OPTIMIZE_BUNDLE_DIR = resolve(KIBANA_ROOT, 'optimize/bundles');
|
||||
|
|
|
@ -31,7 +31,7 @@ export { runTestsCli, processRunTestsCliOptions, startServersCli, processStartSe
|
|||
export { runTests, startServers } from './functional_tests/tasks';
|
||||
|
||||
// @ts-ignore not typed yet
|
||||
export { OPTIMIZE_BUNDLE_DIR, KIBANA_ROOT } from './functional_tests/lib/paths';
|
||||
export { KIBANA_ROOT } from './functional_tests/lib/paths';
|
||||
|
||||
// @ts-ignore not typed yet
|
||||
export { esTestConfig, createLegacyEsTestCluster } from './legacy_es';
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/sass/run_build_sass_cli');
|
|
@ -21,20 +21,6 @@ import * as Rx from 'rxjs';
|
|||
|
||||
import { mockCluster } from './cluster_manager.test.mocks';
|
||||
|
||||
jest.mock('./run_kbn_optimizer', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires,no-shadow
|
||||
const Rx = require('rxjs');
|
||||
|
||||
return {
|
||||
runKbnOptimizer: () =>
|
||||
new Rx.BehaviorSubject({
|
||||
type: 'compiler success',
|
||||
durSec: 0,
|
||||
bundles: [],
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('readline', () => ({
|
||||
createInterface: jest.fn(() => ({
|
||||
on: jest.fn(),
|
||||
|
@ -43,18 +29,26 @@ jest.mock('readline', () => ({
|
|||
})),
|
||||
}));
|
||||
|
||||
const mockConfig: any = {
|
||||
get: (key: string) => {
|
||||
expect(key).toBe('optimize.enabled');
|
||||
return false;
|
||||
},
|
||||
};
|
||||
const mockConfig: any = {};
|
||||
|
||||
import { sample } from 'lodash';
|
||||
|
||||
import { ClusterManager } from './cluster_manager';
|
||||
import { ClusterManager, SomeCliArgs } from './cluster_manager';
|
||||
import { Worker } from './worker';
|
||||
|
||||
const CLI_ARGS: SomeCliArgs = {
|
||||
disableOptimizer: true,
|
||||
open: false,
|
||||
oss: false,
|
||||
quiet: false,
|
||||
repl: false,
|
||||
runExamples: false,
|
||||
silent: false,
|
||||
watch: false,
|
||||
cache: false,
|
||||
dist: false,
|
||||
};
|
||||
|
||||
describe('CLI cluster manager', () => {
|
||||
beforeEach(() => {
|
||||
mockCluster.fork.mockImplementation(() => {
|
||||
|
@ -75,17 +69,18 @@ describe('CLI cluster manager', () => {
|
|||
});
|
||||
|
||||
test('has two workers', () => {
|
||||
const manager = new ClusterManager({}, mockConfig);
|
||||
const manager = new ClusterManager(CLI_ARGS, mockConfig);
|
||||
|
||||
expect(manager.workers).toHaveLength(2);
|
||||
for (const worker of manager.workers) expect(worker).toBeInstanceOf(Worker);
|
||||
expect(manager.workers).toHaveLength(1);
|
||||
for (const worker of manager.workers) {
|
||||
expect(worker).toBeInstanceOf(Worker);
|
||||
}
|
||||
|
||||
expect(manager.optimizer).toBeInstanceOf(Worker);
|
||||
expect(manager.server).toBeInstanceOf(Worker);
|
||||
});
|
||||
|
||||
test('delivers broadcast messages to other workers', () => {
|
||||
const manager = new ClusterManager({}, mockConfig);
|
||||
const manager = new ClusterManager(CLI_ARGS, mockConfig);
|
||||
|
||||
for (const worker of manager.workers) {
|
||||
Worker.prototype.start.call(worker); // bypass the debounced start method
|
||||
|
@ -110,7 +105,7 @@ describe('CLI cluster manager', () => {
|
|||
test('correctly configures `BasePathProxy`.', async () => {
|
||||
const basePathProxyMock = { start: jest.fn() };
|
||||
|
||||
new ClusterManager({}, mockConfig, basePathProxyMock as any);
|
||||
new ClusterManager(CLI_ARGS, mockConfig, basePathProxyMock as any);
|
||||
|
||||
expect(basePathProxyMock.start).toHaveBeenCalledWith({
|
||||
shouldRedirectFromOldBasePath: expect.any(Function),
|
||||
|
@ -125,7 +120,7 @@ describe('CLI cluster manager', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
const basePathProxyMock = { start: jest.fn() };
|
||||
clusterManager = new ClusterManager({}, mockConfig, basePathProxyMock as any);
|
||||
clusterManager = new ClusterManager(CLI_ARGS, mockConfig, basePathProxyMock as any);
|
||||
[[{ delayUntil, shouldRedirectFromOldBasePath }]] = basePathProxyMock.start.mock.calls;
|
||||
});
|
||||
|
||||
|
@ -147,7 +142,6 @@ describe('CLI cluster manager', () => {
|
|||
describe('delayUntil()', () => {
|
||||
test('returns an observable which emits when the server and kbnOptimizer are ready and completes', async () => {
|
||||
clusterManager.serverReady$.next(false);
|
||||
clusterManager.optimizerReady$.next(false);
|
||||
clusterManager.kbnOptimizerReady$.next(false);
|
||||
|
||||
const events: Array<string | Error> = [];
|
||||
|
|
|
@ -27,6 +27,7 @@ import * as Rx from 'rxjs';
|
|||
import { startWith, mapTo, filter, map, take, tap } from 'rxjs/operators';
|
||||
|
||||
import { runKbnOptimizer } from './run_kbn_optimizer';
|
||||
import { CliArgs } from '../../core/server/config';
|
||||
import { LegacyConfig } from '../../core/server/legacy';
|
||||
import { BasePathProxyServer } from '../../core/server/http';
|
||||
|
||||
|
@ -35,6 +36,20 @@ import { Worker } from './worker';
|
|||
|
||||
process.env.kbnWorkerType = 'managr';
|
||||
|
||||
export type SomeCliArgs = Pick<
|
||||
CliArgs,
|
||||
| 'quiet'
|
||||
| 'silent'
|
||||
| 'repl'
|
||||
| 'disableOptimizer'
|
||||
| 'open'
|
||||
| 'watch'
|
||||
| 'oss'
|
||||
| 'runExamples'
|
||||
| 'cache'
|
||||
| 'dist'
|
||||
>;
|
||||
|
||||
const firstAllTrue = (...sources: Array<Rx.Observable<boolean>>) =>
|
||||
Rx.combineLatest(...sources).pipe(
|
||||
filter((values) => values.every((v) => v === true)),
|
||||
|
@ -43,7 +58,6 @@ const firstAllTrue = (...sources: Array<Rx.Observable<boolean>>) =>
|
|||
);
|
||||
|
||||
export class ClusterManager {
|
||||
public optimizer: Worker;
|
||||
public server: Worker;
|
||||
public workers: Worker[];
|
||||
|
||||
|
@ -56,45 +70,33 @@ export class ClusterManager {
|
|||
// exposed for testing
|
||||
public readonly serverReady$ = new Rx.ReplaySubject<boolean>(1);
|
||||
// exposed for testing
|
||||
public readonly optimizerReady$ = new Rx.ReplaySubject<boolean>(1);
|
||||
// exposed for testing
|
||||
public readonly kbnOptimizerReady$ = new Rx.ReplaySubject<boolean>(1);
|
||||
|
||||
constructor(
|
||||
opts: Record<string, any>,
|
||||
config: LegacyConfig,
|
||||
basePathProxy?: BasePathProxyServer
|
||||
) {
|
||||
constructor(opts: SomeCliArgs, config: LegacyConfig, basePathProxy?: BasePathProxyServer) {
|
||||
this.log = new Log(opts.quiet, opts.silent);
|
||||
this.inReplMode = !!opts.repl;
|
||||
this.basePathProxy = basePathProxy;
|
||||
|
||||
if (config.get('optimize.enabled') !== false) {
|
||||
// run @kbn/optimizer and write it's state to kbnOptimizerReady$
|
||||
// run @kbn/optimizer and write it's state to kbnOptimizerReady$
|
||||
if (opts.disableOptimizer) {
|
||||
this.kbnOptimizerReady$.next(true);
|
||||
} else {
|
||||
runKbnOptimizer(opts, config)
|
||||
.pipe(
|
||||
map(({ state }) => state.phase === 'success' || state.phase === 'issue'),
|
||||
tap({
|
||||
error: (error) => {
|
||||
this.log.bad('New platform optimizer error', error.stack);
|
||||
this.log.bad('@kbn/optimizer error', error.stack);
|
||||
process.exit(1);
|
||||
},
|
||||
})
|
||||
)
|
||||
.subscribe(this.kbnOptimizerReady$);
|
||||
} else {
|
||||
this.kbnOptimizerReady$.next(true);
|
||||
}
|
||||
|
||||
const serverArgv = [];
|
||||
const optimizerArgv = ['--plugins.initialize=false', '--server.autoListen=false'];
|
||||
|
||||
if (this.basePathProxy) {
|
||||
optimizerArgv.push(
|
||||
`--server.basePath=${this.basePathProxy.basePath}`,
|
||||
'--server.rewriteBasePath=true'
|
||||
);
|
||||
|
||||
serverArgv.push(
|
||||
`--server.port=${this.basePathProxy.targetPort}`,
|
||||
`--server.basePath=${this.basePathProxy.basePath}`,
|
||||
|
@ -103,13 +105,6 @@ export class ClusterManager {
|
|||
}
|
||||
|
||||
this.workers = [
|
||||
(this.optimizer = new Worker({
|
||||
type: 'optmzr',
|
||||
title: 'optimizer',
|
||||
log: this.log,
|
||||
argv: optimizerArgv,
|
||||
watch: false,
|
||||
})),
|
||||
(this.server = new Worker({
|
||||
type: 'server',
|
||||
log: this.log,
|
||||
|
@ -126,18 +121,6 @@ export class ClusterManager {
|
|||
.pipe(startWith(this.server.listening || this.server.crashed))
|
||||
.subscribe(this.serverReady$);
|
||||
|
||||
// write optimizer status to the optimizerReady$ subject
|
||||
Rx.merge(
|
||||
Rx.fromEvent(this.optimizer, 'optimizeStatus'),
|
||||
Rx.defer(() => {
|
||||
if (this.optimizer.fork) {
|
||||
this.optimizer.fork.send({ optimizeReady: '?' });
|
||||
}
|
||||
})
|
||||
)
|
||||
.pipe(map((msg: any) => msg && !!msg.success))
|
||||
.subscribe(this.optimizerReady$);
|
||||
|
||||
// broker messages between workers
|
||||
this.workers.forEach((worker) => {
|
||||
worker.on('broadcast', (msg) => {
|
||||
|
@ -224,7 +207,7 @@ export class ClusterManager {
|
|||
}
|
||||
|
||||
setupOpen(openUrl: string) {
|
||||
firstAllTrue(this.serverReady$, this.kbnOptimizerReady$, this.optimizerReady$)
|
||||
firstAllTrue(this.serverReady$, this.kbnOptimizerReady$)
|
||||
.toPromise()
|
||||
.then(() => {
|
||||
opn(openUrl);
|
||||
|
|
|
@ -28,9 +28,12 @@ import {
|
|||
} from '@kbn/dev-utils';
|
||||
import { runOptimizer, OptimizerConfig, logOptimizerState } from '@kbn/optimizer';
|
||||
|
||||
import { CliArgs } from '../../core/server/config';
|
||||
import { LegacyConfig } from '../../core/server/legacy';
|
||||
|
||||
export function runKbnOptimizer(opts: Record<string, any>, config: LegacyConfig) {
|
||||
type SomeCliArgs = Pick<CliArgs, 'watch' | 'cache' | 'dist' | 'oss' | 'runExamples'>;
|
||||
|
||||
export function runKbnOptimizer(opts: SomeCliArgs, config: LegacyConfig) {
|
||||
const optimizerConfig = OptimizerConfig.create({
|
||||
repoRoot: REPO_ROOT,
|
||||
watch: !!opts.watch,
|
||||
|
|
|
@ -77,7 +77,6 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
|
|||
|
||||
if (opts.dev) {
|
||||
set('env', 'development');
|
||||
set('optimize.watch', true);
|
||||
|
||||
if (!has('elasticsearch.username')) {
|
||||
set('elasticsearch.username', 'kibana_system');
|
||||
|
@ -194,7 +193,7 @@ export default function (program) {
|
|||
[]
|
||||
)
|
||||
.option('--plugins <path>', 'an alias for --plugin-dir', pluginDirCollector)
|
||||
.option('--optimize', 'Run the legacy plugin optimizer and then stop the server');
|
||||
.option('--optimize', 'Deprecated, running the optimizer is no longer required');
|
||||
|
||||
if (CAN_REPL) {
|
||||
command.option('--repl', 'Run the server with a REPL prompt and access to the server object');
|
||||
|
@ -220,6 +219,7 @@ export default function (program) {
|
|||
"Don't put a proxy in front of the dev server, which adds a random basePath"
|
||||
)
|
||||
.option('--no-watch', 'Prevents automatic restarts of the server in --dev mode')
|
||||
.option('--no-optimizer', 'Disable the kbn/optimizer completely')
|
||||
.option('--no-cache', 'Disable the kbn/optimizer cache')
|
||||
.option('--no-dev-config', 'Prevents loading the kibana.dev.yml file in --dev mode');
|
||||
}
|
||||
|
@ -255,6 +255,7 @@ export default function (program) {
|
|||
// elastic.co links.
|
||||
basePath: opts.runExamples ? false : !!opts.basePath,
|
||||
optimize: !!opts.optimize,
|
||||
disableOptimizer: !opts.optimizer,
|
||||
oss: !!opts.oss,
|
||||
cache: !!opts.cache,
|
||||
dist: !!opts.dist,
|
||||
|
|
|
@ -1321,7 +1321,6 @@ This table shows where these uiExports have moved to in the New Platform. In mos
|
|||
| `savedObjectTypes` | | Part of SavedObjects, see [#33587](https://github.com/elastic/kibana/issues/33587) |
|
||||
| `search` | | |
|
||||
| `shareContextMenuExtensions` | | |
|
||||
| `styleSheetPaths` | | |
|
||||
| `taskDefinitions` | | Should be an API on the taskManager plugin. |
|
||||
| `uiCapabilities` | [`core.application.register`](/docs/development/core/public/kibana-plugin-core-public.applicationsetup.register.md) | |
|
||||
| `uiSettingDefaults` | [`core.uiSettings.register`](/docs/development/core/server/kibana-plugin-core-server.uisettingsservicesetup.md) | |
|
||||
|
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
@ -1,7 +1,6 @@
|
|||
// v7dark global scope
|
||||
//
|
||||
// prepended to all .scss imports (from JS, when v7dark theme selected) and
|
||||
// legacy uiExports.styleSheetPaths when any dark theme is selected
|
||||
// prepended to all .scss imports (from JS, when v7dark theme selected)
|
||||
|
||||
@import '@elastic/eui/src/themes/eui/eui_colors_dark';
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
// v7light global scope
|
||||
//
|
||||
// prepended to all .scss imports (from JS, when v7light theme selected) and
|
||||
// legacy uiExports.styleSheetPaths when any dark theme is selected
|
||||
// prepended to all .scss imports (from JS, when v7light theme selected)
|
||||
|
||||
@import '@elastic/eui/src/themes/eui/eui_colors_light';
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
z-index: 1;
|
||||
width: 310px;
|
||||
height: 477px;
|
||||
content: url(lightOrDarkTheme('ui/assets/images/bg_top_branded.svg', 'ui/assets/images/bg_top_branded_dark.svg'));
|
||||
content: url(lightOrDarkTheme('~core_app_image_assets/bg_top_branded.svg', '~core_app_image_assets/bg_top_branded_dark.svg'));
|
||||
}
|
||||
|
||||
&::after {
|
||||
|
@ -99,7 +99,7 @@
|
|||
z-index: 1;
|
||||
width: 313px;
|
||||
height: 461px;
|
||||
content: url(lightOrDarkTheme('ui/assets/images/bg_bottom_branded.svg', 'ui/assets/images/bg_bottom_branded_dark.svg'));
|
||||
content: url(lightOrDarkTheme('~core_app_image_assets/bg_bottom_branded.svg', '~core_app_image_assets/bg_bottom_branded_dark.svg'));
|
||||
}
|
||||
|
||||
@keyframes kibanaFullScreenGraphics_FadeIn {
|
|
@ -55,6 +55,11 @@ export async function bootstrap({
|
|||
onRootShutdown('Kibana REPL mode can only be run in development mode.');
|
||||
}
|
||||
|
||||
if (cliArgs.optimize) {
|
||||
// --optimize is deprecated and does nothing now, avoid starting up and just shutdown
|
||||
return;
|
||||
}
|
||||
|
||||
const env = Env.createDefault({
|
||||
configs,
|
||||
cliArgs,
|
||||
|
@ -106,12 +111,6 @@ export async function bootstrap({
|
|||
} catch (err) {
|
||||
await shutdown(err);
|
||||
}
|
||||
|
||||
if (cliArgs.optimize) {
|
||||
const cliLogger = root.logger.get('cli');
|
||||
cliLogger.info('Optimization done.');
|
||||
await shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
function onRootShutdown(reason?: any) {
|
||||
|
|
|
@ -36,7 +36,9 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
|
|||
watch: false,
|
||||
repl: false,
|
||||
basePath: false,
|
||||
optimize: false,
|
||||
disableOptimizer: true,
|
||||
cache: true,
|
||||
dist: false,
|
||||
oss: false,
|
||||
runExamples: false,
|
||||
...(options.cliArgs || {}),
|
||||
|
|
|
@ -5,10 +5,12 @@ Env {
|
|||
"binDir": "/test/kibanaRoot/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": true,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"envName": "development",
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
@ -49,10 +51,12 @@ Env {
|
|||
"binDir": "/test/kibanaRoot/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": false,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"envName": "production",
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
@ -93,9 +97,11 @@ Env {
|
|||
"binDir": "/test/kibanaRoot/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": true,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
@ -136,9 +142,11 @@ Env {
|
|||
"binDir": "/test/kibanaRoot/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": false,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
@ -179,9 +187,11 @@ Env {
|
|||
"binDir": "/test/kibanaRoot/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": false,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
@ -222,9 +232,11 @@ Env {
|
|||
"binDir": "/some/home/dir/bin",
|
||||
"cliArgs": Object {
|
||||
"basePath": false,
|
||||
"cache": true,
|
||||
"dev": false,
|
||||
"disableOptimizer": true,
|
||||
"dist": false,
|
||||
"open": false,
|
||||
"optimize": false,
|
||||
"oss": false,
|
||||
"quiet": false,
|
||||
"repl": false,
|
||||
|
|
|
@ -120,11 +120,25 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
|
|||
unusedFromRoot('savedObjects.indexCheckTimeout'),
|
||||
unusedFromRoot('server.xsrf.token'),
|
||||
unusedFromRoot('maps.manifestServiceUrl'),
|
||||
renameFromRoot('optimize.lazy', 'optimize.watch'),
|
||||
renameFromRoot('optimize.lazyPort', 'optimize.watchPort'),
|
||||
renameFromRoot('optimize.lazyHost', 'optimize.watchHost'),
|
||||
renameFromRoot('optimize.lazyPrebuild', 'optimize.watchPrebuild'),
|
||||
renameFromRoot('optimize.lazyProxyTimeout', 'optimize.watchProxyTimeout'),
|
||||
unusedFromRoot('optimize.lazy'),
|
||||
unusedFromRoot('optimize.lazyPort'),
|
||||
unusedFromRoot('optimize.lazyHost'),
|
||||
unusedFromRoot('optimize.lazyPrebuild'),
|
||||
unusedFromRoot('optimize.lazyProxyTimeout'),
|
||||
unusedFromRoot('optimize.enabled'),
|
||||
unusedFromRoot('optimize.bundleFilter'),
|
||||
unusedFromRoot('optimize.bundleDir'),
|
||||
unusedFromRoot('optimize.viewCaching'),
|
||||
unusedFromRoot('optimize.watch'),
|
||||
unusedFromRoot('optimize.watchPort'),
|
||||
unusedFromRoot('optimize.watchHost'),
|
||||
unusedFromRoot('optimize.watchPrebuild'),
|
||||
unusedFromRoot('optimize.watchProxyTimeout'),
|
||||
unusedFromRoot('optimize.useBundleCache'),
|
||||
unusedFromRoot('optimize.sourceMaps'),
|
||||
unusedFromRoot('optimize.workers'),
|
||||
unusedFromRoot('optimize.profile'),
|
||||
unusedFromRoot('optimize.validateSyntaxOfNodeModules'),
|
||||
renameFromRoot('xpack.xpack_main.telemetry.config', 'telemetry.config'),
|
||||
renameFromRoot('xpack.xpack_main.telemetry.url', 'telemetry.url'),
|
||||
renameFromRoot('xpack.xpack_main.telemetry.enabled', 'telemetry.enabled'),
|
||||
|
|
|
@ -40,10 +40,14 @@ export interface CliArgs {
|
|||
watch: boolean;
|
||||
repl: boolean;
|
||||
basePath: boolean;
|
||||
optimize: boolean;
|
||||
open: boolean;
|
||||
oss: boolean;
|
||||
/** @deprecated use disableOptimizer to know if the @kbn/optimizer is disabled in development */
|
||||
optimize?: boolean;
|
||||
runExamples: boolean;
|
||||
disableOptimizer: boolean;
|
||||
cache: boolean;
|
||||
dist: boolean;
|
||||
}
|
||||
|
||||
export class Env {
|
||||
|
|
|
@ -24,6 +24,10 @@ import * as kbnTestServer from '../../../../test_utils/kbn_server';
|
|||
describe('configuration deprecations', () => {
|
||||
let root: ReturnType<typeof kbnTestServer.createRoot>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (root) {
|
||||
await root.shutdown();
|
||||
|
@ -36,13 +40,7 @@ describe('configuration deprecations', () => {
|
|||
await root.setup();
|
||||
|
||||
const logs = loggingSystemMock.collect(mockLoggingSystem);
|
||||
const warnings = logs.warn.flatMap((i) => i);
|
||||
expect(warnings).not.toContain(
|
||||
'"optimize.lazy" is deprecated and has been replaced by "optimize.watch"'
|
||||
);
|
||||
expect(warnings).not.toContain(
|
||||
'"optimize.lazyPort" is deprecated and has been replaced by "optimize.watchPort"'
|
||||
);
|
||||
expect(logs.warn.flat()).toMatchInlineSnapshot(`Array []`);
|
||||
});
|
||||
|
||||
it('should log deprecation warnings for core deprecations', async () => {
|
||||
|
@ -56,12 +54,11 @@ describe('configuration deprecations', () => {
|
|||
await root.setup();
|
||||
|
||||
const logs = loggingSystemMock.collect(mockLoggingSystem);
|
||||
const warnings = logs.warn.flatMap((i) => i);
|
||||
expect(warnings).toContain(
|
||||
'"optimize.lazy" is deprecated and has been replaced by "optimize.watch"'
|
||||
);
|
||||
expect(warnings).toContain(
|
||||
'"optimize.lazyPort" is deprecated and has been replaced by "optimize.watchPort"'
|
||||
);
|
||||
expect(logs.warn.flat()).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"optimize.lazy is deprecated and is no longer used",
|
||||
"optimize.lazyPort is deprecated and is no longer used",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,8 +6,3 @@ Kibana packages two fonts:
|
|||
* [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono) was pulled from the Google Fonts website on January 22, 2019.
|
||||
|
||||
Licenses for both can be found in the folders below this root.
|
||||
|
||||
|
||||
## How fonts are loaded
|
||||
|
||||
Reference the `src/legacy/ui/ui_render/views/chrome.pug` which makes the font-face CSS declarations against the files contained here. References to those those faces are called directly in [EUI](https://github.com/elastic/eui) primarily through the [typography variables](https://github.com/elastic/eui/blob/master/src/global_styling/variables/_typography.scss).
|
|
@ -1,9 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="147" height="51" viewBox="0 0 147 51">
|
||||
<g fill="#FFF" fill-rule="evenodd">
|
||||
<polygon points="0 0 0 46 40 0"/>
|
||||
<path d="M23.1487518,27 L3.71557862,49.0544767 L2,51 L39,51 C36.9701896,41.1410139 31.1632495,32.644207 23.1487518,27"/>
|
||||
<g transform="translate(55 13)">
|
||||
<path d="M4.3,23.99 L4.3,17.29 L6.4,17.09 L10.4,24.09 L14.5,24.09 L9.5,15.29 L14.3,7.59 L10.3,7.59 L6.4,13.99 L4.4,14.19 L4.4,0.59 L0.8,0.59 L0.8,23.99 L4.3,23.99 Z M17.3,23.99 L20.9,23.99 L20.9,7.49 L17.3,7.49 L17.3,23.99 Z M17.3,4.69 L20.9,4.69 L20.9,0.89 L17.3,0.89 L17.3,4.69 Z M33,7.19 C31.1,7.19 28.9,8.19 28.9,8.19 L28.9,0.69 L25.3,0.69 L25.3,24.09 C25.3,24.09 29.6,24.49 31.3,24.49 C37.2,24.49 39.4,22.49 39.4,15.59 C39.4,9.39 37.5,7.19 33,7.19 Z M31.3,21.19 C30.6,21.19 28.8,21.09 28.8,21.09 L28.8,11.09 C28.8,11.09 30.7,10.39 32.5,10.39 C34.7,10.39 35.7,11.89 35.7,15.59 C35.7,19.59 35,21.19 31.3,21.19 Z M55.2,12.59 C55.2,8.79 53.5,7.09 49.5,7.09 C46.5,7.09 42.9,7.99 42.9,7.99 L43,10.49 C43,10.49 47,10.19 49.2,10.19 C50.8,10.19 51.6,10.79 51.6,12.59 L51.6,13.79 L47.3,14.19 C43.8,14.49 41.8,15.69 41.8,19.19 C41.8,22.59 43.5,24.49 46.7,24.49 C49.4,24.49 52,23.29 52,23.29 C53.2,24.29 54.4,24.49 56.4,24.49 L56.5,21.79 C55.5,21.69 55.1,21.29 55,20.29 L55.2,12.59 Z M51.6,16.29 L51.6,20.69 C51.6,20.69 49.4,21.39 47.5,21.39 C46.1,21.39 45.5,20.49 45.5,18.99 C45.5,17.49 46.3,16.79 47.8,16.69 L51.6,16.29 Z M63.3,23.99 L63.3,11.19 C63.3,11.19 65.1,10.29 67,10.29 C69.5,10.29 69.9,11.89 69.9,15.19 L69.9,23.99 L73.5,23.99 L73.5,15.09 C73.5,9.69 72.4,7.09 67.8,7.09 C65.7,7.09 63.2,8.49 63.2,8.49 L63.2,7.49 L59.6,7.49 L59.6,23.99 L63.3,23.99 Z M89.9,12.59 C89.9,8.79 88.2,7.09 84.2,7.09 C81.2,7.09 77.6,7.99 77.6,7.99 L77.7,10.49 C77.7,10.49 81.7,10.19 83.9,10.19 C85.5,10.19 86.3,10.79 86.3,12.59 L86.3,13.79 L82,14.19 C78.5,14.49 76.5,15.69 76.5,19.19 C76.5,22.59 78.2,24.49 81.4,24.49 C84.1,24.49 86.7,23.29 86.7,23.29 C87.9,24.29 89.1,24.49 91.1,24.49 L91.2,21.79 C90.2,21.69 89.8,21.29 89.7,20.29 L89.9,12.59 Z M86.3,16.29 L86.3,20.69 C86.3,20.69 84.1,21.39 82.2,21.39 C80.8,21.39 80.2,20.49 80.2,18.99 C80.2,17.49 81,16.79 82.5,16.69 L86.3,16.29 Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.2 KiB |
4419
src/core/server/core_app/assets/legacy_dark_theme.css
Normal file
4419
src/core/server/core_app/assets/legacy_light_theme.css
Normal file
|
@ -273,277 +273,3 @@ Object {
|
|||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`RenderingService setup() render() renders "legacy" page 1`] = `
|
||||
Object {
|
||||
"anonymousStatusPage": false,
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNumber": Any<Number>,
|
||||
"csp": Object {
|
||||
"warnLegacyBrowsers": true,
|
||||
},
|
||||
"env": Object {
|
||||
"mode": Object {
|
||||
"dev": Any<Boolean>,
|
||||
"name": Any<String>,
|
||||
"prod": Any<Boolean>,
|
||||
},
|
||||
"packageInfo": Object {
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"dist": Any<Boolean>,
|
||||
"version": Any<String>,
|
||||
},
|
||||
},
|
||||
"i18n": Object {
|
||||
"translationsUrl": "/mock-server-basepath/translations/en.json",
|
||||
},
|
||||
"legacyMetadata": Object {
|
||||
"app": Object {},
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"bundleId": "app:legacy",
|
||||
"devMode": true,
|
||||
"nav": Array [],
|
||||
"serverName": "http-server-test",
|
||||
"uiSettings": Object {
|
||||
"defaults": Object {
|
||||
"registered": Object {
|
||||
"name": "title",
|
||||
},
|
||||
},
|
||||
"user": Object {},
|
||||
},
|
||||
"version": Any<String>,
|
||||
},
|
||||
"legacyMode": true,
|
||||
"serverBasePath": "/mock-server-basepath",
|
||||
"uiPlugins": Array [],
|
||||
"vars": Object {},
|
||||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`RenderingService setup() render() renders "legacy" page for blank basepath 1`] = `
|
||||
Object {
|
||||
"anonymousStatusPage": false,
|
||||
"basePath": "",
|
||||
"branch": Any<String>,
|
||||
"buildNumber": Any<Number>,
|
||||
"csp": Object {
|
||||
"warnLegacyBrowsers": true,
|
||||
},
|
||||
"env": Object {
|
||||
"mode": Object {
|
||||
"dev": Any<Boolean>,
|
||||
"name": Any<String>,
|
||||
"prod": Any<Boolean>,
|
||||
},
|
||||
"packageInfo": Object {
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"dist": Any<Boolean>,
|
||||
"version": Any<String>,
|
||||
},
|
||||
},
|
||||
"i18n": Object {
|
||||
"translationsUrl": "/translations/en.json",
|
||||
},
|
||||
"legacyMetadata": Object {
|
||||
"app": Object {},
|
||||
"basePath": "",
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"bundleId": "app:legacy",
|
||||
"devMode": true,
|
||||
"nav": Array [],
|
||||
"serverName": "http-server-test",
|
||||
"uiSettings": Object {
|
||||
"defaults": Object {
|
||||
"registered": Object {
|
||||
"name": "title",
|
||||
},
|
||||
},
|
||||
"user": Object {},
|
||||
},
|
||||
"version": Any<String>,
|
||||
},
|
||||
"legacyMode": true,
|
||||
"serverBasePath": "/mock-server-basepath",
|
||||
"uiPlugins": Array [],
|
||||
"vars": Object {},
|
||||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`RenderingService setup() render() renders "legacy" with custom vars 1`] = `
|
||||
Object {
|
||||
"anonymousStatusPage": false,
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNumber": Any<Number>,
|
||||
"csp": Object {
|
||||
"warnLegacyBrowsers": true,
|
||||
},
|
||||
"env": Object {
|
||||
"mode": Object {
|
||||
"dev": Any<Boolean>,
|
||||
"name": Any<String>,
|
||||
"prod": Any<Boolean>,
|
||||
},
|
||||
"packageInfo": Object {
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"dist": Any<Boolean>,
|
||||
"version": Any<String>,
|
||||
},
|
||||
},
|
||||
"i18n": Object {
|
||||
"translationsUrl": "/mock-server-basepath/translations/en.json",
|
||||
},
|
||||
"legacyMetadata": Object {
|
||||
"app": Object {},
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"bundleId": "app:legacy",
|
||||
"devMode": true,
|
||||
"nav": Array [],
|
||||
"serverName": "http-server-test",
|
||||
"uiSettings": Object {
|
||||
"defaults": Object {
|
||||
"registered": Object {
|
||||
"name": "title",
|
||||
},
|
||||
},
|
||||
"user": Object {},
|
||||
},
|
||||
"version": Any<String>,
|
||||
},
|
||||
"legacyMode": true,
|
||||
"serverBasePath": "/mock-server-basepath",
|
||||
"uiPlugins": Array [],
|
||||
"vars": Object {
|
||||
"fake": "__TEST_TOKEN__",
|
||||
},
|
||||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`RenderingService setup() render() renders "legacy" with excluded user settings 1`] = `
|
||||
Object {
|
||||
"anonymousStatusPage": false,
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNumber": Any<Number>,
|
||||
"csp": Object {
|
||||
"warnLegacyBrowsers": true,
|
||||
},
|
||||
"env": Object {
|
||||
"mode": Object {
|
||||
"dev": Any<Boolean>,
|
||||
"name": Any<String>,
|
||||
"prod": Any<Boolean>,
|
||||
},
|
||||
"packageInfo": Object {
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"dist": Any<Boolean>,
|
||||
"version": Any<String>,
|
||||
},
|
||||
},
|
||||
"i18n": Object {
|
||||
"translationsUrl": "/mock-server-basepath/translations/en.json",
|
||||
},
|
||||
"legacyMetadata": Object {
|
||||
"app": Object {},
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"bundleId": "app:legacy",
|
||||
"devMode": true,
|
||||
"nav": Array [],
|
||||
"serverName": "http-server-test",
|
||||
"uiSettings": Object {
|
||||
"defaults": Object {
|
||||
"registered": Object {
|
||||
"name": "title",
|
||||
},
|
||||
},
|
||||
"user": Object {},
|
||||
},
|
||||
"version": Any<String>,
|
||||
},
|
||||
"legacyMode": true,
|
||||
"serverBasePath": "/mock-server-basepath",
|
||||
"uiPlugins": Array [],
|
||||
"vars": Object {},
|
||||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`RenderingService setup() render() renders "legacy" with excluded user settings and custom vars 1`] = `
|
||||
Object {
|
||||
"anonymousStatusPage": false,
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNumber": Any<Number>,
|
||||
"csp": Object {
|
||||
"warnLegacyBrowsers": true,
|
||||
},
|
||||
"env": Object {
|
||||
"mode": Object {
|
||||
"dev": Any<Boolean>,
|
||||
"name": Any<String>,
|
||||
"prod": Any<Boolean>,
|
||||
},
|
||||
"packageInfo": Object {
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"dist": Any<Boolean>,
|
||||
"version": Any<String>,
|
||||
},
|
||||
},
|
||||
"i18n": Object {
|
||||
"translationsUrl": "/mock-server-basepath/translations/en.json",
|
||||
},
|
||||
"legacyMetadata": Object {
|
||||
"app": Object {},
|
||||
"basePath": "/mock-server-basepath",
|
||||
"branch": Any<String>,
|
||||
"buildNum": Any<Number>,
|
||||
"buildSha": Any<String>,
|
||||
"bundleId": "app:legacy",
|
||||
"devMode": true,
|
||||
"nav": Array [],
|
||||
"serverName": "http-server-test",
|
||||
"uiSettings": Object {
|
||||
"defaults": Object {
|
||||
"registered": Object {
|
||||
"name": "title",
|
||||
},
|
||||
},
|
||||
"user": Object {},
|
||||
},
|
||||
"version": Any<String>,
|
||||
},
|
||||
"legacyMode": true,
|
||||
"serverBasePath": "/mock-server-basepath",
|
||||
"uiPlugins": Array [],
|
||||
"vars": Object {
|
||||
"fake": "__TEST_TOKEN__",
|
||||
},
|
||||
"version": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -52,7 +52,6 @@ const INJECTED_METADATA = {
|
|||
};
|
||||
|
||||
const { createKibanaRequest, createRawRequest } = httpServerMock;
|
||||
const legacyApp = { getId: () => 'legacy' };
|
||||
|
||||
describe('RenderingService', () => {
|
||||
let service: RenderingService;
|
||||
|
@ -126,62 +125,6 @@ describe('RenderingService', () => {
|
|||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
|
||||
it('renders "legacy" page', async () => {
|
||||
const content = await render(createRawRequest(), uiSettings, { app: legacyApp });
|
||||
const dom = load(content);
|
||||
const data = JSON.parse(dom('kbn-injected-metadata').attr('data'));
|
||||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
|
||||
it('renders "legacy" page for blank basepath', async () => {
|
||||
mockRenderingSetupDeps.http.basePath.get.mockReturnValueOnce('');
|
||||
|
||||
const content = await render(createRawRequest(), uiSettings, { app: legacyApp });
|
||||
const dom = load(content);
|
||||
const data = JSON.parse(dom('kbn-injected-metadata').attr('data'));
|
||||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
|
||||
it('renders "legacy" with custom vars', async () => {
|
||||
const content = await render(createRawRequest(), uiSettings, {
|
||||
app: legacyApp,
|
||||
vars: {
|
||||
fake: '__TEST_TOKEN__',
|
||||
},
|
||||
});
|
||||
const dom = load(content);
|
||||
const data = JSON.parse(dom('kbn-injected-metadata').attr('data'));
|
||||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
|
||||
it('renders "legacy" with excluded user settings', async () => {
|
||||
const content = await render(createRawRequest(), uiSettings, {
|
||||
app: legacyApp,
|
||||
includeUserSettings: false,
|
||||
});
|
||||
const dom = load(content);
|
||||
const data = JSON.parse(dom('kbn-injected-metadata').attr('data'));
|
||||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
|
||||
it('renders "legacy" with excluded user settings and custom vars', async () => {
|
||||
const content = await render(createRawRequest(), uiSettings, {
|
||||
app: legacyApp,
|
||||
includeUserSettings: false,
|
||||
vars: {
|
||||
fake: '__TEST_TOKEN__',
|
||||
},
|
||||
});
|
||||
const dom = load(content);
|
||||
const data = JSON.parse(dom('kbn-injected-metadata').attr('data'));
|
||||
|
||||
expect(data).toMatchSnapshot(INJECTED_METADATA);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -69,7 +69,7 @@ export class RenderingService implements CoreService<InternalRenderingServiceSet
|
|||
const metadata: RenderingMetadata = {
|
||||
strictCsp: http.csp.strict,
|
||||
uiPublicUrl: `${basePath}/ui`,
|
||||
bootstrapScriptUrl: `${basePath}/bundles/app/${appId}/bootstrap.js`,
|
||||
bootstrapScriptUrl: `${basePath}/bootstrap.js`,
|
||||
i18n: i18n.translate,
|
||||
locale: i18n.getLocale(),
|
||||
darkMode: settings.user?.['theme:darkMode']?.userValue
|
||||
|
@ -82,7 +82,7 @@ export class RenderingService implements CoreService<InternalRenderingServiceSet
|
|||
basePath,
|
||||
serverBasePath,
|
||||
env,
|
||||
legacyMode: appId !== 'core',
|
||||
legacyMode: false,
|
||||
anonymousStatusPage: status.isStatusPageAnonymous(),
|
||||
i18n: {
|
||||
translationsUrl: `${basePath}/translations/${i18n.getLocale()}.json`,
|
||||
|
|
|
@ -98,43 +98,27 @@ describe('resolveInstanceUuid', () => {
|
|||
|
||||
describe('when file is present and config property is set', () => {
|
||||
describe('when they mismatch', () => {
|
||||
describe('when syncToFile is true', () => {
|
||||
it('writes to file and returns the config uuid', async () => {
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
DEFAULT_CONFIG_UUID,
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Updating Kibana instance UUID to: CONFIG_UUID (was: FILE_UUID)",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when syncTofile is false', () => {
|
||||
it('does not write to file and returns the config uuid', async () => {
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: false });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Updating Kibana instance UUID to: CONFIG_UUID (was: FILE_UUID)",
|
||||
]
|
||||
`);
|
||||
});
|
||||
it('writes to file and returns the config uuid', async () => {
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
DEFAULT_CONFIG_UUID,
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Updating Kibana instance UUID to: CONFIG_UUID (was: FILE_UUID)",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when they match', () => {
|
||||
it('does not write to file', async () => {
|
||||
mockReadFile({ uuid: DEFAULT_CONFIG_UUID });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
|
@ -148,45 +132,28 @@ describe('resolveInstanceUuid', () => {
|
|||
});
|
||||
|
||||
describe('when file is not present and config property is set', () => {
|
||||
describe('when syncToFile is true', () => {
|
||||
it('writes the uuid to file and returns the config uuid', async () => {
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
DEFAULT_CONFIG_UUID,
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: CONFIG_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when syncToFile is false', () => {
|
||||
it('does not write the uuid to file and returns the config uuid', async () => {
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: false });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: CONFIG_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
it('writes the uuid to file and returns the config uuid', async () => {
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
DEFAULT_CONFIG_UUID,
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: CONFIG_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when file is present and config property is not set', () => {
|
||||
it('does not write to file and returns the file uuid', async () => {
|
||||
configService = getConfigService(undefined);
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).toEqual(DEFAULT_FILE_UUID);
|
||||
expect(writeFile).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
|
@ -203,7 +170,7 @@ describe('resolveInstanceUuid', () => {
|
|||
it('writes new uuid to file and returns new uuid', async () => {
|
||||
mockReadFile({ uuid: UUID_7_6_0_BUG });
|
||||
configService = getConfigService(undefined);
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).not.toEqual(UUID_7_6_0_BUG);
|
||||
expect(uuid).toEqual('NEW_UUID');
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
|
@ -229,7 +196,7 @@ describe('resolveInstanceUuid', () => {
|
|||
it('writes config uuid to file and returns config uuid', async () => {
|
||||
mockReadFile({ uuid: UUID_7_6_0_BUG });
|
||||
configService = getConfigService(DEFAULT_CONFIG_UUID);
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).not.toEqual(UUID_7_6_0_BUG);
|
||||
expect(uuid).toEqual(DEFAULT_CONFIG_UUID);
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
|
@ -253,40 +220,22 @@ describe('resolveInstanceUuid', () => {
|
|||
});
|
||||
|
||||
describe('when file is not present and config property is not set', () => {
|
||||
describe('when syncToFile is true', () => {
|
||||
it('generates a new uuid and write it to file', async () => {
|
||||
configService = getConfigService(undefined);
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: true });
|
||||
expect(uuid).toEqual('NEW_UUID');
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
'NEW_UUID',
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: NEW_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when syncToFile is false', () => {
|
||||
it('generates a new uuid and does not write it to file', async () => {
|
||||
configService = getConfigService(undefined);
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger, syncToFile: false });
|
||||
expect(uuid).toEqual('NEW_UUID');
|
||||
expect(writeFile).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: NEW_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
it('generates a new uuid and write it to file', async () => {
|
||||
configService = getConfigService(undefined);
|
||||
mockReadFile({ error: fileNotFoundError });
|
||||
const uuid = await resolveInstanceUuid({ configService, logger });
|
||||
expect(uuid).toEqual('NEW_UUID');
|
||||
expect(writeFile).toHaveBeenCalledWith(
|
||||
join('data-folder', 'uuid'),
|
||||
'NEW_UUID',
|
||||
expect.any(Object)
|
||||
);
|
||||
expect(logger.debug).toHaveBeenCalledTimes(1);
|
||||
expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Setting new Kibana instance UUID: NEW_UUID",
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -294,7 +243,7 @@ describe('resolveInstanceUuid', () => {
|
|||
it('throws an explicit error for file read errors', async () => {
|
||||
mockReadFile({ error: permissionError });
|
||||
await expect(
|
||||
resolveInstanceUuid({ configService, logger, syncToFile: true })
|
||||
resolveInstanceUuid({ configService, logger })
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unable to read Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES"`
|
||||
);
|
||||
|
@ -302,7 +251,7 @@ describe('resolveInstanceUuid', () => {
|
|||
it('throws an explicit error for file write errors', async () => {
|
||||
mockWriteFile(isDirectoryError);
|
||||
await expect(
|
||||
resolveInstanceUuid({ configService, logger, syncToFile: true })
|
||||
resolveInstanceUuid({ configService, logger })
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unable to write Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EISDIR"`
|
||||
);
|
||||
|
|
|
@ -36,11 +36,9 @@ export const UUID_7_6_0_BUG = `ce42b997-a913-4d58-be46-bb1937feedd6`;
|
|||
|
||||
export async function resolveInstanceUuid({
|
||||
configService,
|
||||
syncToFile,
|
||||
logger,
|
||||
}: {
|
||||
configService: IConfigService;
|
||||
syncToFile: boolean;
|
||||
logger: Logger;
|
||||
}): Promise<string> {
|
||||
const [pathConfig, serverConfig] = await Promise.all([
|
||||
|
@ -65,7 +63,7 @@ export async function resolveInstanceUuid({
|
|||
} else {
|
||||
logger.debug(`Updating Kibana instance UUID to: ${uuidFromConfig} (was: ${uuidFromFile})`);
|
||||
}
|
||||
await writeUuidToFile(uuidFilePath, uuidFromConfig, syncToFile);
|
||||
await writeUuidToFile(uuidFilePath, uuidFromConfig);
|
||||
return uuidFromConfig;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +71,7 @@ export async function resolveInstanceUuid({
|
|||
const newUuid = uuid.v4();
|
||||
// no uuid either in config or file, we need to generate and write it.
|
||||
logger.debug(`Setting new Kibana instance UUID: ${newUuid}`);
|
||||
await writeUuidToFile(uuidFilePath, newUuid, syncToFile);
|
||||
await writeUuidToFile(uuidFilePath, newUuid);
|
||||
return newUuid;
|
||||
}
|
||||
|
||||
|
@ -105,11 +103,7 @@ async function readUuidFromFile(filepath: string, logger: Logger): Promise<strin
|
|||
}
|
||||
}
|
||||
|
||||
async function writeUuidToFile(filepath: string, uuidValue: string, syncToFile: boolean) {
|
||||
if (!syncToFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
async function writeUuidToFile(filepath: string, uuidValue: string) {
|
||||
try {
|
||||
return await writeFile(filepath, uuidValue, { encoding: FILE_ENCODING });
|
||||
} catch (e) {
|
||||
|
|
|
@ -23,8 +23,6 @@ import { CoreContext } from '../core_context';
|
|||
|
||||
import { loggingSystemMock } from '../logging/logging_system.mock';
|
||||
import { mockCoreContext } from '../core_context.mock';
|
||||
import { Env } from '../config';
|
||||
import { getEnvOptions } from '../config/__mocks__/env';
|
||||
|
||||
jest.mock('./resolve_uuid', () => ({
|
||||
resolveInstanceUuid: jest.fn().mockResolvedValue('SOME_UUID'),
|
||||
|
@ -47,28 +45,10 @@ describe('UuidService', () => {
|
|||
expect(resolveInstanceUuid).toHaveBeenCalledTimes(1);
|
||||
expect(resolveInstanceUuid).toHaveBeenCalledWith({
|
||||
configService: coreContext.configService,
|
||||
syncToFile: true,
|
||||
logger: logger.get('uuid'),
|
||||
});
|
||||
});
|
||||
|
||||
describe('when cliArgs.optimize is true', () => {
|
||||
it('calls resolveInstanceUuid with syncToFile: false', async () => {
|
||||
coreContext = mockCoreContext.create({
|
||||
logger,
|
||||
env: Env.createDefault(getEnvOptions({ cliArgs: { optimize: true } })),
|
||||
});
|
||||
const service = new UuidService(coreContext);
|
||||
await service.setup();
|
||||
expect(resolveInstanceUuid).toHaveBeenCalledTimes(1);
|
||||
expect(resolveInstanceUuid).toHaveBeenCalledWith({
|
||||
configService: coreContext.configService,
|
||||
syncToFile: false,
|
||||
logger: logger.get('uuid'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the uuid resolved from resolveInstanceUuid', async () => {
|
||||
const service = new UuidService(coreContext);
|
||||
const setup = await service.setup();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { resolveInstanceUuid } from './resolve_uuid';
|
||||
import { CoreContext } from '../core_context';
|
||||
import { Logger } from '../logging';
|
||||
import { IConfigService, CliArgs } from '../config';
|
||||
import { IConfigService } from '../config';
|
||||
|
||||
/**
|
||||
* APIs to access the application's instance uuid.
|
||||
|
@ -38,19 +38,16 @@ export interface UuidServiceSetup {
|
|||
export class UuidService {
|
||||
private readonly log: Logger;
|
||||
private readonly configService: IConfigService;
|
||||
private readonly cliArgs: CliArgs;
|
||||
private uuid: string = '';
|
||||
|
||||
constructor(core: CoreContext) {
|
||||
this.log = core.logger.get('uuid');
|
||||
this.configService = core.configService;
|
||||
this.cliArgs = core.env.cliArgs;
|
||||
}
|
||||
|
||||
public async setup() {
|
||||
this.uuid = await resolveInstanceUuid({
|
||||
configService: this.configService,
|
||||
syncToFile: !this.cliArgs.optimize,
|
||||
logger: this.log,
|
||||
});
|
||||
|
||||
|
|
|
@ -73,8 +73,6 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
|
|||
await run(Tasks.CreateNoticeFile);
|
||||
await run(Tasks.UpdateLicenseFile);
|
||||
await run(Tasks.RemovePackageJsonDeps);
|
||||
await run(Tasks.TranspileScss);
|
||||
await run(Tasks.OptimizeBuild);
|
||||
await run(Tasks.CleanTypescript);
|
||||
await run(Tasks.CleanExtraFilesFromModules);
|
||||
await run(Tasks.CleanEmptyFolders);
|
||||
|
|
|
@ -39,7 +39,6 @@ export const CopySource: Task = {
|
|||
'!src/functional_test_runner/**',
|
||||
'!src/dev/**',
|
||||
'typings/**',
|
||||
'webpackShims/**',
|
||||
'config/kibana.yml',
|
||||
'config/node.options',
|
||||
'tsconfig*.json',
|
||||
|
|
|
@ -31,12 +31,10 @@ export * from './install_dependencies_task';
|
|||
export * from './license_file_task';
|
||||
export * from './nodejs';
|
||||
export * from './notice_file_task';
|
||||
export * from './optimize_task';
|
||||
export * from './os_packages';
|
||||
export * from './patch_native_modules_task';
|
||||
export * from './path_length_task';
|
||||
export * from './transpile_babel_task';
|
||||
export * from './transpile_scss_task';
|
||||
export * from './uuid_verification_task';
|
||||
export * from './verify_env_task';
|
||||
export * from './write_sha_sums_task';
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* 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 { deleteAll, copyAll, exec, Task } from '../lib';
|
||||
import { getNodeDownloadInfo } from './nodejs';
|
||||
|
||||
export const OptimizeBuild: Task = {
|
||||
description: 'Running optimizer',
|
||||
|
||||
async run(config, log, build) {
|
||||
const tempNodeInstallDir = build.resolvePath('node');
|
||||
const platform = config.getPlatformForThisOs();
|
||||
|
||||
// copy extracted node for this platform into the build temporarily
|
||||
log.debug('Temporarily installing node.js for', platform.getNodeArch());
|
||||
const { extractDir } = getNodeDownloadInfo(config, platform);
|
||||
await copyAll(extractDir, tempNodeInstallDir);
|
||||
|
||||
const kibanaScript = platform.isWindows() ? '.\\bin\\kibana.bat' : './bin/kibana';
|
||||
|
||||
const kibanaArgs = ['--env.name=production', '--logging.json=false', '--optimize'];
|
||||
|
||||
log.info('Running bin/kibana to trigger the optimizer');
|
||||
|
||||
await exec(log, kibanaScript, kibanaArgs, {
|
||||
cwd: build.resolvePath('.'),
|
||||
env: {
|
||||
KBN_CACHE_LOADER_WRITABLE: 'true',
|
||||
NODE_OPTIONS: '--max-old-space-size=4096',
|
||||
},
|
||||
});
|
||||
|
||||
// clean up temporary node install
|
||||
await deleteAll([tempNodeInstallDir], log);
|
||||
},
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* 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 { Task } from '../lib';
|
||||
|
||||
// @ts-expect-error buildSass isn't TS yet
|
||||
import { buildSass } from '../../sass';
|
||||
|
||||
export const TranspileScss: Task = {
|
||||
description: 'Transpiling SCSS to CSS',
|
||||
async run(config, log, build) {
|
||||
await buildSass({
|
||||
log,
|
||||
kibanaDir: build.resolvePath('.'),
|
||||
});
|
||||
},
|
||||
};
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
### Description
|
||||
|
||||
The tool is used to extract default messages from all `*.{js, ts, jsx, tsx, html, pug}` files in provided plugins directories to a JSON file.
|
||||
The tool is used to extract default messages from all `*.{js, ts, jsx, tsx, html }` files in provided plugins directories to a JSON file.
|
||||
|
||||
It uses Babel to parse code and build an AST for each file or a single JS expression if whole file parsing is impossible. The tool is able to validate, extract and match IDs, default messages and descriptions only if they are defined statically and together, otherwise it will fail with detailed explanation. That means one can't define ID in one place and default message in another, or use function call to dynamically create default message etc.
|
||||
|
||||
|
@ -116,18 +116,6 @@ The `description` is optional, `values` is optional too unless `defaultMessage`
|
|||
|
||||
* Expression can be parsed only if it is located in syntactically valid JS/TS code. Do not use type assertions in TypeScript for `defaultMessage` or `description` properties, id argument or the second argument of `i18n*` call expression. It is never needed for i18n engine use cases.
|
||||
|
||||
* **Pug (.pug)**
|
||||
|
||||
```
|
||||
#{i18n('pluginNamespace.messageId', {
|
||||
defaultMessage: 'Default message string literal, {key}',
|
||||
values: { key: 'value' },
|
||||
description: 'Message context or description',
|
||||
})}
|
||||
```
|
||||
|
||||
* Expression in `#{...}` is parsed as a JS expression.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
extends ./chrome.pug
|
||||
|
||||
block content
|
||||
.kibanaWelcomeView
|
||||
.kibanaLoaderWrap
|
||||
.kibanaLoader
|
||||
.kibanaWelcomeLogoCircle
|
||||
.kibanaWelcomeLogo
|
||||
.kibanaWelcomeText
|
||||
| #{i18n('plugin_1.id_5', { defaultMessage: 'Message 5' })}
|
|
@ -30,13 +30,6 @@ Array [
|
|||
"message": "Message 4",
|
||||
},
|
||||
],
|
||||
Array [
|
||||
"plugin_1.id_5",
|
||||
Object {
|
||||
"description": undefined,
|
||||
"message": "Message 5",
|
||||
},
|
||||
],
|
||||
Array [
|
||||
"plugin_1.id_7",
|
||||
Object {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import path from 'path';
|
||||
|
||||
import { extractHtmlMessages, extractCodeMessages, extractPugMessages } from './extractors';
|
||||
import { extractHtmlMessages, extractCodeMessages } from './extractors';
|
||||
import { globAsync, readFileAsync, normalizePath } from './utils';
|
||||
|
||||
import { createFailError, isFailError } from '@kbn/dev-utils';
|
||||
|
@ -70,7 +70,7 @@ export async function matchEntriesWithExctractors(inputPath, options = {}) {
|
|||
'**/*.d.ts',
|
||||
].concat(additionalIgnore);
|
||||
|
||||
const entries = await globAsync('*.{js,jsx,pug,ts,tsx,html}', {
|
||||
const entries = await globAsync('*.{js,jsx,ts,tsx,html}', {
|
||||
cwd: inputPath,
|
||||
matchBase: true,
|
||||
ignore,
|
||||
|
@ -78,27 +78,24 @@ export async function matchEntriesWithExctractors(inputPath, options = {}) {
|
|||
absolute,
|
||||
});
|
||||
|
||||
const { htmlEntries, codeEntries, pugEntries } = entries.reduce(
|
||||
const { htmlEntries, codeEntries } = entries.reduce(
|
||||
(paths, entry) => {
|
||||
const resolvedPath = path.resolve(inputPath, entry);
|
||||
|
||||
if (resolvedPath.endsWith('.html')) {
|
||||
paths.htmlEntries.push(resolvedPath);
|
||||
} else if (resolvedPath.endsWith('.pug')) {
|
||||
paths.pugEntries.push(resolvedPath);
|
||||
} else {
|
||||
paths.codeEntries.push(resolvedPath);
|
||||
}
|
||||
|
||||
return paths;
|
||||
},
|
||||
{ htmlEntries: [], codeEntries: [], pugEntries: [] }
|
||||
{ htmlEntries: [], codeEntries: [] }
|
||||
);
|
||||
|
||||
return [
|
||||
[htmlEntries, extractHtmlMessages],
|
||||
[codeEntries, extractCodeMessages],
|
||||
[pugEntries, extractPugMessages],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`dev/i18n/extractors/pug extracts messages from pug template with interpolation 1`] = `
|
||||
Array [
|
||||
"message-id",
|
||||
Object {
|
||||
"description": "Message description",
|
||||
"message": "Default message",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`dev/i18n/extractors/pug extracts messages from pug template without interpolation 1`] = `
|
||||
Array [
|
||||
"message-id",
|
||||
Object {
|
||||
"description": "Message description",
|
||||
"message": "Default message",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`dev/i18n/extractors/pug throws on empty id 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
[Error: Empty "id" value in i18n() or i18n.translate() is not allowed.],
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`dev/i18n/extractors/pug throws on missing default message 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
[Error: Empty defaultMessage in i18n() or i18n.translate() is not allowed ("message-id").],
|
||||
],
|
||||
]
|
||||
`;
|
|
@ -19,4 +19,3 @@
|
|||
|
||||
export { extractCodeMessages } from './code';
|
||||
export { extractHtmlMessages } from './html';
|
||||
export { extractPugMessages } from './pug';
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* 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 { parse } from '@babel/parser';
|
||||
|
||||
import { extractI18nCallMessages } from './i18n_call';
|
||||
import { isI18nTranslateFunction, traverseNodes, createParserErrorMessage } from '../utils';
|
||||
import { createFailError, isFailError } from '@kbn/dev-utils';
|
||||
|
||||
/**
|
||||
* Matches `i18n(...)` in `#{i18n('id', { defaultMessage: 'Message text' })}`
|
||||
*/
|
||||
const PUG_I18N_REGEX = /i18n\((([^)']|'([^'\\]|\\.)*')*)\)/g;
|
||||
|
||||
function parsePugExpression(expression) {
|
||||
let ast;
|
||||
|
||||
try {
|
||||
ast = parse(expression);
|
||||
} catch (error) {
|
||||
if (error instanceof SyntaxError) {
|
||||
const errorWithContext = createParserErrorMessage(expression, error);
|
||||
throw createFailError(
|
||||
`Couldn't parse Pug expression with i18n(...) call:\n${errorWithContext}`
|
||||
);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Example: `#{i18n('message-id', { defaultMessage: 'Message text' })}`
|
||||
*/
|
||||
export function* extractPugMessages(buffer, reporter) {
|
||||
const expressions = buffer.toString().match(PUG_I18N_REGEX) || [];
|
||||
|
||||
for (const expression of expressions) {
|
||||
try {
|
||||
const ast = parsePugExpression(expression);
|
||||
const node = [...traverseNodes(ast.program.body)].find((node) =>
|
||||
isI18nTranslateFunction(node)
|
||||
);
|
||||
|
||||
if (node) {
|
||||
yield extractI18nCallMessages(node);
|
||||
}
|
||||
} catch (error) {
|
||||
if (!isFailError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
reporter.report(error);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* 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 { extractPugMessages } from './pug';
|
||||
|
||||
const report = jest.fn();
|
||||
|
||||
describe('dev/i18n/extractors/pug', () => {
|
||||
beforeEach(() => {
|
||||
report.mockClear();
|
||||
});
|
||||
|
||||
test('extracts messages from pug template with interpolation', () => {
|
||||
const source = Buffer.from(`\
|
||||
#{i18n('message-id', { defaultMessage: 'Default message', description: 'Message description' })}
|
||||
`);
|
||||
const [messageObject] = extractPugMessages(source);
|
||||
|
||||
expect(messageObject).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('extracts messages from pug template without interpolation', () => {
|
||||
const source = Buffer.from(`\
|
||||
.kibanaWelcomeText(data-error-message=i18n('message-id', { defaultMessage: 'Default message', description: 'Message description' }))
|
||||
`);
|
||||
const [messageObject] = extractPugMessages(source);
|
||||
|
||||
expect(messageObject).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('throws on empty id', () => {
|
||||
const source = Buffer.from(`\
|
||||
h1= i18n('', { defaultMessage: 'Default message', description: 'Message description' })
|
||||
`);
|
||||
|
||||
expect(() => extractPugMessages(source, { report }).next()).not.toThrow();
|
||||
expect(report.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('throws on missing default message', () => {
|
||||
const source = Buffer.from(`\
|
||||
#{i18n('message-id', { description: 'Message description' })}
|
||||
`);
|
||||
|
||||
expect(() => extractPugMessages(source, { report }).next()).not.toThrow();
|
||||
expect(report.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
});
|
|
@ -45,7 +45,6 @@ export async function extractUntrackedMessagesTask({
|
|||
const availablePaths = Object.values(config.paths).flat();
|
||||
const ignore = availablePaths.concat([
|
||||
'**/build/**',
|
||||
'**/webpackShims/**',
|
||||
'**/__fixtures__/**',
|
||||
'**/packages/kbn-i18n/**',
|
||||
'**/packages/kbn-plugin-generator/sao_template/**',
|
||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
|||
'<rootDir>/src/cli_plugin',
|
||||
'<rootDir>/packages/kbn-test/target/functional_test_runner',
|
||||
'<rootDir>/src/dev',
|
||||
'<rootDir>/src/optimize',
|
||||
'<rootDir>/src/legacy/utils',
|
||||
'<rootDir>/src/setup_node_env',
|
||||
'<rootDir>/packages',
|
||||
|
|
|
@ -40,7 +40,7 @@ export const IGNORE_FILE_GLOBS = [
|
|||
'x-pack/plugins/canvas/canvas_plugin_src/**/*',
|
||||
'x-pack/plugins/monitoring/public/lib/jquery_flot/**/*',
|
||||
'**/.*',
|
||||
'**/{webpackShims,__mocks__}/**/*',
|
||||
'**/__mocks__/**/*',
|
||||
'x-pack/docs/**/*',
|
||||
'src/core/server/core_app/assets/fonts/**/*',
|
||||
'packages/kbn-utility-types/test-d/**/*',
|
||||
|
@ -98,7 +98,6 @@ export const KEBAB_CASE_DIRECTORY_GLOBS = ['packages/*', 'x-pack'];
|
|||
*/
|
||||
export const IGNORE_DIRECTORY_GLOBS = [
|
||||
...KEBAB_CASE_DIRECTORY_GLOBS,
|
||||
'**/webpackShims',
|
||||
'src/babel-*',
|
||||
'packages/*',
|
||||
'packages/kbn-ui-framework/generator-kui',
|
||||
|
@ -142,35 +141,10 @@ export const TEMPORARILY_IGNORED_PATHS = [
|
|||
'src/core/server/core_app/assets/favicons/mstile-310x150.png',
|
||||
'src/core/server/core_app/assets/favicons/mstile-310x310.png',
|
||||
'src/core/server/core_app/assets/favicons/safari-pinned-tab.svg',
|
||||
'src/legacy/ui/public/styles/bootstrap/component-animations.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/input-groups.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/list-group.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/background-variant.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/border-radius.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/center-block.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/grid-framework.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/hide-text.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/list-group.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/nav-divider.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/nav-vertical-align.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/progress-bar.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/reset-filter.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/reset-text.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/responsive-visibility.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/tab-focus.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/table-row.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/text-emphasis.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/text-overflow.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/mixins/vendor-prefixes.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/progress-bars.less',
|
||||
'src/legacy/ui/public/styles/bootstrap/responsive-utilities.less',
|
||||
'test/functional/apps/management/exports/_import_objects-conflicts.json',
|
||||
'packages/kbn-ui-framework/doc_site/src/images/elastic-logo.svg',
|
||||
'packages/kbn-ui-framework/doc_site/src/images/hint-arrow.svg',
|
||||
'packages/kbn-ui-framework/doc_site/src/images/react-logo.svg',
|
||||
'webpackShims/elasticsearch-browser.js',
|
||||
'webpackShims/moment-timezone.js',
|
||||
'webpackShims/ui-bootstrap.js',
|
||||
'x-pack/legacy/plugins/index_management/public/lib/editSettings.js',
|
||||
'x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js',
|
||||
'x-pack/plugins/monitoring/public/components/sparkline/__mocks__/plugins/xpack_main/jquery_flot.js',
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* 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 { resolve } from 'path';
|
||||
|
||||
import * as Rx from 'rxjs';
|
||||
import { toArray } from 'rxjs/operators';
|
||||
|
||||
import { createFailError } from '@kbn/dev-utils';
|
||||
import { debounce } from 'lodash';
|
||||
import { findPluginSpecs } from '../../legacy/plugin_discovery';
|
||||
import { collectUiExports } from '../../legacy/ui';
|
||||
import { buildAll } from '../../legacy/server/sass/build_all';
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
// TODO: clintandrewhall - Extract and use FSWatcher from legacy/server/sass
|
||||
const build = async ({ log, kibanaDir, styleSheetPaths, watch }) => {
|
||||
if (styleSheetPaths.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let bundleCount = 0;
|
||||
try {
|
||||
const bundles = await buildAll({
|
||||
styleSheets: styleSheetPaths,
|
||||
log,
|
||||
buildDir: resolve(kibanaDir, 'built_assets/css'),
|
||||
sourceMap: true,
|
||||
});
|
||||
|
||||
bundles.forEach((bundle) => {
|
||||
log.debug(`Compiled SCSS: ${bundle.sourcePath} (theme=${bundle.theme})`);
|
||||
});
|
||||
|
||||
bundleCount = bundles.length;
|
||||
} catch (error) {
|
||||
const { message, line, file } = error;
|
||||
throw createFailError(`${message} on line ${line} of ${file}`);
|
||||
}
|
||||
|
||||
log.success('%d scss bundles %s', bundleCount, watch ? 'rebuilt' : 'created');
|
||||
};
|
||||
|
||||
export async function buildSass({ log, kibanaDir, watch }) {
|
||||
log.info('running plugin discovery in', kibanaDir);
|
||||
|
||||
const scanDirs = [resolve(kibanaDir, 'src/legacy/core_plugins')];
|
||||
const paths = [resolve(kibanaDir, 'x-pack')];
|
||||
const { spec$, disabledSpec$ } = findPluginSpecs({ plugins: { scanDirs, paths } });
|
||||
const allPlugins = await Rx.merge(spec$, disabledSpec$).pipe(toArray()).toPromise();
|
||||
const uiExports = collectUiExports(allPlugins);
|
||||
const { styleSheetPaths } = uiExports;
|
||||
|
||||
log.info('%s %d styleSheetPaths', watch ? 'watching' : 'found', styleSheetPaths.length);
|
||||
log.verbose(styleSheetPaths);
|
||||
|
||||
if (watch) {
|
||||
const debouncedBuild = debounce(async (path) => {
|
||||
let buildPaths = styleSheetPaths;
|
||||
if (path) {
|
||||
buildPaths = styleSheetPaths.filter((styleSheetPath) =>
|
||||
path.includes(styleSheetPath.urlImports.publicDir)
|
||||
);
|
||||
}
|
||||
await build({ log, kibanaDir, styleSheetPaths: buildPaths, watch });
|
||||
});
|
||||
|
||||
const watchPaths = styleSheetPaths.map((styleSheetPath) => styleSheetPath.urlImports.publicDir);
|
||||
|
||||
await build({ log, kibanaDir, styleSheetPaths });
|
||||
|
||||
chokidar.watch(watchPaths, { ignoreInitial: true }).on('all', (_, path) => {
|
||||
debouncedBuild(path);
|
||||
});
|
||||
} else {
|
||||
await build({ log, kibanaDir, styleSheetPaths });
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* 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 { run } from '@kbn/dev-utils';
|
||||
import { REPO_ROOT } from '../constants';
|
||||
import { buildSass } from './build_sass';
|
||||
|
||||
run(
|
||||
async ({ log, flags: { kibanaDir, watch } }) => {
|
||||
await buildSass({
|
||||
log,
|
||||
kibanaDir,
|
||||
watch,
|
||||
});
|
||||
},
|
||||
{
|
||||
description: 'Simple CLI, useful for building scss files outside of the server',
|
||||
flags: {
|
||||
default: {
|
||||
kibanaDir: REPO_ROOT,
|
||||
watch: false,
|
||||
},
|
||||
string: ['kibanaDir'],
|
||||
boolean: ['watch'],
|
||||
help: `
|
||||
--kibanaDir The root of the Kibana directory to build sass files in.
|
||||
--watch Watch the SASS files and recompile them on save.
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
import Fs from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import { getUiSettingDefaults } from './server/ui_setting_defaults';
|
||||
|
@ -40,7 +39,6 @@ export default function (kibana) {
|
|||
},
|
||||
|
||||
uiExports: {
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
uiSettingDefaults: getUiSettingDefaults(),
|
||||
},
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* 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 default function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
uiExports: {
|
||||
app: {
|
||||
title: 'Legacy Server Status',
|
||||
main: 'plugins/status_page/status_page',
|
||||
hidden: true,
|
||||
url: '/__legacy__/status',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "status_page",
|
||||
"version": "kibana"
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* 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 React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
// just to import eui into legacy
|
||||
import '@elastic/eui';
|
||||
|
||||
const STATUS_PAGE_DOM_NODE_ID = 'createStatusPageReact';
|
||||
|
||||
export function renderStatusPage() {
|
||||
const node = document.getElementById(STATUS_PAGE_DOM_NODE_ID);
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
render(<I18nContext>Foo</I18nContext>, node);
|
||||
}
|
||||
|
||||
export function destroyStatusPage() {
|
||||
const node = document.getElementById(STATUS_PAGE_DOM_NODE_ID);
|
||||
node && unmountComponentAtNode(node);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
<div id="createStatusPageReact"></div>
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* 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 'ui/i18n';
|
||||
import chrome from 'ui/chrome';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { destroyStatusPage, renderStatusPage } from './components/render';
|
||||
import template from 'plugins/status_page/status_page.html';
|
||||
|
||||
npStart.core.chrome.navLinks.enableForcedAppSwitcherNavigation();
|
||||
|
||||
chrome.setRootTemplate(template).setRootController('ui', function ($scope, buildNum, buildSha) {
|
||||
$scope.$$postDigest(() => {
|
||||
renderStatusPage(buildNum, buildSha.substr(0, 8));
|
||||
$scope.$on('$destroy', destroyStatusPage);
|
||||
});
|
||||
});
|