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

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

* chore(NA): solve ts config errors

Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com>
This commit is contained in:
Kibana Machine 2021-04-14 23:38:45 -04:00 committed by GitHub
parent b338c69e28
commit 9b326c67c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 128 additions and 22 deletions

View file

@ -65,4 +65,5 @@ yarn kbn watch-bazel
- @kbn/apm-utils
- @kbn/config-schema
- @kbn/tinymath
- @kbn/utility-types

View file

@ -138,7 +138,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",

View file

@ -7,5 +7,6 @@ filegroup(
"//packages/kbn-apm-utils:build",
"//packages/kbn-config-schema:build",
"//packages/kbn-tinymath:build",
"//packages/kbn-utility-types:build",
],
)

View file

@ -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"],
)

View file

@ -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"
}
}

View file

@ -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": [
@ -17,6 +17,6 @@
"include": [
"index.ts",
"jest/**/*",
"test-d/**/*"
"tsd_tests/**/*"
]
}

View file

@ -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

View file

@ -0,0 +1,9 @@
{
"types": "empty.d.ts",
"tsd": {
"directory": "test_d",
"compilerOptions": {
"rootDir": "../"
}
}
}

View file

@ -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 = '';

View file

@ -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 = '';

View file

@ -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 = '';

View file

@ -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 = '';

View file

@ -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>>;

View file

@ -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' }>;

View file

@ -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>>;

View file

@ -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]>>;

View file

@ -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[]>;

View file

@ -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']);

View file

@ -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,

View file

@ -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';

View file

@ -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 ""