Skip to content

Commit

Permalink
Sustainable Kibana Architecture: Move CodeEditor related packages #…
Browse files Browse the repository at this point in the history
…205587 (#205738)

## Summary

This PR aims at relocating some of the Kibana modules (plugins and
packages) into a new folder structure, according to the _Sustainable
Kibana Architecture_ initiative.

> [!IMPORTANT]
> * We kindly ask you to:
> * Manually fix the errors in the error section below (if there are
any).
> * Search for the `packages[\/\\]` and `plugins[\/\\]` patterns in the
source code (Babel and Eslint config files), and update them
appropriately.
> * Manually review
`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to ensure that
any CI pipeline customizations continue to be correctly applied after
the changed path names
> * Review all of the updated files, specially the `.ts` and `.js` files
listed in the sections below, as some of them contain relative paths
that have been updated.
> * Think of potential impact of the move, including tooling and
configuration files that can be pointing to the relocated modules. E.g.:
>     * customised eslint rules
>     * docs pointing to source code

> [!NOTE]
> * This PR has been auto-generated.
> * Any manual contributions will be lost if the 'relocate' script is
re-run.
> * Try to obtain the missing reviews / approvals before applying manual
fixes, and/or keep your changes in a .patch / git stash.
> * Please use
[#sustainable_kibana_architecture](https://elastic.slack.com/archives/C07TCKTA22E)
Slack channel for feedback.

Are you trying to rebase this PR to solve merge conflicts? Please follow
the steps describe
[here](https://elastic.slack.com/archives/C07TCKTA22E/p1734019532879269?thread_ts=1734019339.935419&cid=C07TCKTA22E).

#### 3 packages(s) are going to be relocated:

| Id | Target folder |
| -- | ------------- |
| `@kbn/code-editor` |
`src/platform/packages/shared/shared-ux/code_editor/impl` |
| `@kbn/code-editor-mock` |
`src/platform/packages/shared/shared-ux/code_editor/mocks` |
| `@kbn/monaco` | `src/platform/packages/shared/kbn-monaco` |


<details >
<summary>Updated relative paths</summary>

```
src/platform/packages/shared/kbn-monaco/jest.config.js:12
src/platform/packages/shared/kbn-monaco/tsconfig.json:2
src/platform/packages/shared/kbn-monaco/tsconfig.type_check.json:2
src/platform/packages/shared/shared-ux/code_editor/impl/jest.config.js:12
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:16
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.json:2
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:18
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:2
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:25
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:28
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:31
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:34
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:37
src/platform/packages/shared/shared-ux/code_editor/impl/tsconfig.type_check.json:40
src/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:16
src/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.json:2
src/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:18
src/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:2
src/platform/packages/shared/shared-ux/code_editor/mocks/tsconfig.type_check.json:25
```

</details>
  • Loading branch information
Dosant authored Jan 8, 2025
1 parent 24f8888 commit 3b2ab7b
Show file tree
Hide file tree
Showing 211 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ snapshots.js
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
/packages/kbn-ui-framework/dist
/src/platform/packages/shared/kbn-flot-charts/lib
/packages/kbn-monaco/src/**/antlr
/src/platform/packages/shared/kbn-monaco/src/**/antlr
/src/platform/packages/shared/kbn-esql-ast/src/**/antlr

# Bazel
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ packages/kbn-management/storybook/config @elastic/kibana-management
packages/kbn-manifest @elastic/kibana-core
packages/kbn-mock-idp-plugin @elastic/kibana-security
packages/kbn-mock-idp-utils @elastic/kibana-security
packages/kbn-monaco @elastic/appex-sharedux
packages/kbn-openapi-bundler @elastic/security-detection-rule-management
packages/kbn-openapi-generator @elastic/security-detection-rule-management
packages/kbn-optimizer @elastic/kibana-operations
Expand Down Expand Up @@ -230,8 +229,6 @@ packages/serverless/settings/common @elastic/appex-sharedux @elastic/kibana-mana
packages/serverless/settings/observability_project @elastic/appex-sharedux @elastic/kibana-management @elastic/obs-ux-management-team
packages/serverless/storybook/config @elastic/appex-sharedux
packages/serverless/types @elastic/appex-sharedux
packages/shared-ux/code_editor/impl @elastic/appex-sharedux
packages/shared-ux/code_editor/mocks @elastic/appex-sharedux
src/core @elastic/kibana-core
src/core/packages/analytics/browser @elastic/kibana-core
src/core/packages/analytics/browser-internal @elastic/kibana-core
Expand Down Expand Up @@ -501,6 +498,7 @@ src/platform/packages/shared/kbn-management/settings/components/field_row @elast
src/platform/packages/shared/kbn-management/settings/field_definition @elastic/kibana-management
src/platform/packages/shared/kbn-management/settings/types @elastic/kibana-management
src/platform/packages/shared/kbn-management/settings/utilities @elastic/kibana-management
src/platform/packages/shared/kbn-monaco @elastic/appex-sharedux
src/platform/packages/shared/kbn-object-versioning @elastic/appex-sharedux
src/platform/packages/shared/kbn-object-versioning-utils @elastic/appex-sharedux
src/platform/packages/shared/kbn-openapi-common @elastic/security-detection-rule-management
Expand Down Expand Up @@ -570,6 +568,8 @@ src/platform/packages/shared/shared-ux/card/no_data/impl @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/card/no_data/mocks @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/card/no_data/types @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/chrome/navigation @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/code_editor/impl @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/code_editor/mocks @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/error_boundary @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/file/context @elastic/appex-sharedux
src/platform/packages/shared/shared-ux/file/file_picker/impl @elastic/appex-sharedux
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"src/platform/packages/shared/kbn-management",
"packages/kbn-management"
],
"monaco": "packages/kbn-monaco/src",
"monaco": "src/platform/packages/shared/kbn-monaco/src",
"navigation": ["src/platform/plugins/shared/navigation", "packages/solution-nav"],
"links": "src/platform/plugins/private/links",
"newsfeed": "src/platform/plugins/shared/newsfeed",
Expand Down
2 changes: 1 addition & 1 deletion dev_docs/contributing/code_walkthrough.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Contains our two license header texts, one for the Elastic license and one for t

## [packages](https://github.com/elastic/kibana/tree/main/packages)

The packages folder contains a mixture of build-time related code (like the [code needed to build the api docs](https://github.com/elastic/kibana/tree/main/packages/kbn-docs-utils)), as well as static code that some plugins rely on (like the [kbn-monaco package](https://github.com/elastic/kibana/tree/main/packages/kbn-monaco)). <DocLink id="kibPlatformIntro" section="1000-foot-view" text="This document"/> covers how packages differ from plugins.
The packages folder contains a mixture of build-time related code (like the [code needed to build the api docs](https://github.com/elastic/kibana/tree/main/packages/kbn-docs-utils)), as well as static code that some plugins rely on (like the [kbn-monaco package](https://github.com/elastic/kibana/tree/main/src/platform/packages/shared/kbn-monaco)). <DocLink id="kibPlatformIntro" section="1000-foot-view" text="This document"/> covers how packages differ from plugins.

## [plugins](https://github.com/elastic/kibana/tree/main/plugins)

Expand Down
2 changes: 1 addition & 1 deletion kbn_pm/src/lib/bazel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BAZEL_RUNNER_SRC = '../../../packages/kbn-bazel-runner/index.js';
const BAZEL_TARGETS = [
'//src/platform/packages/private/kbn-ui-shared-deps-npm:shared_built_assets',
'//src/platform/packages/private/kbn-ui-shared-deps-src:shared_built_assets',
'//packages/kbn-monaco:target_workers',
'//src/platform/packages/shared/kbn-monaco:target_workers',
];

async function getBazelRunner() {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@
"@kbn/cloud-security-posture-common": "link:x-pack/platform/packages/shared/kbn-cloud-security-posture/common",
"@kbn/cloud-security-posture-graph": "link:x-pack/solutions/security/packages/kbn-cloud-security-posture/graph",
"@kbn/cloud-security-posture-plugin": "link:x-pack/solutions/security/plugins/cloud_security_posture",
"@kbn/code-editor": "link:packages/shared-ux/code_editor/impl",
"@kbn/code-editor-mock": "link:packages/shared-ux/code_editor/mocks",
"@kbn/code-editor": "link:src/platform/packages/shared/shared-ux/code_editor/impl",
"@kbn/code-editor-mock": "link:src/platform/packages/shared/shared-ux/code_editor/mocks",
"@kbn/coloring": "link:src/platform/packages/shared/kbn-coloring",
"@kbn/config": "link:src/platform/packages/shared/kbn-config",
"@kbn/config-mocks": "link:src/platform/packages/private/kbn-config-mocks",
Expand Down Expand Up @@ -681,7 +681,7 @@
"@kbn/ml-ui-actions": "link:x-pack/platform/packages/private/ml/ui_actions",
"@kbn/ml-url-state": "link:x-pack/platform/packages/private/ml/url_state",
"@kbn/ml-validators": "link:x-pack/platform/packages/private/ml/validators",
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/monaco": "link:src/platform/packages/shared/kbn-monaco",
"@kbn/monitoring-collection-plugin": "link:x-pack/platform/plugins/private/monitoring_collection",
"@kbn/monitoring-plugin": "link:x-pack/platform/plugins/private/monitoring",
"@kbn/navigation-plugin": "link:src/platform/plugins/shared/navigation",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/src/tasks/bazel_packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function buildBazelPackages({ log, dist }: TaskContext) {
'build',
'//src/platform/packages/private/kbn-ui-shared-deps-npm:shared_built_assets',
'//src/platform/packages/private/kbn-ui-shared-deps-src:shared_built_assets',
'//packages/kbn-monaco:target_workers',
'//src/platform/packages/shared/kbn-monaco:target_workers',
'--show_result=1',
].concat(dist ? [`--define=dist=true`] : []),
{
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/tasks/build_packages_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const BuildPackages: Task = {
'build',
'//src/platform/packages/private/kbn-ui-shared-deps-npm:shared_built_assets',
'//src/platform/packages/private/kbn-ui-shared-deps-src:shared_built_assets',
'//packages/kbn-monaco:target_workers',
'//src/platform/packages/shared/kbn-monaco:target_workers',
'--show_result=1',
'--define=dist=true',
],
Expand Down
2 changes: 1 addition & 1 deletion src/platform/packages/private/kbn-esql-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contains the editor for text based languages. Specifically for:
---

Contains the ESQL editor with the autocomplete and the autosuggest functionality (based on atlr).
The antlr code can be found in packages/kbn-monaco/src/esql
The antlr code can be found in src/platform/packages/shared/kbn-monaco/src/esql

A **monaco** based editor that is part of the unified search experience. It is rendered for all the applications that support text-based languages.
In order to enable text based languages on your unified search bar add `textBasedLanguages: ['ESQL', '...']` to the dataViewPicker properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ webpack_cli(
"//src/platform/packages/shared/kbn-i18n-react",
"//src/platform/packages/shared/kbn-ebt-tools",
"//src/platform/packages/shared/kbn-esql-ast",
"//packages/kbn-monaco",
"//src/platform/packages/shared/kbn-monaco",
"//src/platform/packages/shared/kbn-datemath",
"//src/platform/packages/shared/kbn-analytics",
"//src/platform/packages/shared/kbn-crypto-browser",
Expand All @@ -38,7 +38,7 @@ webpack_cli(
"//packages/kbn-peggy-loader",
"//src/platform/packages/shared/shared-ux/error_boundary",
"//src/platform/packages/shared/kbn-rison",
"//packages/shared-ux/code_editor/impl:code_editor",
"//src/platform/packages/shared/shared-ux/code_editor/impl:code_editor",
"//packages/react/kibana_context/common",
"//packages/react/kibana_context/root",
"//packages/react/kibana_context/render",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-monaco'],
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-monaco'],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ESQL Theme', () => {
const theme = buildESQLTheme(mockTheme);

// These names aren't from the lexer... they are added on our side
// see packages/kbn-monaco/src/esql/lib/esql_token_helpers.ts
// see src/platform/packages/shared/kbn-monaco/src/esql/lib/esql_token_helpers.ts
const syntheticNames = ['functions', 'nulls_order', 'timespan_literal'];

const rulesWithNoName: string[] = [];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/shared-ux/code_editor'],
rootDir: '../../../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/shared-ux/code_editor'],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand All @@ -13,7 +13,7 @@
"include": [
"**/*.ts",
"**/*.tsx",
"../../../../typings/**/*",
"../../../../../../../typings/**/*",
],
"exclude": [
"target/**/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand All @@ -13,7 +13,7 @@
"include": [
"**/*.ts",
"**/*.tsx",
"../../../../typings/**/*",
"../../../../../../../typings/**/*",
],
"exclude": [
"target/**/*",
Expand Down
2 changes: 1 addition & 1 deletion src/platform/plugins/shared/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ POST /_some_endpoint
```

## Architecture
Console uses Monaco editor that is wrapped with [`kbn-monaco`](https://github.com/elastic/kibana/blob/main/packages/kbn-monaco/index.ts), so that if needed it can easily be replaced with another editor.
Console uses Monaco editor that is wrapped with [`kbn-monaco`](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-monaco/index.ts), so that if needed it can easily be replaced with another editor.
The autocomplete logic is located in [`autocomplete`](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/console/public/lib/autocomplete) folder. Autocomplete rules are computed by classes in `components` sub-folder.

## Autocomplete definitions
Expand Down
4 changes: 2 additions & 2 deletions test/functional/services/monaco_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class MonacoEditorService extends FtrService {
await this.retry.try(async () => {
values = await this.browser.execute(
() =>
// @ts-expect-error this value is provided in @kbn/monaco for this specific purpose, see {@link packages/kbn-monaco/src/register_globals.ts}
// @ts-expect-error this value is provided in @kbn/monaco for this specific purpose, see {@link src/platform/packages/shared/kbn-monaco/src/register_globals.ts}
(window.MonacoEnvironment?.monaco.editor as typeof monaco.editor)
.getModels()
.map((model: any) => model.getValue()) as string[]
Expand All @@ -48,7 +48,7 @@ export class MonacoEditorService extends FtrService {
await this.retry.try(async () => {
await this.browser.execute(
(editorIndex, codeEditorValue) => {
// @ts-expect-error this value is provided in @kbn/monaco for this specific purpose, see {@link packages/kbn-monaco/src/register_globals.ts}
// @ts-expect-error this value is provided in @kbn/monaco for this specific purpose, see {@link src/platform/packages/shared/kbn-monaco/src/register_globals.ts}
const editor = window.MonacoEnvironment?.monaco.editor as typeof monaco.editor;
const textModels = editor.getModels();

Expand Down
12 changes: 6 additions & 6 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@
"@kbn/cloud-security-posture-graph/*": ["x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/*"],
"@kbn/cloud-security-posture-plugin": ["x-pack/solutions/security/plugins/cloud_security_posture"],
"@kbn/cloud-security-posture-plugin/*": ["x-pack/solutions/security/plugins/cloud_security_posture/*"],
"@kbn/code-editor": ["packages/shared-ux/code_editor/impl"],
"@kbn/code-editor/*": ["packages/shared-ux/code_editor/impl/*"],
"@kbn/code-editor-mock": ["packages/shared-ux/code_editor/mocks"],
"@kbn/code-editor-mock/*": ["packages/shared-ux/code_editor/mocks/*"],
"@kbn/code-editor": ["src/platform/packages/shared/shared-ux/code_editor/impl"],
"@kbn/code-editor/*": ["src/platform/packages/shared/shared-ux/code_editor/impl/*"],
"@kbn/code-editor-mock": ["src/platform/packages/shared/shared-ux/code_editor/mocks"],
"@kbn/code-editor-mock/*": ["src/platform/packages/shared/shared-ux/code_editor/mocks/*"],
"@kbn/code-owners": ["packages/kbn-code-owners"],
"@kbn/code-owners/*": ["packages/kbn-code-owners/*"],
"@kbn/coloring": ["src/platform/packages/shared/kbn-coloring"],
Expand Down Expand Up @@ -1296,8 +1296,8 @@
"@kbn/mock-idp-plugin/*": ["packages/kbn-mock-idp-plugin/*"],
"@kbn/mock-idp-utils": ["packages/kbn-mock-idp-utils"],
"@kbn/mock-idp-utils/*": ["packages/kbn-mock-idp-utils/*"],
"@kbn/monaco": ["packages/kbn-monaco"],
"@kbn/monaco/*": ["packages/kbn-monaco/*"],
"@kbn/monaco": ["src/platform/packages/shared/kbn-monaco"],
"@kbn/monaco/*": ["src/platform/packages/shared/kbn-monaco/*"],
"@kbn/monitoring-collection-plugin": ["x-pack/platform/plugins/private/monitoring_collection"],
"@kbn/monitoring-collection-plugin/*": ["x-pack/platform/plugins/private/monitoring_collection/*"],
"@kbn/monitoring-plugin": ["x-pack/platform/plugins/private/monitoring"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const INGEST_PIPELINE_PAINLESS_CONTEXT = 'ctx' as const as SafePainlessExpressio
* - Subsequent characters can be underscores, letters, or digits.
*
* This is the ID and DOTID regexp in the Painless grammar under the following link:
* @link packages/kbn-monaco/src/painless/antlr/painless_parser.g4
* @link src/platform/packages/shared/kbn-monaco/src/painless/antlr/painless_parser.g4
*/
const PAINLESS_IDENTIFIER_REGEXP = /^[_a-zA-Z][_a-zA-Z0-9]*$/;

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4217,11 +4217,11 @@
version "0.0.0"
uid ""

"@kbn/code-editor-mock@link:packages/shared-ux/code_editor/mocks":
"@kbn/code-editor-mock@link:src/platform/packages/shared/shared-ux/code_editor/mocks":
version "0.0.0"
uid ""

"@kbn/code-editor@link:packages/shared-ux/code_editor/impl":
"@kbn/code-editor@link:src/platform/packages/shared/shared-ux/code_editor/impl":
version "0.0.0"
uid ""

Expand Down Expand Up @@ -6445,7 +6445,7 @@
version "0.0.0"
uid ""

"@kbn/monaco@link:packages/kbn-monaco":
"@kbn/monaco@link:src/platform/packages/shared/kbn-monaco":
version "0.0.0"
uid ""

Expand Down

0 comments on commit 3b2ab7b

Please sign in to comment.