From 62086281b46b9b9ba9c6bffa4cb85b8e29f9be46 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 13 May 2021 20:39:15 +0100 Subject: [PATCH] chore(NA): moving @kbn/docs-utils into bazel (#100051) --- .../monorepo-packages.asciidoc | 1 + package.json | 2 +- packages/BUILD.bazel | 1 + packages/kbn-docs-utils/BUILD.bazel | 88 +++++++++++++++++++ packages/kbn-docs-utils/package.json | 4 - packages/kbn-docs-utils/tsconfig.json | 3 +- yarn.lock | 2 +- 7 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 packages/kbn-docs-utils/BUILD.bazel diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index 1e7a95b83dd67..7265cd415949c 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -74,6 +74,7 @@ yarn kbn watch-bazel - @kbn/config-schema - @kbn/crypto - @kbn/dev-utils +- @kbn/docs-utils - @kbn/es - @kbn/eslint-import-resolver-kibana - @kbn/eslint-plugin-eslint diff --git a/package.json b/package.json index d46617f2a6f2a..c04face1233ae 100644 --- a/package.json +++ b/package.json @@ -448,7 +448,7 @@ "@kbn/babel-preset": "link:bazel-bin/packages/kbn-babel-preset/npm_module", "@kbn/cli-dev-mode": "link:packages/kbn-cli-dev-mode", "@kbn/dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module", - "@kbn/docs-utils": "link:packages/kbn-docs-utils", + "@kbn/docs-utils": "link:bazel-bin/packages/kbn-docs-utils/npm_module", "@kbn/es": "link:bazel-bin/packages/kbn-es/npm_module", "@kbn/es-archiver": "link:packages/kbn-es-archiver", "@kbn/eslint-import-resolver-kibana": "link:bazel-bin/packages/kbn-eslint-import-resolver-kibana/npm_module", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 2ae04e02cffd2..c3d08ad49daea 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -16,6 +16,7 @@ filegroup( "//packages/kbn-config-schema:build", "//packages/kbn-crypto:build", "//packages/kbn-dev-utils:build", + "//packages/kbn-docs-utils:build", "//packages/kbn-es:build", "//packages/kbn-eslint-import-resolver-kibana:build", "//packages/kbn-eslint-plugin-eslint:build", diff --git a/packages/kbn-docs-utils/BUILD.bazel b/packages/kbn-docs-utils/BUILD.bazel new file mode 100644 index 0000000000000..e72d83851f5d2 --- /dev/null +++ b/packages/kbn-docs-utils/BUILD.bazel @@ -0,0 +1,88 @@ +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-docs-utils" +PKG_REQUIRE_NAME = "@kbn/docs-utils" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + "**/__fixtures__/**", + "**/snapshots/**", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +SRC_DEPS = [ + "//packages/kbn-config", + "//packages/kbn-dev-utils", + "//packages/kbn-utils", + "@npm//dedent", + "@npm//ts-morph", +] + +TYPES_DEPS = [ + "@npm//@types/dedent", + "@npm//@types/jest", + "@npm//@types/node", +] + +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 = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_BASE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = [":tsc"] + DEPS, + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [ + ":%s" % PKG_BASE_NAME, + ] +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-docs-utils/package.json b/packages/kbn-docs-utils/package.json index 27d38d2d8ed4f..b2a52b2d1f78e 100644 --- a/packages/kbn-docs-utils/package.json +++ b/packages/kbn-docs-utils/package.json @@ -7,9 +7,5 @@ "types": "target/index.d.ts", "kibana": { "devOnly": true - }, - "scripts": { - "kbn:bootstrap": "../../node_modules/.bin/tsc", - "kbn:watch": "../../node_modules/.bin/tsc --watch" } } \ No newline at end of file diff --git a/packages/kbn-docs-utils/tsconfig.json b/packages/kbn-docs-utils/tsconfig.json index 6f4a6fa2af8a5..9868c8b3d2bb4 100644 --- a/packages/kbn-docs-utils/tsconfig.json +++ b/packages/kbn-docs-utils/tsconfig.json @@ -1,11 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, + "incremental": true, "outDir": "./target", "target": "ES2019", "declaration": true, "declarationMap": true, + "rootDir": "src", "sourceMap": true, "sourceRoot": "../../../../packages/kbn-docs-utils/src", "types": [ diff --git a/yarn.lock b/yarn.lock index 69d5c9553a3b6..b8b4e54d25dcc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2634,7 +2634,7 @@ version "0.0.0" uid "" -"@kbn/docs-utils@link:packages/kbn-docs-utils": +"@kbn/docs-utils@link:bazel-bin/packages/kbn-docs-utils/npm_module": version "0.0.0" uid ""