Skip to content

Commit

Permalink
IDM: Migrate core server-side core_app to package (#144075)
Browse files Browse the repository at this point in the history
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: spalger <[email protected]>
  • Loading branch information
3 people authored Nov 2, 2022
1 parent 57dce56 commit 0ba81e1
Show file tree
Hide file tree
Showing 98 changed files with 4,679 additions and 29 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ packages/core/application/core-application-browser-mocks @elastic/kibana-core
packages/core/application/core-application-common @elastic/kibana-core
packages/core/apps/core-apps-browser-internal @elastic/kibana-core
packages/core/apps/core-apps-browser-mocks @elastic/kibana-core
packages/core/apps/core-apps-server-internal @elastic/kibana-core
packages/core/base/core-base-browser-internal @elastic/kibana-core
packages/core/base/core-base-browser-mocks @elastic/kibana-core
packages/core/base/core-base-common @elastic/kibana-core
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"@kbn/core-application-common": "link:bazel-bin/packages/core/application/core-application-common",
"@kbn/core-apps-browser-internal": "link:bazel-bin/packages/core/apps/core-apps-browser-internal",
"@kbn/core-apps-browser-mocks": "link:bazel-bin/packages/core/apps/core-apps-browser-mocks",
"@kbn/core-apps-server-internal": "link:bazel-bin/packages/core/apps/core-apps-server-internal",
"@kbn/core-base-browser-internal": "link:bazel-bin/packages/core/base/core-base-browser-internal",
"@kbn/core-base-browser-mocks": "link:bazel-bin/packages/core/base/core-base-browser-mocks",
"@kbn/core-base-common": "link:bazel-bin/packages/core/base/core-base-common",
Expand Down
2 changes: 2 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ filegroup(
"//packages/core/application/core-application-common:build",
"//packages/core/apps/core-apps-browser-internal:build",
"//packages/core/apps/core-apps-browser-mocks:build",
"//packages/core/apps/core-apps-server-internal:build",
"//packages/core/base/core-base-browser-internal:build",
"//packages/core/base/core-base-browser-mocks:build",
"//packages/core/base/core-base-common:build",
Expand Down Expand Up @@ -386,6 +387,7 @@ filegroup(
"//packages/core/application/core-application-common:build_types",
"//packages/core/apps/core-apps-browser-internal:build_types",
"//packages/core/apps/core-apps-browser-mocks:build_types",
"//packages/core/apps/core-apps-server-internal:build_types",
"//packages/core/base/core-base-browser-internal:build_types",
"//packages/core/base/core-base-browser-mocks:build_types",
"//packages/core/base/core-base-common:build_types",
Expand Down
140 changes: 140 additions & 0 deletions packages/core/apps/core-apps-server-internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_DIRNAME = "core-apps-server-internal"
PKG_REQUIRE_NAME = "@kbn/core-apps-server-internal"

SOURCE_FILES = glob(
[
"**/*.ts",
"src/**/*.css",
"src/**/*.ttf",
"src/**/*.woff",
"src/**/*.woff2",
"src/**/*.ico",
"src/**/*.png",
"src/**/*.svg",
],
exclude = [
"**/*.config.js",
"**/*.mock.*",
"**/*.test.*",
"**/*.stories.*",
"**/__snapshots__/**",
"**/integration_tests/**",
"**/mocks/**",
"**/scripts/**",
"**/storybook/**",
"**/test_fixtures/**",
"**/test_helpers/**",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

RUNTIME_DEPS = [
"@npm//elastic-apm-node",
"@npm//lru-cache",
"@npm//mime-types",
"//packages/kbn-config",
"//packages/kbn-config-schema",
"//packages/kbn-utils",
"//packages/kbn-logging",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"//packages/core/base/core-base-server-internal",
"//packages/core/lifecycle/core-lifecycle-server-internal",
"//packages/core/plugins/core-plugins-base-server-internal",
]

TYPES_DEPS = [
"@npm//elastic-apm-node",
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/lru-cache",
"@npm//@types/mime-types",
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
"//packages/kbn-ui-shared-deps-src:npm_module_types",
"//packages/kbn-utils:npm_module_types",
"//packages/kbn-logging:npm_module_types",
"//packages/core/base/core-base-server-internal:npm_module_types",
"//packages/core/http/core-http-resources-server:npm_module_types",
"//packages/core/http/core-http-server:npm_module_types",
"//packages/core/lifecycle/core-lifecycle-server-internal:npm_module_types",
"//packages/core/plugins/core-plugins-base-server-internal:npm_module_types",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
additional_args = [
"--copy-files",
"--quiet"
],
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)

ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
emit_declaration_only = True,
out_dir = "target_types",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

js_library(
name = "npm_module_types",
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)

filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)

pkg_npm(
name = "build_types",
deps = [":npm_module_types"],
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions packages/core/apps/core-apps-server-internal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-apps-server-internal

This package contains the internal types and implementation of Core's server-side `coreApps` service.
15 changes: 15 additions & 0 deletions packages/core/apps/core-apps-server-internal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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.
*/

export { CoreAppsService } from './src';
export type {
InternalCoreAppsServiceRequestHandlerContext,
InternalCoreAppsServiceRouter,
} from './src';
// only used by integration tests
export { FileHashCache, registerRouteForBundle } from './src';
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
* Side Public License, v 1.
*/

export { CoreApp } from './core_app';
module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/apps/core-apps-server-internal'],
};
7 changes: 7 additions & 0 deletions packages/core/apps/core-apps-server-internal/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "shared-common",
"id": "@kbn/core-apps-server-internal",
"owner": "@elastic/kibana-core",
"runtimeDeps": [],
"typeDeps": [],
}
9 changes: 9 additions & 0 deletions packages/core/apps/core-apps-server-internal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@kbn/core-apps-server-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"author": "Kibana Core",
"license": "SSPL-1.0 OR Elastic License 2.0",
"types": "./target_types/index.d.ts"
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0ba81e1

Please sign in to comment.