Skip to content

Commit a6b34d9

Browse files
committed
feat: migrate to buf v1 and go.einride.tech
1 parent 860ec09 commit a6b34d9

File tree

28 files changed

+124
-131
lines changed

28 files changed

+124
-131
lines changed

Makefile

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
SHELL := /bin/bash
22

33
all: \
4-
buf-lint \
5-
buf-generate \
64
go-lint \
75
go-review \
8-
buf-generate \
9-
eslint \
106
go-test \
7+
examples/proto \
8+
eslint \
119
go-mod-tidy \
1210
git-verify-nodiff
1311

14-
include tools/buf/rules.mk
1512
include tools/commitlint/rules.mk
1613
include tools/git-verify-nodiff/rules.mk
1714
include tools/golangci-lint/rules.mk
@@ -29,26 +26,11 @@ go-mod-tidy:
2926
$(info [$@] tidying Go module files...)
3027
@go mod tidy -v
3128

32-
.PHONY: buf-lint
33-
buf-lint: $(buf)
34-
$(info [$@] linting protobuf schemas...)
35-
@$(buf) lint
36-
37-
protoc_gen_typescript_http := ./bin/protoc-gen-typescript-http
38-
export PATH := $(dir $(abspath $(protoc_gen_typescript_http))):$(PATH)
39-
40-
.PHONY: $(protoc_gen_typescript_http)
41-
$(protoc_gen_typescript_http):
42-
$(info [$@] building protoc-gen-typescript-http...)
43-
@go build -o $@ .
29+
.PHONY: examples/proto
30+
examples/proto:
31+
@make -C examples/proto
4432

4533
.PHONY: $(eslint)
4634
eslint: $(eslint)
4735
$(info [$@] linting typescript files...)
4836
$(eslint) --config $(eslint_cwd)/.eslintrc.js --quiet "examples/proto/gen/typescript/**/*.ts"
49-
50-
.PHONY: buf-generate
51-
buf-generate: $(buf) $(protoc_gen_typescript_http)
52-
$(info [$@] generating protobuf stubs...)
53-
@rm -rf examples/proto/gen
54-
@$(buf) generate --path examples/proto/src/einride

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ generated code, look at [examples][examples].
2020
### Install the plugin
2121

2222
```bash
23-
go get github.com/einride/protoc-gen-typescript-http
23+
go get go.einride.tech/protoc-gen-typescript-http
2424
```
2525

2626
Or download a prebuilt binary from [releases][releases].

buf.gen.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

buf.lock

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/proto/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build/
2+
.tools/*/*/

tools/buf/rules.mk renamed to examples/proto/.tools/buf/rules.mk

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
buf_cwd := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
2-
buf := $(buf_cwd)/bin/buf
2+
buf_version := 1.0.0-rc10
3+
buf := $(buf_cwd)/$(buf_version)/bin/buf
4+
export PATH := $(dir $(buf)):$(PATH)
35

4-
buf_version := 0.39.1
6+
os := $(shell uname -s)-$(shell uname -m)
57

6-
arch = $(shell uname -s)-$(shell uname -m)
7-
8-
# enforce x86 arch if mac m1 until tool has official support
9-
ifeq ($(arch),Darwin-arm64)
10-
arch = Darwin-x86_64
11-
endif
12-
13-
buf_bin_url := https://github.com/bufbuild/buf/releases/download/v$(buf_version)/buf-$(arch)
8+
buf_bin_url := https://github.com/bufbuild/buf/releases/download/v$(buf_version)/buf-$(os)
149

1510
$(buf): $(buf_cwd)/rules.mk
1611
$(info [buf] feching $(buf_version) binary...)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
clang_format_dir := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
2+
clang_format_version := 1.6.0
3+
clang_format := $(clang_format_dir)/bin/clang-format
4+
export PATH := $(dir $(clang_format)):$(PATH)
5+
6+
ifeq ($(shell uname),Linux)
7+
clang_format_bin_path := $(clang_format_dir)/node_modules/clang-format/bin/linux_x64
8+
else ifeq ($(shell uname),Darwin)
9+
clang_format_bin_path := $(clang_format_dir)/node_modules/clang-format/bin/darwin_x64
10+
else
11+
$(error unsupported OS: $(shell uname))
12+
endif
13+
14+
$(clang_format):
15+
$(info [clang-format] installing version $(clang_format_version)...)
16+
@npm install --no-save --no-audit --prefix $(clang_format_dir) clang-format@$(clang_format_version) &> /dev/null
17+
@mkdir -p $(dir $(clang_format))
18+
@ln -fs $(clang_format_bin_path)/clang-format $@
19+
@chmod +x $@
20+
@touch $@

examples/proto/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
SHELL := /usr/bin/env bash
2+
3+
.PHONY: all
4+
all: \
5+
clang-format \
6+
buf-lint \
7+
buf-generate
8+
9+
include .tools/buf/rules.mk
10+
include .tools/clang-format/rules.mk
11+
12+
.PHONY: .build/protoc-gen-typescript-http
13+
.build/protoc-gen-typescript-http:
14+
$(info [$@] building binary...)
15+
@cd ../.. && go build -o $(abspath $@) .
16+
17+
.PHONY: buf-lint
18+
buf-lint: $(buf)
19+
$(info [$@] linting proto schemas...)
20+
@$(buf) lint
21+
22+
.PHONY: clang-format
23+
clang-format: proto_files = $(shell find einride -type f -name '*.proto')
24+
clang-format: $(clang_format)
25+
$(info [$@] formatting proto files...)
26+
@$(clang_format) \
27+
-i \
28+
--style='{BasedOnStyle: Google, ColumnLimit: 0, Language: Proto}' \
29+
$(proto_files)
30+
31+
protoc_plugins := \
32+
.build/protoc-gen-typescript-http
33+
34+
.PHONY: buf-generate
35+
buf-generate: $(buf) $(protoc_plugins)
36+
$(info [$@] generating protobuf stubs...)
37+
@$(buf) generate \
38+
--template buf.gen.yaml \
39+
--path einride

examples/proto/buf.gen.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: v1
2+
3+
plugins:
4+
- name: typescript-http
5+
out: gen/typescript
6+
path: ./.build/protoc-gen-typescript-http

examples/proto/buf.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v1
3+
deps:
4+
- remote: buf.build
5+
owner: googleapis
6+
repository: googleapis
7+
branch: main
8+
commit: 9088184d3ed04821b7e990024ff05656
9+
digest: b1---R9Xre3yvH8peoJPQ0dsUYp37KzdlBlx5fjPsYekyI=
10+
create_time: 2021-12-23T15:04:49.66847Z

0 commit comments

Comments
 (0)