2020-11-01 05:26:58 +01:00
|
|
|
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
|
|
|
load("//ts:prettier.bzl", "prettier_test")
|
|
|
|
load("//ts:eslint.bzl", "eslint_test")
|
2021-03-20 01:22:06 +01:00
|
|
|
load("//ts:protobuf.bzl", "protobufjs_library")
|
2021-04-12 06:40:05 +02:00
|
|
|
load("@npm//jest-cli:index.bzl", "jest_test")
|
2020-11-01 05:26:58 +01:00
|
|
|
|
|
|
|
# Protobuf
|
|
|
|
#############
|
|
|
|
|
2021-03-20 01:22:06 +01:00
|
|
|
protobufjs_library(
|
2020-11-01 05:26:58 +01:00
|
|
|
name = "backend_proto",
|
2021-03-20 01:22:06 +01:00
|
|
|
proto = "//rslib:backend_proto_lib",
|
2020-11-01 05:26:58 +01:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
2021-03-26 00:40:41 +01:00
|
|
|
# Translations
|
|
|
|
################
|
|
|
|
|
|
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
|
|
|
load("@py_deps//:requirements.bzl", "requirement")
|
|
|
|
|
|
|
|
py_binary(
|
|
|
|
name = "genfluent",
|
|
|
|
srcs = [
|
|
|
|
"genfluent.py",
|
|
|
|
],
|
|
|
|
deps = [
|
|
|
|
requirement("black"),
|
|
|
|
requirement("stringcase"),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "fluent_gen",
|
2021-03-26 11:23:43 +01:00
|
|
|
outs = ["i18n.ts"],
|
2021-03-26 00:40:41 +01:00
|
|
|
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $@",
|
|
|
|
tools = [
|
|
|
|
"genfluent",
|
|
|
|
"//rslib/i18n:strings.json",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
# Anki Library
|
|
|
|
################
|
|
|
|
|
|
|
|
ts_library(
|
|
|
|
name = "lib",
|
2021-04-12 06:40:05 +02:00
|
|
|
srcs = glob(
|
|
|
|
["**/*.ts"],
|
|
|
|
exclude = ["*.test.ts"],
|
|
|
|
) + [":i18n.ts"],
|
2020-11-01 05:26:58 +01:00
|
|
|
data = [
|
|
|
|
"backend_proto",
|
|
|
|
],
|
2020-11-05 02:01:30 +01:00
|
|
|
module_name = "anki",
|
2020-11-01 05:26:58 +01:00
|
|
|
tsconfig = "//:tsconfig.json",
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
"backend_proto",
|
|
|
|
"@npm//@fluent/bundle",
|
|
|
|
"@npm//@types/long",
|
|
|
|
"@npm//intl-pluralrules",
|
|
|
|
"@npm//tslib",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
################
|
|
|
|
|
|
|
|
prettier_test(
|
2020-11-12 11:11:40 +01:00
|
|
|
name = "format_check",
|
2020-11-01 05:26:58 +01:00
|
|
|
srcs = glob(["*.ts"]),
|
|
|
|
)
|
|
|
|
|
|
|
|
eslint_test(
|
|
|
|
name = "eslint",
|
|
|
|
srcs = glob(["*.ts"]),
|
|
|
|
)
|
2021-04-12 06:40:05 +02:00
|
|
|
|
|
|
|
ts_library(
|
|
|
|
name = "test_lib",
|
|
|
|
srcs = glob(["*.test.ts"]),
|
|
|
|
tsconfig = "//ts:tsconfig.json",
|
|
|
|
deps = [
|
|
|
|
":lib",
|
|
|
|
"@npm//@types/jest",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
jest_test(
|
|
|
|
name = "test",
|
|
|
|
args = [
|
|
|
|
"--no-cache",
|
|
|
|
"--no-watchman",
|
|
|
|
"--ci",
|
|
|
|
"--colors",
|
|
|
|
"--config",
|
|
|
|
"$(location //ts:jest.config.js)",
|
|
|
|
],
|
|
|
|
data = [
|
|
|
|
":test_lib",
|
|
|
|
"//ts:jest.config.js",
|
|
|
|
"//ts:package.json",
|
|
|
|
"@npm//protobufjs",
|
|
|
|
],
|
2021-03-28 12:34:10 +02:00
|
|
|
target_compatible_with = select({
|
|
|
|
"@platforms//os:osx": [],
|
|
|
|
"@platforms//os:linux": [],
|
|
|
|
"//conditions:default": ["@platforms//os:linux"],
|
|
|
|
}),
|
2021-04-12 06:40:05 +02:00
|
|
|
)
|