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

chore(NA): moving @kbn/utility-types into bazel #97151

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ yarn kbn watch-bazel
- @kbn/apm-utils
- @kbn/config-schema
- @kbn/tinymath
- @kbn/utility-types

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath/npm_module",
"@kbn/ui-framework": "link:packages/kbn-ui-framework",
"@kbn/ui-shared-deps": "link:packages/kbn-ui-shared-deps",
"@kbn/utility-types": "link:packages/kbn-utility-types",
"@kbn/utility-types": "link:bazel-bin/packages/kbn-utility-types/npm_module",
"@kbn/utils": "link:packages/kbn-utils",
"@loaders.gl/core": "^2.3.1",
"@loaders.gl/json": "^2.3.1",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ filegroup(
"//packages/kbn-apm-utils:build",
"//packages/kbn-config-schema:build",
"//packages/kbn-tinymath:build",
"//packages/kbn-utility-types:build",
],
)
80 changes: 80 additions & 0 deletions packages/kbn-utility-types/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")

PKG_BASE_NAME = "kbn-utility-types"
PKG_REQUIRE_NAME = "@kbn/utility-types"

SOURCE_FILES = glob([
"jest/index.ts",
"index.ts"
])

SRCS = SOURCE_FILES

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

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

SRC_DEPS = [
"@npm//utility-types",
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
]

DEPS = SRC_DEPS + TYPES_DEPS

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

ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = ".",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_BASE_NAME,
srcs = [],
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
6 changes: 1 addition & 5 deletions packages/kbn-utility-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"devOnly": false
},
"scripts": {
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "../../node_modules/.bin/tsc",
"kbn:watch": "../../node_modules/.bin/tsc --watch",
"test": "../../node_modules/.bin/tsd",
"clean": "../../node_modules/.bin/del target"
"test": "../../node_modules/.bin/tsd tsd_tests"
}
}
6 changes: 3 additions & 3 deletions packages/kbn-utility-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"incremental": true,
"outDir": "./target",
"declarationDir": "./target",
"stripInternal": true,
"declaration": true,
"declarationMap": true,
"rootDir": "./",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-utility-types",
"types": [
Expand All @@ -17,6 +17,6 @@
"include": [
"index.ts",
"jest/**/*",
"test-d/**/*"
"tsd_tests/**/*"
]
}
9 changes: 9 additions & 0 deletions packages/kbn-utility-types/tsd_tests/empty.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

// This is just an empty mock file to provide a workaround to run tsd correctly isolated
9 changes: 9 additions & 0 deletions packages/kbn-utility-types/tsd_tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"types": "empty.d.ts",
"tsd": {
"directory": "test_d",
"compilerOptions": {
"rootDir": "../"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { MethodKeysOf } from '../index';
import { MethodKeysOf } from '../../index';

class Test {
public name: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicContract } from '../index';
import { PublicContract } from '../../index';

class Test {
public str: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicKeys } from '../index';
import { PublicKeys } from '../../index';

class Test {
public str: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable, expectNotAssignable } from 'tsd';
import { PublicMethodsOf } from '../index';
import { PublicMethodsOf } from '../../index';

class Test {
public name: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { ShallowPromise } from '../index';
import { ShallowPromise } from '../../index';

type P1 = ShallowPromise<string>;
type P2 = ShallowPromise<ShallowPromise<string>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnionToIntersection } from '../index';
import { UnionToIntersection } from '../../index';

type INTERSECTED = UnionToIntersection<{ foo: 'bar' } | { baz: 'qux' }>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnwrapObservable, ObservableLike } from '../index';
import { UnwrapObservable, ObservableLike } from '../../index';

type STRING = UnwrapObservable<ObservableLike<string>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnwrapPromise } from '../index';
import { UnwrapPromise } from '../../index';

type STRING = UnwrapPromise<Promise<string>>;
type TUPLE = UnwrapPromise<Promise<[number, number]>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Values } from '../index';
import { Values } from '../../index';

// Arrays
type STRING = Values<string[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Writable } from '../index';
import { Writable } from '../../index';

type WritableArray = Writable<readonly string[]>;
expectAssignable<WritableArray>(['1']);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/server/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ElasticsearchClient } from 'kibana/server';
import { DeeplyMockedKeys } from 'packages/kbn-utility-types/target/jest';
import { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import { loggingSystemMock, elasticsearchServiceMock } from '../../../../../src/core/server/mocks';
import {
AlertServiceContract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock('./common', () => {
});

import { ResponseError } from '@elastic/elasticsearch/lib/errors';
import type { DeeplyMockedKeys } from 'packages/kbn-utility-types/target/jest';
import type { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import type { ElasticsearchClient, SavedObject, SavedObjectsClientContract } from 'kibana/server';

import { ElasticsearchAssetType } from '../../../../types';
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@
version "0.0.0"
uid ""

"@kbn/utility-types@link:packages/kbn-utility-types":
"@kbn/utility-types@link:bazel-bin/packages/kbn-utility-types/npm_module":
version "0.0.0"
uid ""

Expand Down