diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-01 21:02:30 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-01 21:02:30 +0900 |
| commit | b05de1617c7ad323f582f7392e4e62c1f08af58e (patch) | |
| tree | d9b79a1fa6fb57945383a71bd208d4ef8f0889de | |
| parent | 10b9be2c2a46b204f83be7d152ca62bf69e8843e (diff) | |
| download | phperkaigi-2025-albatross-b05de1617c7ad323f582f7392e4e62c1f08af58e.tar.gz phperkaigi-2025-albatross-b05de1617c7ad323f582f7392e4e62c1f08af58e.tar.zst phperkaigi-2025-albatross-b05de1617c7ad323f582f7392e4e62c1f08af58e.zip | |
refactor: run code generation by `go generate`
| -rw-r--r-- | Makefile | 18 | ||||
| -rw-r--r-- | backend/Makefile | 10 | ||||
| -rw-r--r-- | backend/gen/gen.go | 4 | ||||
| -rw-r--r-- | backend/gen/oapi-codegen.yaml (renamed from backend/oapi-codegen.yaml) | 2 | ||||
| -rw-r--r-- | backend/gen/sqlc.yaml (renamed from backend/sqlc.yaml) | 6 | ||||
| -rw-r--r-- | frontend/Makefile | 3 | ||||
| -rw-r--r-- | frontend/package.json | 1 |
7 files changed, 16 insertions, 28 deletions
@@ -52,17 +52,7 @@ initdb: make psql-query < ./backend/schema.sql make psql-query < ./backend/fixtures/dev.sql -.PHONY: openapi -openapi: oapi-codegen openapi-typescript - -.PHONY: oapi-codegen -oapi-codegen: - cd backend; make oapi-codegen - -.PHONY: openapi-typescript -openapi-typescript: - cd frontend; make openapi-typescript - -.PHONY: sqlc -sqlc: - cd backend; make sqlc +.PHONY: gen +gen: + cd backend; make gen + cd frontend; npm run openapi-typescript diff --git a/backend/Makefile b/backend/Makefile index 3b26e00..72d3314 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -10,10 +10,6 @@ check: lint: go vet ./... -.PHONY: oapi-codegen -oapi-codegen: - go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config oapi-codegen.yaml ../openapi.yaml - -.PHONY: sqlc -sqlc: - go run github.com/sqlc-dev/sqlc/cmd/sqlc generate +.PHONY: gen +gen: + go generate ./... diff --git a/backend/gen/gen.go b/backend/gen/gen.go new file mode 100644 index 0000000..6af912d --- /dev/null +++ b/backend/gen/gen.go @@ -0,0 +1,4 @@ +package main + +//go:generate go run github.com/sqlc-dev/sqlc/cmd/sqlc generate +//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config oapi-codegen.yaml ../../openapi.yaml diff --git a/backend/oapi-codegen.yaml b/backend/gen/oapi-codegen.yaml index 65cf079..d235096 100644 --- a/backend/oapi-codegen.yaml +++ b/backend/gen/oapi-codegen.yaml @@ -4,7 +4,7 @@ generate: echo-server: true strict-server: true embedded-spec: true -output: api/generated.go +output: ../api/generated.go output-options: skip-prune: true nullable-type: true diff --git a/backend/sqlc.yaml b/backend/gen/sqlc.yaml index 3b2d1d0..c56e44b 100644 --- a/backend/sqlc.yaml +++ b/backend/gen/sqlc.yaml @@ -1,11 +1,11 @@ version: "2" sql: - engine: "postgresql" - queries: "query.sql" - schema: "schema.sql" + queries: "../query.sql" + schema: "../schema.sql" gen: go: package: "db" - out: "db" + out: "../db" sql_package: "pgx/v5" emit_pointers_for_null_types: true diff --git a/frontend/Makefile b/frontend/Makefile deleted file mode 100644 index 17dd690..0000000 --- a/frontend/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -.PHONY: openapi-typescript -openapi-typescript: - npx --no-install openapi-typescript --path-params-as-types --output ./app/.server/api/schema.d.ts ../openapi.yaml diff --git a/frontend/package.json b/frontend/package.json index aefb693..ff25a86 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,6 +7,7 @@ "build": "remix vite:build", "dev": "remix vite:dev", "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", + "openapi-typescript": "npx --no-install openapi-typescript --path-params-as-types --output ./app/.server/api/schema.d.ts ../openapi.yaml", "start": "remix-serve ./build/server/index.js", "typecheck": "tsc" }, |
