Skip to content

Commit

Permalink
chore(NA): moving @kbn/logging to babel transpiler (#108702)
Browse files Browse the repository at this point in the history
* chore(NA): moving @kbn/logging to babel transpiler

* chore(NA): fix imports for @kbn/logging

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
mistic and kibanamachine committed Aug 20, 2021
1 parent 9c24e8f commit 9fb152a
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-config/src/config_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { mockApplyDeprecations, mockedChangedPaths } from './config_service.test
import { rawConfigServiceMock } from './raw/raw_config_service.mock';

import { schema } from '@kbn/config-schema';
import { MockedLogger, loggerMock } from '@kbn/logging/target/mocks';
import { MockedLogger, loggerMock } from '@kbn/logging/mocks';

import { ConfigService, Env, RawPackageInfo } from '.';

Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-logging/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
20 changes: 14 additions & 6 deletions packages/kbn-logging/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-logging"
PKG_REQUIRE_NAME = "@kbn/logging"
Expand All @@ -21,20 +22,26 @@ filegroup(
)

NPM_MODULE_EXTRA_FILES = [
"mocks/package.json",
"package.json",
"README.md"
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-std"
]

TYPES_DEPS = [
"//packages/kbn-std",
"@npm//@types/jest",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -46,13 +53,14 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -61,7 +69,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-logging/mocks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"private": true,
"main": "../target_node/mocks/index.js",
"types": "../target_types/mocks/index.d.ts"
}
4 changes: 2 additions & 2 deletions packages/kbn-logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts"
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts"
}
5 changes: 3 additions & 2 deletions packages/kbn-logging/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "target",
"stripInternal": false,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-logging/src",
"stripInternal": false,
"types": [
"jest",
"node"
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/integration_tests/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { loggingSystemMock } from '../../logging/logging_system.mock';
import { createHttpServer } from '../test_utils';
import { HttpService } from '../http_service';
import { Router } from '../router';
import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';

let server: HttpService;
let logger: ReturnType<typeof loggingSystemMock.create>;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/logging/logger.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* Side Public License, v 1.
*/

export { loggerMock } from '@kbn/logging/target/mocks';
export type { MockedLogger } from '@kbn/logging/target/mocks';
export { loggerMock } from '@kbn/logging/mocks';
export type { MockedLogger } from '@kbn/logging/mocks';
2 changes: 1 addition & 1 deletion src/core/server/metrics/collectors/cgroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import mockFs from 'mock-fs';
import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import { OsCgroupMetricsCollector } from './cgroup';

describe('OsCgroupMetricsCollector', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/metrics/collectors/os.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

jest.mock('getos', () => (cb: Function) => cb(null, { dist: 'distrib', release: 'release' }));

import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import os from 'os';
import { cgroupCollectorMock } from './os.test.mocks';
import { OsMetricsCollector } from './os';
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/metrics/ops_metrics_collector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import {
mockOsCollector,
mockProcessCollector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { MockedLogger, loggerMock } from '@kbn/logging/target/mocks';
import { MockedLogger, loggerMock } from '@kbn/logging/mocks';
import { TaskRunnerFactory } from '../task_runner';
import { RuleTypeRegistry, ConstructorOptions } from '../rule_type_registry';
import { taskManagerMock } from '../../../task_manager/server/mocks';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/server/services/cases/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
SavedObjectsUpdateResponse,
} from 'kibana/server';
import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server';
import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import { getNoneCaseConnector, CONNECTOR_ID_REFERENCE_NAME } from '../../common';
import { CasesService } from '.';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
SavedObjectsUpdateResponse,
} from 'kibana/server';
import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server';
import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import { CaseConfigureService } from '.';
import { ESCasesConfigureAttributes } from './types';
import { getNoneCaseConnector, CONNECTOR_ID_REFERENCE_NAME } from '../../common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import {
elasticsearchServiceMock,
savedObjectsClientMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { schema } from '@kbn/config-schema';
import { ALERT_DURATION, ALERT_STATUS, ALERT_UUID } from '@kbn/rule-data-utils';
import { loggerMock } from '@kbn/logging/target/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import { castArray, omit, mapValues } from 'lodash';
import { RuleDataClient } from '../rule_data_client';
import { createRuleDataClientMock } from '../rule_data_client/rule_data_client.mock';
Expand Down

0 comments on commit 9fb152a

Please sign in to comment.