fix(build): auto-run api-gen when generated files are missing#18
Conversation
`go build` fails after a plain `git clone` because the generated API files are gitignored. Add a guard to the `build` target that runs `make api-gen` automatically if the files are absent, so `git clone && make build` works out of the box.
isaacrowntree
left a comment
There was a problem hiding this comment.
Useful fix — solves the real "fresh clone → 14 compile errors" problem with minimal surface area.
Suggestion: apply the same guard to install and test
Both targets have the identical fresh-clone problem. Could either repeat the guard or factor it out:
```makefile
.PHONY: ensure-gen
ensure-gen:
@[ -f api/clickupv3/client.gen.go ] || $(MAKE) api-gen
build: ensure-gen
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/clickup
install: ensure-gen
go install -ldflags "$(LDFLAGS)" ./cmd/clickup
test: ensure-gen
go test ./...
```
Other note: this silently adds a network dependency to make build on fresh clones (api-gen curls the OpenAPI specs from developer.clickup.com). Acceptable since the alternative is failing the build outright, but worth a line in the README so airgapped/offline builders aren't surprised.
LGTM otherwise.
The original auto-gen guard only covered `make build`. Extract it into a phony `ensure-gen` target so `install` and `test` also work after a fresh clone without manual `make api-gen`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Problem
go buildfails after a plaingit clonebecause the generated API files (api/clickupv{2,3}/*.gen.go,internal/apiv{2,3}/operations.gen.go) are gitignored. This produces 14 compile errors for types that only exist in the generated code:Any Dockerfile or CI pipeline that does
git clone && go buildis broken.Fix
One line added to the
buildtarget — if the generated files are absent, runmake api-genfirst:Verification