Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove core->cli dependency #95145

Merged
merged 45 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7fdc347
extract http_tools to package
pgayvallet Mar 23, 2021
3c7ca94
fix readme
pgayvallet Mar 23, 2021
a617ef8
start moving stuff
pgayvallet Mar 23, 2021
10dcd75
cleaning up `isDevCliParent`
pgayvallet Mar 23, 2021
023c6af
choose bootstrap script
pgayvallet Mar 23, 2021
38ab1af
fix bootstrap script logic
pgayvallet Mar 24, 2021
fb098c0
fix watch paths logic
pgayvallet Mar 24, 2021
0967c20
import REPO_ROOT from correct package
pgayvallet Mar 24, 2021
54ee08a
create the @kbn/crypto package
pgayvallet Mar 24, 2021
1ef4ddd
update core's `dev` config
pgayvallet Mar 24, 2021
d2e1ba0
only export bootstrap function
pgayvallet Mar 24, 2021
6a64c1c
extract sslConfig to http-tools package
pgayvallet Mar 24, 2021
790b74a
fix core types
pgayvallet Mar 24, 2021
3ddd3e7
fix optimizer tests
pgayvallet Mar 24, 2021
a25f37c
fix cli_dev_mode tests
pgayvallet Mar 24, 2021
f4892b4
fix basePath proxy tests
pgayvallet Mar 24, 2021
783e4f7
update generated doc
pgayvallet Mar 24, 2021
a7a0b1f
fix unit tests
pgayvallet Mar 24, 2021
f19dfa1
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 25, 2021
77e5625
create @kbn/dev-cli-mode package
pgayvallet Mar 25, 2021
6908053
remove useless comment
pgayvallet Mar 25, 2021
587d275
self-review NITS
pgayvallet Mar 25, 2021
47db89a
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 25, 2021
3092af1
update CODEOWNERS file
pgayvallet Mar 25, 2021
74a7a35
add devOnly flag
pgayvallet Mar 25, 2021
35420c6
use variable for DEV_MODE_PATH
pgayvallet Mar 25, 2021
2fe3e49
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 26, 2021
eafa84c
review comments
pgayvallet Mar 26, 2021
83943d1
fix logger/log adapter
pgayvallet Mar 26, 2021
bd2a5a8
fix log calls in base path proxy server
pgayvallet Mar 26, 2021
63f059a
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 29, 2021
b14bdcc
address some review comments
pgayvallet Mar 29, 2021
78d0d42
rename @kbn/http-tools to @kbn/server-http-tools
pgayvallet Mar 29, 2021
70dadaa
more review comments
pgayvallet Mar 29, 2021
08ed6ea
move test to correct file
pgayvallet Mar 29, 2021
fd26fba
add comment on getBootstrapScript
pgayvallet Mar 29, 2021
107bb39
fix lint
pgayvallet Mar 29, 2021
324d2d8
lint
pgayvallet Mar 29, 2021
dabd6eb
add cli-dev-mode to eslint dev packages
pgayvallet Mar 29, 2021
19a018e
review comments
pgayvallet Mar 29, 2021
e2ab226
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 29, 2021
f47fc07
update yarn.lock
pgayvallet Mar 29, 2021
28ef9e8
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 30, 2021
b007289
Revert "[ci] skip building ts refs when not necessary (#95739)"
pgayvallet Mar 30, 2021
a123e34
Merge remote-tracking branch 'upstream/master' into kbn-76935-extract…
pgayvallet Mar 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
const DEV_PACKAGES = [
'kbn-babel-code-parser',
'kbn-dev-utils',
'kbn-cli-dev-mode',
'kbn-docs-utils',
'kbn-es*',
'kbn-eslint*',
Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
/packages/kbn-ui-shared-deps/ @elastic/kibana-operations
/packages/kbn-es-archiver/ @elastic/kibana-operations
/packages/kbn-utils/ @elastic/kibana-operations
/packages/kbn-cli-dev-mode/ @elastic/kibana-operations
/src/cli/keystore/ @elastic/kibana-operations
/src/legacy/server/warnings/ @elastic/kibana-operations
/.ci/es-snapshots/ @elastic/kibana-operations
Expand Down Expand Up @@ -194,6 +195,8 @@
/packages/kbn-config/ @elastic/kibana-core
/packages/kbn-logging/ @elastic/kibana-core
/packages/kbn-legacy-logging/ @elastic/kibana-core
/packages/kbn-crypto/ @elastic/kibana-core
/packages/kbn-http-tools/ @elastic/kibana-core
/src/legacy/server/config/ @elastic/kibana-core
/src/legacy/server/http/ @elastic/kibana-core
/src/legacy/server/logging/ @elastic/kibana-core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Set of helpers used to create `KibanaResponse` to form HTTP response on an incom

```typescript
kibanaResponseFactory: {
custom: <T extends string | Record<string, any> | Buffer | Error | Stream | {
custom: <T extends string | Record<string, any> | Error | Buffer | {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not change anything on any core type. Moving stuff around just had some effects on TS non-deterministic type generation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, the print order in union types is indeterministic, we should minimize the number of Union type occurrences in the public types #78126

message: string | Error;
attributes?: Record<string, any> | undefined;
} | undefined>(options: CustomHttpResponseOptions<T>) => KibanaResponse<T>;
} | Stream | undefined>(options: CustomHttpResponseOptions<T>) => KibanaResponse<T>;
badRequest: (options?: ErrorHttpResponseOptions) => KibanaResponse<ResponseError>;
unauthorized: (options?: ErrorHttpResponseOptions) => KibanaResponse<ResponseError>;
forbidden: (options?: ErrorHttpResponseOptions) => KibanaResponse<ResponseError>;
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@
"@kbn/apm-utils": "link:packages/kbn-apm-utils",
"@kbn/config": "link:packages/kbn-config",
"@kbn/config-schema": "link:packages/kbn-config-schema",
"@kbn/crypto": "link:packages/kbn-crypto",
"@kbn/i18n": "link:packages/kbn-i18n",
"@kbn/interpreter": "link:packages/kbn-interpreter",
"@kbn/legacy-logging": "link:packages/kbn-legacy-logging",
"@kbn/logging": "link:packages/kbn-logging",
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/server-http-tools": "link:packages/kbn-server-http-tools",
"@kbn/std": "link:packages/kbn-std",
"@kbn/tinymath": "link:packages/kbn-tinymath",
"@kbn/ui-framework": "link:packages/kbn-ui-framework",
Expand Down Expand Up @@ -450,6 +452,7 @@
"@jest/reporters": "^26.5.2",
"@kbn/babel-code-parser": "link:packages/kbn-babel-code-parser",
"@kbn/babel-preset": "link:packages/kbn-babel-preset",
"@kbn/cli-dev-mode": "link:packages/kbn-cli-dev-mode",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbn/cli-dev-mode is a dev dependency, making sure we'll not be shipping it into production builds.

"@kbn/dev-utils": "link:packages/kbn-dev-utils",
"@kbn/docs-utils": "link:packages/kbn-docs-utils",
"@kbn/es": "link:packages/kbn-es",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ The `DevServer` object is responsible for everything related to running and rest

The `Optimizer` object manages a `@kbn/optimizer` instance, adapting its configuration and logging to the data available to the CLI.

## `BasePathProxyServer` (currently passed from core)
## `BasePathProxyServer`

The `BasePathProxyServer` is passed to the `CliDevMode` from core when the dev mode is trigged by the `--dev` flag. This proxy injects a random three character base path in the URL that Kibana is served from to help ensure that Kibana features are written to adapt to custom base path configurations from users.
This proxy injects a random three character base path in the URL that Kibana is served from to help ensure that Kibana features
are written to adapt to custom base path configurations from users.

The basePathProxy also has another important job, ensuring that requests don't fail because the server is restarting and that the browser receives front-end assets containing all saved changes. We accomplish this by observing the ready state of the `Optimizer` and `DevServer` objects and pausing all requests through the proxy until both objects report that they aren't building/restarting based on recently saved changes.
The basePathProxy also has another important job, ensuring that requests don't fail because the server is restarting and
that the browser receives front-end assets containing all saved changes. We accomplish this by observing the ready state of
the `Optimizer` and `DevServer` objects and pausing all requests through the proxy until both objects report that
they aren't building/restarting based on recently saved changes.
13 changes: 13 additions & 0 deletions packages/kbn-cli-dev-mode/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-cli-dev-mode'],
};
26 changes: 26 additions & 0 deletions packages/kbn-cli-dev-mode/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@kbn/cli-dev-mode",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true,
"scripts": {
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},
"kibana": {
"devOnly": true
},
"dependencies": {
"@kbn/config": "link:../kbn-config",
"@kbn/config-schema": "link:../kbn-config-schema",
"@kbn/logging": "link:../kbn-logging",
"@kbn/server-http-tools": "link:../kbn-server-http-tools",
"@kbn/optimizer": "link:../kbn-optimizer",
"@kbn/std": "link:../kbn-std",
"@kbn/dev-utils": "link:../kbn-dev-utils",
"@kbn/utils": "link:../kbn-utils"
}
}
Loading