1
- # Copyright Google Inc. All Rights Reserved.
2
- #
3
- # Use of this source code is governed by an MIT-style license that can be
4
- # found in the LICENSE file at https://angular.dev/license
5
-
6
- def _ts_json_schema_interface_impl (ctx ):
7
- args = [
8
- ctx .files .src [0 ].path ,
9
- ctx .outputs .ts .path ,
10
- ]
11
-
12
- ctx .actions .run (
13
- inputs = ctx .files .src + ctx .files .data ,
14
- executable = ctx .executable ._binary ,
15
- outputs = [ctx .outputs .ts ],
16
- arguments = args ,
17
- )
18
-
19
- return [DefaultInfo ()]
20
-
21
- _ts_json_schema_interface = rule (
22
- _ts_json_schema_interface_impl ,
23
- attrs = {
24
- "src" : attr .label (
25
- allow_files = [".json" ],
26
- mandatory = True ,
27
- ),
28
- "out" : attr .string (
29
- mandatory = True ,
30
- ),
31
- "data" : attr .label_list (
32
- allow_files = [".json" ],
33
- ),
34
- "_binary" : attr .label (
35
- default = Label ("//tools:quicktype_runner" ),
36
- executable = True ,
37
- cfg = "exec" ,
38
- ),
39
- },
40
- outputs = {
41
- "ts" : "%{out}" ,
42
- },
43
- )
1
+ load ("@aspect_rules_js//js:defs.bzl" , "js_run_binary" )
44
2
45
3
# Generates a TS file that contains the interface for a JSON Schema file. Takes a single `src`
46
4
# argument as input, an optional data field for reference files, and produces a
@@ -50,9 +8,12 @@ _ts_json_schema_interface = rule(
50
8
def ts_json_schema (name , src , data = []):
51
9
out = src .replace (".json" , ".ts" )
52
10
53
- _ts_json_schema_interface (
11
+ js_run_binary (
54
12
name = name + ".interface" ,
55
- src = src ,
56
- out = out ,
57
- data = data ,
13
+ outs = [out ],
14
+ srcs = [src ] + data ,
15
+ tool = "//tools:quicktype_runner" ,
16
+ progress_message = "Generating TS interface for %s" % src ,
17
+ mnemonic = "TsJsonSchema" ,
18
+ args = ["$(rootpath %s)" % src , "$(rootpath %s)" % out ],
58
19
)
0 commit comments