Skip to content

Commit

Permalink
Relocate @kbn/core inside src/core/packages/core
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Dec 20, 2024
1 parent fecc6d5 commit 656cae1
Show file tree
Hide file tree
Showing 275 changed files with 466 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
source .buildkite/scripts/common/util.sh

echo --- Check SO definition changes
cmd="node scripts/jest_integration -u src/core/server/integration_tests/ci_checks"
cmd="node scripts/jest_integration -u src/core/packages/core/server/integration_tests/ci_checks"

eval "$cmd"
check_for_changed_files "$cmd" true
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ module.exports = {
{
files: [
// core-team owned code
'src/core/**',
'src/core/packages/core/**',
'x-pack/plugins/features/**',
'x-pack/plugins/licensing/**',
'x-pack/plugins/global_search/**',
Expand Down
8 changes: 4 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ packages/shared-ux/router/types @elastic/appex-sharedux
packages/shared-ux/storybook/config @elastic/appex-sharedux
packages/shared-ux/storybook/mock @elastic/appex-sharedux
packages/shared-ux/table_persist @elastic/appex-sharedux
src/core @elastic/kibana-core
src/core/packages/core @elastic/kibana-core
src/platform/packages/private/default-nav/devtools @elastic/kibana-management
src/platform/packages/private/default-nav/management @elastic/kibana-management
src/platform/packages/private/default-nav/ml @elastic/ml-ui
Expand Down Expand Up @@ -1822,7 +1822,7 @@ packages/kbn-monaco/src/esql @elastic/kibana-esql
/x-pack/test_serverless/api_integration/test_suites/**/telemetry/ @elastic/kibana-core
/x-pack/test/functional/es_archives/cases/migrations/8.8.0 @elastic/response-ops

#CC# /src/core/server/csp/ @elastic/kibana-core
#CC# /src/core/packages/core/server/csp/ @elastic/kibana-core
#CC# /src/plugins/saved_objects/ @elastic/kibana-core
#CC# /x-pack/plugins/cloud/ @elastic/kibana-core
#CC# /x-pack/plugins/features/ @elastic/kibana-core
Expand All @@ -1848,7 +1848,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib

# Kibana Localization
/src/dev/i18n_tools/ @elastic/kibana-localization @elastic/kibana-core
/src/core/public/i18n/ @elastic/kibana-localization @elastic/kibana-core
/src/core/packages/core/public/i18n/ @elastic/kibana-localization @elastic/kibana-core
#CC# /x-pack/platform/plugins/private/translations/ @elastic/kibana-localization @elastic/kibana-core

# Kibana Platform Security
Expand Down Expand Up @@ -1887,7 +1887,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/.github/workflows/codeql.yml @elastic/kibana-security
/.github/workflows/codeql-stats.yml @elastic/kibana-security
/src/dev/eslint/security_eslint_rule_tests.ts @elastic/kibana-security
/src/core/server/integration_tests/config/check_dynamic_config.test.ts @elastic/kibana-security
/src/core/packages/core/server/integration_tests/config/check_dynamic_config.test.ts @elastic/kibana-security
/src/plugins/telemetry/server/config/telemetry_labels.ts @elastic/kibana-security
/packages/kbn-std/src/is_internal_url.test.ts @elastic/kibana-core @elastic/kibana-security
/packages/kbn-std/src/is_internal_url.ts @elastic/kibana-core @elastic/kibana-security
Expand Down
2 changes: 1 addition & 1 deletion STYLEGUIDE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ 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/core/public/styles/core_app/_globals_v8light.scss).
& Kibana invisibles (SASS variables, mixins, functions) from the [`globals_[theme].scss` file](src/core/packages/core/public/styles/core_app/_globals_v8light.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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"@kbn/content-management-utils": "link:packages/kbn-content-management-utils",
"@kbn/controls-example-plugin": "link:examples/controls_example",
"@kbn/controls-plugin": "link:src/plugins/controls",
"@kbn/core": "link:src/core",
"@kbn/core": "link:src/core/packages/core",
"@kbn/core-analytics-browser": "link:packages/core/analytics/core-analytics-browser",
"@kbn/core-analytics-browser-internal": "link:packages/core/analytics/core-analytics-browser-internal",
"@kbn/core-analytics-server": "link:packages/core/analytics/core-analytics-server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface AppMountParameters<HistoryLocationState = unknown> {
* import ReactDOM from 'react-dom';
* import { Router, Route } from 'react-router-dom';
*
* import { CoreStart, AppMountParameters } from 'src/core/public';
* import { CoreStart, AppMountParameters } from '@kbn/core/public';
* import { MyPluginDepsStart } from './plugin';
*
* export renderApp = ({ element, history }: AppMountParameters) => {
Expand Down Expand Up @@ -117,7 +117,7 @@ export interface AppMountParameters<HistoryLocationState = unknown> {
* import ReactDOM from 'react-dom';
* import { BrowserRouter, Route } from 'react-router-dom';
*
* import { CoreStart, AppMountParameters } from 'src/core/public';
* import { CoreStart, AppMountParameters } from '@kbn/core/public';
* import { MyPluginDepsStart } from './plugin';
*
* export renderApp = ({ appBasePath, element }: AppMountParameters) => {
Expand Down Expand Up @@ -152,7 +152,7 @@ export interface AppMountParameters<HistoryLocationState = unknown> {
* import ReactDOM from 'react-dom';
* import { BrowserRouter, Route } from 'react-router-dom';
*
* import { CoreStart, AppMountParameters } from 'src/core/public';
* import { CoreStart, AppMountParameters } from '@kbn/core/public';
* import { MyPluginDepsStart } from './plugin';
*
* export renderApp = ({ element, history, onAppLeave }: AppMountParameters) => {
Expand Down Expand Up @@ -190,7 +190,7 @@ export interface AppMountParameters<HistoryLocationState = unknown> {
* import ReactDOM from 'react-dom';
* import { BrowserRouter, Route } from 'react-router-dom';
*
* import { CoreStart, AppMountParameters } from 'src/core/public';
* import { CoreStart, AppMountParameters } from '@kbn/core/public';
* import { MyPluginDepsStart } from './plugin';
*
* export renderApp = ({ element, history, setHeaderActionMenu }: AppMountParameters) => {
Expand All @@ -216,7 +216,7 @@ export interface AppMountParameters<HistoryLocationState = unknown> {
* import React from 'react';
* import ReactDOM from 'react-dom';
*
* import { AppMountParameters } from 'src/core/public';
* import { AppMountParameters } from '@kbn/core/public';
* import { wrapWithTheme } from 'src/plugins/kibana_react';
* import { MyApp } from './app';
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ export interface DeprecationDetailsMessage {
export interface BaseDeprecationDetails {
/**
* The title of the deprecation.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
*/
title: string;
/**
* The description message to be displayed for the deprecation.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
*/
message: string | DeprecationDetailsMessage | Array<string | DeprecationDetailsMessage>;
/**
Expand Down Expand Up @@ -72,7 +70,7 @@ export interface BaseDeprecationDetails {
* Specify a list of manual steps users need to follow to
* fix the deprecation before upgrade. Required even if an API
* corrective action is set in case the API fails.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
* Check the README for writing deprecations in `src/core/packages/core/server/deprecations/README.mdx`
*/
manualSteps: string[];
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { KibanaRequest } from '@kbn/core-http-server';
*
* @example
* ```ts
* import { DeprecationsDetails, GetDeprecationsContext, CoreSetup } from 'src/core/server';
* import { DeprecationsDetails, GetDeprecationsContext, CoreSetup } from '@kbn/core/server';
* import { i18n } from '@kbn/i18n';
*
* async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecationsContext): Promise<DeprecationsDetails[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/http/core-http-server/src/router/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface RouteDeprecationInfo {
documentationUrl: string;
/**
* The description message to be displayed for the deprecation.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
* Check the README for writing deprecations in `src/core/packages/core/server/deprecations/README.mdx`
*/
message?: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function bootstrap({ configs, cliArgs, applyConfigOverrides }: Boot
return;
}

// `bootstrap` is exported from the `src/core/server/index` module,
// `bootstrap` is exported from the `src/core/packages/core/server/index` module,
// meaning that any test importing, implicitly or explicitly, anything concrete
// from `core/server` will load `dev-utils`. As some tests are mocking the `fs` package,
// and as `REPO_ROOT` is initialized on the fly when importing `dev-utils` and requires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function convertNamespaceType(doc: SavedObjectUnsanitizedDoc) {
id: `${namespace}:${type}:${originId}`,
type: LEGACY_URL_ALIAS_TYPE,
attributes: {
// NOTE TO MAINTAINERS: If a saved object migration is added in `src/core/server/saved_objects/object_types/registration.ts`, these
// NOTE TO MAINTAINERS: If a saved object migration is added in `src/core/packages/core/server/saved_objects/object_types/registration.ts`, these
// values must be updated accordingly. That's because a user can upgrade Kibana from 7.17 to 8.x, and any defined migrations will not
// be applied to aliases that are created during the conversion process.
sourceId: originId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const legacyUrlAliasType: SavedObjectsType = {
hidden: false,
migrations: {
// NOTE TO MAINTAINERS: If you add a migration here, be sure to update the alias creation code in the document migrator accordingly,
// see: `src/core/server/saved_objects/migrations/core/document_migrator.ts`
// see: `src/core/packages/core/server/saved_objects/migrations/core/document_migrator.ts`
'8.2.0': (doc) => {
// In version 8.2.0 we added the "purpose" field. Any aliases created before this were created because of saved object conversion.
const purpose: LegacyUrlAlias['purpose'] = 'savedObjectConversion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type { SavedObjectsExtensions } from './extensions/extensions';
*
* @example
* ```ts
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
* import { SavedObjectsClient, CoreSetup } from '@kbn/core/server';
*
* export class Plugin() {
* setup: (core: CoreSetup) => {
Expand All @@ -50,7 +50,7 @@ import type { SavedObjectsExtensions } from './extensions/extensions';
*
* @example
* ```ts
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
* import { SavedObjectsClient, CoreSetup } from '@kbn/core/server';
* import { mySoType } from './saved_objects'
*
* export class Plugin() {
Expand Down Expand Up @@ -93,7 +93,7 @@ export interface SavedObjectsServiceSetup {
* @example
* ```ts
* // src/plugins/my_plugin/server/saved_objects/my_type.ts
* import { SavedObjectsType } from 'src/core/server';
* import { SavedObjectsType } from '@kbn/core/server';
* import * as migrations from './migrations';
* import * as schemas from './schemas';
*
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface SavedObjectsServiceSetup {
* };
*
* // src/plugins/my_plugin/server/plugin.ts
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
* import { SavedObjectsClient, CoreSetup } from '@kbn/core/server';
* import { myType } from './saved_objects';
*
* export class Plugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type ServiceStatusLevelId = 'available' | 'degraded' | 'unavailable' | 'c
* represent higher severities. Note that the default `Array.prototype.sort` implementation does not correctly sort
* these values.
*
* A snapshot serializer is available in `src/core/server/test_utils` to ease testing of these values with Jest.
* A snapshot serializer is available in `src/core/packages/core/server/test_utils` to ease testing of these values with Jest.
*
* @public
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class CoreUsageDataService

private async getSavedObjectAliasUsageData(elasticsearch: ElasticsearchServiceStart) {
// Note: this agg can be changed to use `savedObjectsRepository.find` in the future after `filters` is supported.
// See src/core/server/saved_objects/service/lib/aggregations/aggs_types/bucket_aggs.ts for supported aggregations.
// See src/core/packages/core/server/saved_objects/service/lib/aggregations/aggs_types/bucket_aggs.ts for supported aggregations.
const resp = await elasticsearch.client.asInternalUser.search<
unknown,
{ aliases: UsageDataAggs }
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-import-resolver/src/import_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export class ImportResolver {
private adaptReq(req: string, dirname: string): string | undefined {
// handle typescript aliases
if (req === 'kibana/public') {
return this.adaptReq('src/core/public', dirname);
return this.adaptReq('src/core/packages/core/public', dirname);
}
if (req === 'kibana/server') {
return this.adaptReq('src/core/server', dirname);
return this.adaptReq('src/core/packages/core/server', dirname);
}

// turn root-relative paths into relative paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ describe('#resolve()', () => {
});

it('resolves requests to src/', () => {
expect(resolver.resolve('src/core/public', FIXTURES_DIR)).toMatchInlineSnapshot(`
expect(resolver.resolve('src/core/packages/core/public', FIXTURES_DIR)).toMatchInlineSnapshot(`
Object {
"absolute": <absolute path>/src/core/public/index.ts,
"absolute": <absolute path>/src/core/packages/core/public/index.ts,
"type": "file",
}
`);
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function getWebpackConfig(
loaderContext,
Path.resolve(
worker.repoRoot,
`src/core/public/styles/core_app/_globals_${theme}.scss`
`src/core/packages/core/public/styles/core_app/_globals_${theme}.scss`
)
)};\n${content}`;
},
Expand Down Expand Up @@ -307,7 +307,7 @@ export function getWebpackConfig(
alias: {
core_app_image_assets: Path.resolve(
worker.repoRoot,
'src/core/public/styles/core_app/images'
'src/core/packages/core/public/styles/core_app/images'
),
vega: Path.resolve(worker.repoRoot, 'node_modules/vega/build-es5/vega.js'),
'react-dom$':
Expand Down
12 changes: 9 additions & 3 deletions packages/kbn-storybook/src/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ export default ({ config: storybookConfig }: { config: Configuration }) => {
additionalData(content: string, loaderContext: any) {
return `@import ${stringifyRequest(
loaderContext,
resolve(REPO_ROOT, 'src/core/public/styles/core_app/_globals_v8light.scss')
resolve(
REPO_ROOT,
'src/core/packages/core/public/styles/core_app/_globals_v8light.scss'
)
)};\n${content}`;
},
implementation: require('sass-embedded'),
Expand Down Expand Up @@ -162,8 +165,11 @@ export default ({ config: storybookConfig }: { config: Configuration }) => {
extensions: ['.js', '.ts', '.tsx', '.json', '.mdx'],
mainFields: ['browser', 'main'],
alias: {
core_app_image_assets: resolve(REPO_ROOT, 'src/core/public/styles/core_app/images'),
core_styles: resolve(REPO_ROOT, 'src/core/public/index.scss'),
core_app_image_assets: resolve(
REPO_ROOT,
'src/core/packages/core/public/styles/core_app/images'
),
core_styles: resolve(REPO_ROOT, 'src/core/packages/core/public/index.scss'),
vega: resolve(REPO_ROOT, 'node_modules/vega/build-es5/vega.js'),
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-test/src/jest/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import { map } from 'lodash';
import getopts from 'getopts';
import jestFlags from './jest_flags.json';

// yarn test:jest src/core/server/saved_objects
// yarn test:jest src/core/public/core_system.test.ts
// :kibana/src/core/server/saved_objects yarn test:jest
// yarn test:jest src/core/packages/core/server/saved_objects
// yarn test:jest src/core/packages/core/public/core_system.test.ts
// :kibana/src/core/packages/core/server/saved_objects yarn test:jest

export function runJest(configName = 'jest.config.js') {
const unknownFlag: string[] = [];
Expand Down
10 changes: 5 additions & 5 deletions src/core/CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ my_plugin/
```ts
// my_plugin/public/index.ts

import { PluginInitializer } from '../../src/core/public';
import { PluginInitializer } from '../../src/core/packages/core/public';
import { MyPlugin, MyPluginSetup, MyPluginStart } from './plugin';

export const plugin: PluginInitializer<MyPluginSetup, MyPluginStart> = () => new MyPlugin();
Expand All @@ -103,7 +103,7 @@ export {
```ts
// my_plugin/public/plugin.ts

import { CoreSetup, CoreStart, Plugin } from '../../src/core/public';
import { CoreSetup, CoreStart, Plugin } from '../../src/core/packages/core/public';
import { OtherPluginSetup, OtherPluginStart } from '../other_plugin';
import { ThirdPluginSetup, ThirdPluginStart } from '../third_plugin';

Expand Down Expand Up @@ -164,7 +164,7 @@ leverage this pattern.

import React from 'react';
import ReactDOM from 'react-dom';
import { CoreStart, AppMountParameters } from 'src/core/public';
import { CoreStart, AppMountParameters } from '@kbn/core/public';

import { MyAppRoot } from './components/app.ts';

Expand All @@ -184,7 +184,7 @@ export const renderApp = (
```ts
// my_plugin/public/plugin.ts

import { Plugin } from '../../src/core/public';
import { Plugin } from '../../src/core/packages/core/public';

export class MyPlugin implements Plugin {
public setup(core) {
Expand Down Expand Up @@ -328,7 +328,7 @@ The folder should contain a file per type, named after the snake_case name of th

```typescript
// src/plugins/my-plugin/server/saved_objects/my_type.ts
import { SavedObjectsType } from 'src/core/server';
import { SavedObjectsType } from '@kbn/core/server';

export const myType: SavedObjectsType = {
name: 'my-type',
Expand Down
4 changes: 2 additions & 2 deletions src/core/CORE_CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ area of Core API's and does not apply to internal types.

```ts
// -- good --
import { IRouter } from 'src/core/server';
import { IRouter } from '@kbn/core/server';

// -- bad --
import { IRouter } from 'src/core/server/http/router.ts';
import { IRouter } from 'src/core/packages/core/server/http/router.ts';
```

> Why? This is required for generating documentation from our inline
Expand Down
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 @@ -9,6 +9,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/core/public'],
rootDir: '../../../../..',
roots: ['<rootDir>/src/core/packages/core/public'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

module.exports = {
preset: '@kbn/test/jest_integration',
rootDir: '../../..',
roots: ['<rootDir>/src/core/public'],
rootDir: '../../../../..',
roots: ['<rootDir>/src/core/packages/core/public'],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 656cae1

Please sign in to comment.