Skip to content

Commit

Permalink
Merge branch 'master' into mv/kibana-keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Jul 13, 2020
2 parents bb6bc84 + 4bdd31e commit 74ab52a
Show file tree
Hide file tree
Showing 439 changed files with 7,703 additions and 3,655 deletions.
2 changes: 1 addition & 1 deletion .ci/packer_cache_for_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo "Creating bootstrap_cache archive"
# archive cacheable directories
mkdir -p "$HOME/.kibana/bootstrap_cache"
tar -cf "$HOME/.kibana/bootstrap_cache/$branch.tar" \
x-pack/plugins/reporting/.chromium \
.chromium \
.es \
.chromedriver \
.geckodriver;
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/*.js.snap
**/graphql/types.ts
/.es
/.chromium
/build
/built_assets
/config/apm.dev.js
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.signing-config.json
.ackrc
/.es
/.chromium
.DS_Store
.node_binaries
.native_modules
Expand Down
2 changes: 1 addition & 1 deletion docs/apm/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ include::api.asciidoc[tag=using-the-APIs]
[%collapsible%open]
======
`version` :::
(required, string) Name of service.
(required, string) Version of service.
`environment` :::
(optional, string) Environment of service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export interface DiscoveredPlugin
| [configPath](./kibana-plugin-core-server.discoveredplugin.configpath.md) | <code>ConfigPath</code> | Root configuration path used by the plugin, defaults to "id" in snake\_case format. |
| [id](./kibana-plugin-core-server.discoveredplugin.id.md) | <code>PluginName</code> | Identifier of the plugin. |
| [optionalPlugins](./kibana-plugin-core-server.discoveredplugin.optionalplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that if installed and enabled \*\*may be\*\* leveraged by this plugin for some additional functionality but otherwise are not required for this plugin to work properly. |
| [requiredBundles](./kibana-plugin-core-server.discoveredplugin.requiredbundles.md) | <code>readonly PluginName[]</code> | List of plugin ids that this plugin's UI code imports modules from that are not in <code>requiredPlugins</code>. |
| [requiredPlugins](./kibana-plugin-core-server.discoveredplugin.requiredplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that \*\*must be\*\* installed and enabled for this plugin to function properly. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [DiscoveredPlugin](./kibana-plugin-core-server.discoveredplugin.md) &gt; [requiredBundles](./kibana-plugin-core-server.discoveredplugin.requiredbundles.md)

## DiscoveredPlugin.requiredBundles property

List of plugin ids that this plugin's UI code imports modules from that are not in `requiredPlugins`<!-- -->.

<b>Signature:</b>

```typescript
readonly requiredBundles: readonly PluginName[];
```

## Remarks

The plugins listed here will be loaded in the browser, even if the plugin is disabled. Required by `@kbn/optimizer` to support cross-plugin imports. "core" and plugins already listed in `requiredPlugins` do not need to be duplicated here.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Should never be used in code outside of Core but is exported for documentation p
| [id](./kibana-plugin-core-server.pluginmanifest.id.md) | <code>PluginName</code> | Identifier of the plugin. Must be a string in camelCase. Part of a plugin public contract. Other plugins leverage it to access plugin API, navigate to the plugin, etc. |
| [kibanaVersion](./kibana-plugin-core-server.pluginmanifest.kibanaversion.md) | <code>string</code> | The version of Kibana the plugin is compatible with, defaults to "version". |
| [optionalPlugins](./kibana-plugin-core-server.pluginmanifest.optionalplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that if installed and enabled \*\*may be\*\* leveraged by this plugin for some additional functionality but otherwise are not required for this plugin to work properly. |
| [requiredBundles](./kibana-plugin-core-server.pluginmanifest.requiredbundles.md) | <code>readonly string[]</code> | List of plugin ids that this plugin's UI code imports modules from that are not in <code>requiredPlugins</code>. |
| [requiredPlugins](./kibana-plugin-core-server.pluginmanifest.requiredplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that \*\*must be\*\* installed and enabled for this plugin to function properly. |
| [server](./kibana-plugin-core-server.pluginmanifest.server.md) | <code>boolean</code> | Specifies whether plugin includes some server-side specific functionality. |
| [ui](./kibana-plugin-core-server.pluginmanifest.ui.md) | <code>boolean</code> | Specifies whether plugin includes some client/browser specific functionality that should be included into client bundle via <code>public/ui_plugin.js</code> file. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [PluginManifest](./kibana-plugin-core-server.pluginmanifest.md) &gt; [requiredBundles](./kibana-plugin-core-server.pluginmanifest.requiredbundles.md)

## PluginManifest.requiredBundles property

List of plugin ids that this plugin's UI code imports modules from that are not in `requiredPlugins`<!-- -->.

<b>Signature:</b>

```typescript
readonly requiredBundles: readonly string[];
```

## Remarks

The plugins listed here will be loaded in the browser, even if the plugin is disabled. Required by `@kbn/optimizer` to support cross-plugin imports. "core" and plugins already listed in `requiredPlugins` do not need to be duplicated here.

2 changes: 1 addition & 1 deletion docs/maps/connect-to-ems.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maps makes requests directly from the browser to EMS.
To connect to EMS when your Kibana server and browser are in an internal network:

. Set `map.proxyElasticMapsServiceInMaps` to `true` in your <<settings, kibana.yml>> file to proxy EMS requests through the Kibana server.
. Update your firewall rules to whitelist connections from your Kibana server to the EMS domains.
. Update your firewall rules to allow connections from your Kibana server to the EMS domains.

NOTE: Coordinate map and region map visualizations do not support `map.proxyElasticMapsServiceInMaps` and will not proxy EMS requests through the Kibana server.

Expand Down
2 changes: 1 addition & 1 deletion docs/user/reporting/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ image::user/reporting/images/share-button.png["Share"]
[float]
== Setup

{reporting} is automatically enabled in {kib}. The first time {kib} runs, it extracts a custom build for the Chromium web browser, which
{reporting} is automatically enabled in {kib}. It runs a custom build of the Chromium web browser, which
runs on the server in headless mode to load {kib} and capture the rendered {kib} charts as images.

Chromium is an open-source project not related to Elastic, but the Chromium binary for {kib} has been custom-built by Elastic to ensure it
Expand Down
3 changes: 2 additions & 1 deletion examples/bfetch_explorer/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"server": true,
"ui": true,
"requiredPlugins": ["bfetch", "developerExamples"],
"optionalPlugins": []
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"]
}
3 changes: 2 additions & 1 deletion examples/dashboard_embeddable_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"server": false,
"ui": true,
"requiredPlugins": ["embeddable", "embeddableExamples", "dashboard", "developerExamples"],
"optionalPlugins": []
"optionalPlugins": [],
"requiredBundles": ["esUiShared"]
}
3 changes: 2 additions & 1 deletion examples/embeddable_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"ui": true,
"requiredPlugins": ["embeddable", "uiActions"],
"optionalPlugins": [],
"extraPublicDirs": ["public/todo", "public/hello_world", "public/todo/todo_ref_embeddable"]
"extraPublicDirs": ["public/todo", "public/hello_world", "public/todo/todo_ref_embeddable"],
"requiredBundles": ["kibanaReact"]
}
3 changes: 2 additions & 1 deletion examples/state_containers_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"server": true,
"ui": true,
"requiredPlugins": ["navigation", "data", "developerExamples"],
"optionalPlugins": []
"optionalPlugins": [],
"requiredBundles": ["kibanaUtils", "kibanaReact"]
}
3 changes: 2 additions & 1 deletion examples/ui_action_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"server": false,
"ui": true,
"requiredPlugins": ["uiActions"],
"optionalPlugins": []
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"]
}
3 changes: 2 additions & 1 deletion examples/ui_actions_explorer/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"server": false,
"ui": true,
"requiredPlugins": ["uiActions", "uiActionsExamples", "developerExamples"],
"optionalPlugins": []
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"**/@types/hoist-non-react-statics": "^3.3.1",
"**/@types/chai": "^4.2.11",
"**/cypress/@types/lodash": "^4.14.155",
"**/cypress/lodash": "^4.15.19",
"**/typescript": "3.9.5",
"**/graphql-toolkit/lodash": "^4.17.15",
"**/hoist-non-react-statics": "^3.3.2",
Expand Down Expand Up @@ -127,7 +128,7 @@
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "7.8.0",
"@elastic/ems-client": "7.9.3",
"@elastic/eui": "24.1.0",
"@elastic/eui": "26.3.1",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "^2.5.0",
Expand Down Expand Up @@ -255,7 +256,6 @@
"redux-actions": "^2.6.5",
"redux-thunk": "^2.3.0",
"regenerator-runtime": "^0.13.3",
"regression": "2.0.1",
"request": "^2.88.0",
"require-in-the-middle": "^5.0.2",
"reselect": "^4.0.0",
Expand Down Expand Up @@ -407,7 +407,7 @@
"babel-eslint": "^10.0.3",
"babel-jest": "^25.5.1",
"babel-plugin-istanbul": "^6.0.0",
"backport": "5.4.6",
"backport": "5.5.1",
"chai": "3.5.0",
"chance": "1.0.18",
"cheerio": "0.22.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "bar",
"ui": true
"ui": true,
"requiredBundles": ["foo"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
p {
background-color: rebeccapurple;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./other_styles.scss";

body {
width: $globalStyleConstant;
background-image: url("ui/icon.svg");
Expand Down
10 changes: 9 additions & 1 deletion packages/kbn-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ run(
throw createFlagError('expected --report-stats to have no value');
}

const filter = typeof flags.filter === 'string' ? [flags.filter] : flags.filter;
if (!Array.isArray(filter) || !filter.every((f) => typeof f === 'string')) {
throw createFlagError('expected --filter to be one or more strings');
}

const config = OptimizerConfig.create({
repoRoot: REPO_ROOT,
watch,
Expand All @@ -99,6 +104,7 @@ run(
extraPluginScanDirs,
inspectWorkers,
includeCoreBundle,
filter,
});

let update$ = runOptimizer(config);
Expand Down Expand Up @@ -128,12 +134,13 @@ run(
'inspect-workers',
'report-stats',
],
string: ['workers', 'scan-dir'],
string: ['workers', 'scan-dir', 'filter'],
default: {
core: true,
examples: true,
cache: true,
'inspect-workers': true,
filter: [],
},
help: `
--watch run the optimizer in watch mode
Expand All @@ -142,6 +149,7 @@ run(
--profile profile the webpack builds and write stats.json files to build outputs
--no-core disable generating the core bundle
--no-cache disable the cache
--filter comma-separated list of bundle id filters, results from multiple flags are merged, * and ! are supported
--no-examples don't build the example plugins
--dist create bundles that are suitable for inclusion in the Kibana distributable
--scan-dir add a directory to the list of directories scanned for plugins (specify as many times as necessary)
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-optimizer/src/common/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ it('creates cache keys', () => {
"spec": Object {
"contextDir": "/foo/bar",
"id": "bar",
"manifestPath": undefined,
"outputDir": "/foo/bar/target",
"publicDirNames": Array [
"public",
Expand Down Expand Up @@ -85,6 +86,7 @@ it('parses bundles from JSON specs', () => {
},
"contextDir": "/foo/bar",
"id": "bar",
"manifestPath": undefined,
"outputDir": "/foo/bar/target",
"publicDirNames": Array [
"public",
Expand Down
69 changes: 69 additions & 0 deletions packages/kbn-optimizer/src/common/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
*/

import Path from 'path';
import Fs from 'fs';

import { BundleCache } from './bundle_cache';
import { UnknownVals } from './ts_helpers';
import { includes, ascending, entriesToObject } from './array_helpers';

const VALID_BUNDLE_TYPES = ['plugin' as const, 'entry' as const];

const DEFAULT_IMPLICIT_BUNDLE_DEPS = ['core'];

const isStringArray = (input: any): input is string[] =>
Array.isArray(input) && input.every((x) => typeof x === 'string');

export interface BundleSpec {
readonly type: typeof VALID_BUNDLE_TYPES[0];
/** Unique id for this bundle */
Expand All @@ -37,6 +43,8 @@ export interface BundleSpec {
readonly sourceRoot: string;
/** Absolute path to the directory where output should be written */
readonly outputDir: string;
/** Absolute path to a kibana.json manifest file, if omitted we assume there are not dependenices */
readonly manifestPath?: string;
}

export class Bundle {
Expand All @@ -56,6 +64,12 @@ export class Bundle {
public readonly sourceRoot: BundleSpec['sourceRoot'];
/** Absolute path to the output directory for this bundle */
public readonly outputDir: BundleSpec['outputDir'];
/**
* Absolute path to a manifest file with "requiredBundles" which will be
* used to allow bundleRefs from this bundle to the exports of another bundle.
* Every bundle mentioned in the `requiredBundles` must be built together.
*/
public readonly manifestPath: BundleSpec['manifestPath'];

public readonly cache: BundleCache;

Expand All @@ -66,6 +80,7 @@ export class Bundle {
this.contextDir = spec.contextDir;
this.sourceRoot = spec.sourceRoot;
this.outputDir = spec.outputDir;
this.manifestPath = spec.manifestPath;

this.cache = new BundleCache(Path.resolve(this.outputDir, '.kbn-optimizer-cache'));
}
Expand Down Expand Up @@ -96,8 +111,54 @@ export class Bundle {
contextDir: this.contextDir,
sourceRoot: this.sourceRoot,
outputDir: this.outputDir,
manifestPath: this.manifestPath,
};
}

readBundleDeps(): { implicit: string[]; explicit: string[] } {
if (!this.manifestPath) {
return {
implicit: [...DEFAULT_IMPLICIT_BUNDLE_DEPS],
explicit: [],
};
}

let json: string;
try {
json = Fs.readFileSync(this.manifestPath, 'utf8');
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}

json = '{}';
}

let parsedManifest: { requiredPlugins?: string[]; requiredBundles?: string[] };
try {
parsedManifest = JSON.parse(json);
} catch (error) {
throw new Error(
`unable to parse manifest at [${this.manifestPath}], error: [${error.message}]`
);
}

if (typeof parsedManifest === 'object' && parsedManifest) {
const explicit = parsedManifest.requiredBundles || [];
const implicit = [...DEFAULT_IMPLICIT_BUNDLE_DEPS, ...(parsedManifest.requiredPlugins || [])];

if (isStringArray(explicit) && isStringArray(implicit)) {
return {
explicit,
implicit,
};
}
}

throw new Error(
`Expected "requiredBundles" and "requiredPlugins" in manifest file [${this.manifestPath}] to be arrays of strings`
);
}
}

/**
Expand Down Expand Up @@ -152,13 +213,21 @@ export function parseBundles(json: string) {
throw new Error('`bundles[]` must have an absolute path `outputDir` property');
}

const { manifestPath } = spec;
if (manifestPath !== undefined) {
if (!(typeof manifestPath === 'string' && Path.isAbsolute(manifestPath))) {
throw new Error('`bundles[]` must have an absolute path `manifestPath` property');
}
}

return new Bundle({
type,
id,
publicDirNames,
contextDir,
sourceRoot,
outputDir,
manifestPath,
});
}
);
Expand Down
Loading

0 comments on commit 74ab52a

Please sign in to comment.