Skip to content

Commit 0d943f1

Browse files
committed
Add 'DO NOT EDIT' to the top
1 parent 0127e6d commit 0d943f1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

scripts/apitypings/main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"reflect"
1010
"regexp"
11+
"sort"
1112
"strings"
1213

1314
"golang.org/x/tools/go/packages"
@@ -19,6 +20,7 @@ import (
1920

2021
const (
2122
baseDir = "./codersdk"
23+
indent = " "
2224
)
2325

2426
// TODO: Handle httpapi.Response and other types
@@ -44,6 +46,8 @@ type TypescriptTypes struct {
4446
// String just combines all the codeblocks.
4547
func (t TypescriptTypes) String() string {
4648
var s strings.Builder
49+
s.WriteString("// Code generated by 'make coder/scripts/apitypings/main.go'. DO NOT EDIT.\n\n")
50+
4751
sortedTypes := make([]string, 0, len(t.Types))
4852
sortedEnums := make([]string, 0, len(t.Types))
4953

@@ -54,6 +58,9 @@ func (t TypescriptTypes) String() string {
5458
sortedEnums = append(sortedEnums, k)
5559
}
5660

61+
sort.Strings(sortedTypes)
62+
sort.Strings(sortedEnums)
63+
5764
for _, k := range sortedTypes {
5865
v := t.Types[k]
5966
s.WriteString(v)
@@ -65,7 +72,8 @@ func (t TypescriptTypes) String() string {
6572
s.WriteString(v)
6673
s.WriteRune('\n')
6774
}
68-
return s.String()
75+
76+
return strings.TrimRight(s.String(), "\n")
6977
}
7078

7179
// GenerateFromDirectory will return all the typescript code blocks for a directory
@@ -265,13 +273,13 @@ func (g *Generator) buildStruct(obj types.Object, st *types.Struct) (string, err
265273
}
266274

267275
if tsType.Comment != "" {
268-
s.WriteString(fmt.Sprintf("\t// %s\n", tsType.Comment))
276+
s.WriteString(fmt.Sprintf("%s// %s\n", indent, tsType.Comment))
269277
}
270278
optional := ""
271279
if tsType.Optional {
272280
optional = "?"
273281
}
274-
s.WriteString(fmt.Sprintf("\treadonly %s%s: %s\n", jsonName, optional, tsType.ValueType))
282+
s.WriteString(fmt.Sprintf("%sreadonly %s%s: %s\n", indent, jsonName, optional, tsType.ValueType))
275283
}
276284
s.WriteString("}\n")
277285
return s.String(), nil

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by 'make coder/scripts/apitypings/main.go'. DO NOT EDIT.
2+
13
// From codersdk/workspaceagents.go:35:6
24
export interface AWSInstanceIdentityToken {
35
readonly signature: string
@@ -420,5 +422,3 @@ export type UserStatus = "active" | "suspended"
420422

421423
// From codersdk/workspaceresources.go:15:6
422424
export type WorkspaceAgentStatus = "connected" | "connecting" | "disconnected"
423-
424-

0 commit comments

Comments
 (0)