| // Copyright 2020 Google LLC | |
| // | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| // Program to generate TypeScript definition files for Golang structs that are | |
| // serialized to JSON for the web UI. | |
| // | |
| //go:generate bazelisk run --config=mayberemote //:go -- run . -o ../../../modules/json/index.ts | |
| package main | |
| import ( | |
| "flag" | |
| "io" | |
| "go.skia.org/infra/go/go2ts" | |
| "go.skia.org/infra/go/sklog" | |
| "go.skia.org/infra/go/util" | |
| "go.skia.org/infra/tree_status/go/types" | |
| ) | |
| func main() { | |
| var outputPath = flag.String("o", "", "Path to the output TypeScript file.") | |
| flag.Parse() | |
| generator := go2ts.New() | |
| generator.AddMultiple( | |
| types.AutorollerSnapshot{}, | |
| types.Status{}, | |
| ) | |
| err := util.WithWriteFile(*outputPath, func(w io.Writer) error { | |
| return generator.Render(w) | |
| }) | |
| if err != nil { | |
| sklog.Fatal(err) | |
| } | |
| } |