-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathts_json_schema.bzl
More file actions
20 lines (18 loc) · 888 Bytes
/
ts_json_schema.bzl
File metadata and controls
20 lines (18 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
# Generates a TS file that contains the interface for a JSON Schema file. Takes a single `src`
# argument as input, an optional data field for reference files, and produces a
# _ts_json_schema_interface() rule containing the typescript interface.
# The file produced will have the same name, with the extension replaced from `.json` to `.ts`.
# Any filename collision will be an error thrown by Bazel.
def ts_json_schema(name, src, data = []):
out = src.replace(".json", ".ts")
js_run_binary(
name = name + ".interface",
outs = [out],
srcs = [src] + data,
tags = ["schema"],
tool = "//tools:quicktype_runner",
progress_message = "Generating TS interface for %s" % src,
mnemonic = "TsJsonSchema",
args = ["$(rootpath %s)" % src, "$(rootpath %s)" % out],
)