Skip to content

Commit eefb9f2

Browse files
committed
cmd: use xstring for naming style conversion
1 parent 0d2ef8d commit eefb9f2

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ test: test-sdk test-hasura-ndc-go test-example-codegen
3030

3131
.PHONY: go-tidy
3232
go-tidy:
33+
cp go.work.testing go.work
3334
go mod tidy
3435
cd $(ROOT_DIR)/cmd/hasura-ndc-go && go mod tidy
3536
cd $(ROOT_DIR)/cmd/hasura-ndc-go/command/internal/testdata/basic/source && go mod tidy

cmd/hasura-ndc-go/command/internal/connector.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
"github.com/hasura/ndc-sdk-go/schema"
1818
"github.com/hasura/ndc-sdk-go/utils"
19-
"github.com/iancoleman/strcase"
19+
"github.com/huandu/xstrings"
2020
"github.com/rs/zerolog/log"
2121
"golang.org/x/tools/go/packages"
2222
)
@@ -408,10 +408,10 @@ func (j `)
408408
sb.imports[packageSDKUtils] = ""
409409

410410
sb.builder.WriteString("const (\n")
411-
pascalName := strcase.ToCamel(scalar.NativeType.Name)
411+
pascalName := xstrings.ToPascalCase(scalar.NativeType.Name)
412412
enumConstants := make([]string, len(scalarRep.OneOf))
413413
for i, enum := range scalarRep.OneOf {
414-
enumConst := fmt.Sprintf("%s%s", pascalName, strcase.ToCamel(enum))
414+
enumConst := fmt.Sprintf("%s%s", pascalName, xstrings.ToPascalCase(enum))
415415
enumConstants[i] = enumConst
416416
sb.builder.WriteString(fmt.Sprintf(" %s %s = \"%s\"\n", enumConst, scalarKey, enum))
417417
}

cmd/hasura-ndc-go/command/internal/schema_parser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (sp SchemaParser) formatOperationName(name string) string {
275275
case StyleSnakeCase:
276276
return xstrings.ToSnakeCase(name)
277277
default:
278-
return xstrings.ToSnakeCase(name)
278+
return xstrings.ToCamelCase(name)
279279
}
280280
}
281281

cmd/hasura-ndc-go/command/internal/template.go

-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"fmt"
66
"strings"
77
"text/template"
8-
9-
"github.com/iancoleman/strcase"
108
)
119

1210
const (
@@ -26,11 +24,6 @@ func init() {
2624
if err != nil {
2725
panic(fmt.Errorf("failed to parse connector template: %w", err))
2826
}
29-
30-
strcase.ConfigureAcronym("API", "Api")
31-
strcase.ConfigureAcronym("REST", "Rest")
32-
strcase.ConfigureAcronym("HTTP", "Http")
33-
strcase.ConfigureAcronym("SQL", "sql")
3427
}
3528

3629
func writeFileHeader(builder *strings.Builder, packageName string) {

cmd/hasura-ndc-go/command/internal/testdata/basic/source/go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ go 1.21
55
require (
66
github.com/google/uuid v1.6.0
77
github.com/hasura/ndc-sdk-go v1.4.1
8+
go.opentelemetry.io/otel v1.29.0
9+
go.opentelemetry.io/otel/trace v1.29.0
10+
golang.org/x/sync v0.10.0
811
)
912

1013
require (
@@ -24,7 +27,6 @@ require (
2427
github.com/prometheus/procfs v0.15.1 // indirect
2528
go.opentelemetry.io/contrib/bridges/otelslog v0.4.0 // indirect
2629
go.opentelemetry.io/contrib/propagators/b3 v1.29.0 // indirect
27-
go.opentelemetry.io/otel v1.29.0 // indirect
2830
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.5.0 // indirect
2931
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.5.0 // indirect
3032
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.29.0 // indirect
@@ -38,7 +40,6 @@ require (
3840
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
3941
go.opentelemetry.io/otel/sdk/log v0.5.0 // indirect
4042
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
41-
go.opentelemetry.io/otel/trace v1.29.0 // indirect
4243
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
4344
golang.org/x/net v0.33.0 // indirect
4445
golang.org/x/sys v0.28.0 // indirect

cmd/hasura-ndc-go/command/internal/testdata/basic/source/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
8585
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
8686
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
8787
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
88+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
89+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
8890
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
8991
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9092
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=

cmd/hasura-ndc-go/command/internal/testdata/empty/source/go.mod

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ module github.com/hasura/ndc-codegen-empty-test
22

33
go 1.21
44

5-
require github.com/hasura/ndc-sdk-go v1.4.1
5+
require (
6+
github.com/hasura/ndc-sdk-go v1.4.1
7+
go.opentelemetry.io/otel v1.29.0
8+
golang.org/x/sync v0.10.0
9+
)
610

711
require (
812
github.com/alecthomas/kong v1.8.1 // indirect
@@ -22,7 +26,6 @@ require (
2226
github.com/prometheus/procfs v0.15.1 // indirect
2327
go.opentelemetry.io/contrib/bridges/otelslog v0.4.0 // indirect
2428
go.opentelemetry.io/contrib/propagators/b3 v1.29.0 // indirect
25-
go.opentelemetry.io/otel v1.29.0 // indirect
2629
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.5.0 // indirect
2730
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.5.0 // indirect
2831
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.29.0 // indirect

cmd/hasura-ndc-go/command/internal/testdata/empty/source/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
8585
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
8686
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
8787
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
88+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
89+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
8890
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
8991
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9092
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=

cmd/hasura-ndc-go/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/google/uuid v1.6.0
1111
github.com/hasura/ndc-sdk-go v1.5.0
1212
github.com/huandu/xstrings v1.5.0
13-
github.com/iancoleman/strcase v0.3.0
1413
github.com/rs/zerolog v1.33.0
1514
golang.org/x/mod v0.23.0
1615
golang.org/x/tools v0.30.0

cmd/hasura-ndc-go/go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
2222
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
2323
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
2424
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
25-
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
26-
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
2725
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
2826
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
2927
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=

0 commit comments

Comments
 (0)