Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com>
118 lines
2 KiB
Python
118 lines
2 KiB
Python
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-plugin-generator"
|
|
PKG_REQUIRE_NAME = "@kbn/plugin-generator"
|
|
|
|
SOURCE_FILES = glob(
|
|
[
|
|
"src/**/*.ts",
|
|
],
|
|
exclude = [
|
|
"**/integration_tests/**/*",
|
|
],
|
|
)
|
|
|
|
SRCS = SOURCE_FILES
|
|
|
|
filegroup(
|
|
name = "srcs",
|
|
srcs = SRCS,
|
|
)
|
|
|
|
filegroup(
|
|
name = "template",
|
|
srcs = glob(
|
|
[
|
|
"template/**/*",
|
|
],
|
|
),
|
|
)
|
|
|
|
NPM_MODULE_EXTRA_FILES = [
|
|
"package.json",
|
|
"README.md",
|
|
":template",
|
|
]
|
|
|
|
RUNTIME_DEPS = [
|
|
"//packages/kbn-utils",
|
|
"//packages/kbn-dev-utils",
|
|
"@npm//del",
|
|
"@npm//ejs",
|
|
"@npm//execa",
|
|
"@npm//globby",
|
|
"@npm//inquirer",
|
|
"@npm//minimatch",
|
|
"@npm//prettier",
|
|
"@npm//vinyl-fs",
|
|
]
|
|
|
|
TYPES_DEPS = [
|
|
"//packages/kbn-utils",
|
|
"//packages/kbn-dev-utils",
|
|
"@npm//del",
|
|
"@npm//execa",
|
|
"@npm//globby",
|
|
"@npm//@types/ejs",
|
|
"@npm//@types/inquirer",
|
|
"@npm//@types/jest",
|
|
"@npm//@types/minimatch",
|
|
"@npm//@types/node",
|
|
"@npm//@types/prettier",
|
|
"@npm//@types/vinyl-fs",
|
|
]
|
|
|
|
jsts_transpiler(
|
|
name = "target_node",
|
|
srcs = SRCS,
|
|
build_pkg_name = package_name(),
|
|
)
|
|
|
|
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,
|
|
declaration_map = True,
|
|
emit_declaration_only = True,
|
|
out_dir = "target_types",
|
|
source_map = True,
|
|
root_dir = "src",
|
|
tsconfig = ":tsconfig",
|
|
)
|
|
|
|
js_library(
|
|
name = PKG_BASE_NAME,
|
|
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 = [
|
|
":%s" % PKG_BASE_NAME,
|
|
]
|
|
)
|
|
|
|
filegroup(
|
|
name = "build",
|
|
srcs = [
|
|
":npm_module",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|