convert sql_format to ts_project; move into separate folder

This commit is contained in:
Damien Elmes 2021-10-18 14:14:16 +10:00
parent 5eb1208714
commit 3d416b4a68
8 changed files with 44 additions and 30 deletions

View File

@ -4,7 +4,7 @@
load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_library", "rust_test") load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_library", "rust_test")
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script") load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
load(":rustfmt.bzl", "rustfmt_fix", "rustfmt_test") load(":rustfmt.bzl", "rustfmt_fix", "rustfmt_test")
load("//ts:sql_format.bzl", "sql_format") load("//ts/sql_format:defs.bzl", "sql_format")
# Build script # Build script
####################### #######################

View File

@ -1,13 +1,10 @@
load("//ts:prettier.bzl", "prettier", "prettier_test") load("//ts:prettier.bzl", "prettier", "prettier_test")
load("//ts:sql_format.bzl", "sql_format_setup")
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
prettier() prettier()
prettier_test() prettier_test()
sql_format_setup()
# Exported files # Exported files
################# #################

View File

@ -1,4 +1,3 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//ts:prettier.bzl", "prettier_test") load("//ts:prettier.bzl", "prettier_test")
load("//ts:eslint.bzl", "eslint_test") load("//ts:eslint.bzl", "eslint_test")
load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check")

View File

@ -1,25 +0,0 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
def sql_format_setup():
ts_library(
name = "sql_format_lib",
srcs = ["//ts:sql_format.ts"],
deps = [
"@npm//@sqltools/formatter",
"@npm//@types/node",
"@npm//@types/diff",
"@npm//diff",
],
tsconfig = "//ts:tsconfig_bin",
visibility = ["//visibility:public"],
)
def sql_format(name = "sql_format", srcs = [], **kwargs):
nodejs_test(
name = name,
entry_point = "//ts:sql_format.ts",
args = [native.package_name() + "/" + f for f in srcs],
data = ["//ts:sql_format_lib", "@npm//tslib", "@npm//diff"] + srcs,
**kwargs
)

19
ts/sql_format/BUILD.bazel Normal file
View File

@ -0,0 +1,19 @@
load("//ts:typescript.bzl", "typescript")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
_deps = [
"@npm//@sqltools/formatter",
"@npm//@types/diff",
"@npm//@types/node",
"@npm//diff",
]
typescript(
name = "sql_format_lib",
srcs = ["sql_format.ts"],
deps = _deps,
)
# a hack to allow us to define the test in a different file; there
# should be a better way
exports_files(["sql_format.ts"])

10
ts/sql_format/defs.bzl Normal file
View File

@ -0,0 +1,10 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
def sql_format(name = "sql_format", srcs = [], **kwargs):
nodejs_test(
name = name,
entry_point = "//ts/sql_format:sql_format.ts",
args = [native.package_name() + "/" + f for f in srcs],
data = ["//ts/sql_format:sql_format_lib", "@npm//tslib", "@npm//diff"] + srcs,
**kwargs
)

View File

@ -0,0 +1,14 @@
{
"extends": "../tsconfig.json",
"include": ["*"],
"references": [],
"compilerOptions": {
"types": ["node"],
// ignore missing optional modules like postcss
"skipLibCheck": true,
// ensure node can run the resulting code
"noEmitHelpers": false,
"importHelpers": false,
"module": "commonjs",
}
}