Files
supabase/apps/docs/spec/Makefile
Katerina Skroumpelou 81aefa3c55 fix(docs): install @redocly/cli dep to apps/docs (#44624)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix.

## What is the current behavior?

Running `make` in `apps/docs/spec` (used by the `docs-js-libs-update`
workflow) fails with:

```
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "redocly" not found
make: *** [Makefile:56: dereference.api.v1] Error 254
```

This regression was introduced in #44428, which removed `@redocly/cli`
from `packages/generator/package.json` as an "unused" dependency. It was
previously placed there because the Makefile ran `cd packages/generator
&& pnpm exec redocly` — but that directory had no logical ownership of
the dependency.

## What is the new behavior?

- `@redocly/cli` is now a devDependency of `apps/docs`, which is the
package that owns the spec generation workflow.
- The Makefile no longer `cd`s into `packages/generator` for the redocly
calls. It runs `pnpm exec redocly` directly from `apps/docs/spec`, where
the binary is now available.
- The `tsdoc:dereference` targets are unchanged and still `cd` into
`packages/generator` to run scripts defined there.

## Additional context

The `cd packages/generator` pattern for redocly was introduced in #42987
to fix a peer dependency resolution issue with `npx @redocly/cli`. The
fix was correct but placed the dependency in the wrong package. This PR
moves it to its logical home.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Added documentation processing tool as a development dependency.
* Updated documentation generation configuration to optimize command
execution paths.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-07 15:15:29 +03:00

135 lines
6.8 KiB
Makefile
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
REPO_DIR=$(shell pwd)
GENERATOR_DIR=../../../packages/generator
run: download transform generate format
###############################################################################
# Download all the specs
###############################################################################
# comment out download.auth.v1 temporarily, we're manually creating the file
# download: download.api.v1 download.auth.v1 download.storage.v1 download.tsdoc.v2
download: download.api.v1 download.storage.v1 download.tsdoc.v2
download.api.v1:
curl -sS https://api.supabase.com/api/v1-json > $(REPO_DIR)/api_v1_openapi.json
# This flow needs to be updated, so we'l comment out for the moment
# Manual flow for now:
# — get swagger.json (https://supabase.github.io/gotrue/swagger.json)
# — manually convert via swagger editor -> open api v3 spec
# dereference.tsdoc.v2 -> auth_v1_openapi_deparsed.json
# download.auth.v1:
# curl -sS https://supabase.github.io/gotrue/swagger.json > $(REPO_DIR)/auth_v1_openapi.json
download.storage.v1:
curl -sS https://supabase.github.io/storage/api.json > $(REPO_DIR)/storage_v0_openapi.json
# No longer updated
# download.tsdoc.v1:
# curl -sS https://supabase.github.io/supabase-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/supabase.json
# curl -sS https://supabase.github.io/gotrue-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/gotrue.json
# curl -sS https://supabase.github.io/postgrest-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/postgrest.json
# curl -sS https://supabase.github.io/realtime-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/realtime.json
# curl -sS https://supabase.github.io/storage-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/storage.json
# curl -sS https://supabase.github.io/functions-js/v1/spec.json > $(REPO_DIR)/enrichments/tsdoc_v1/functions.json
download.tsdoc.v2:
curl -sS https://supabase.github.io/supabase-js/supabase-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/supabase.json
curl -sS https://supabase.github.io/supabase-js/auth-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/gotrue.json
curl -sS https://supabase.github.io/supabase-js/postgrest-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/postgrest.json
curl -sS https://supabase.github.io/supabase-js/realtime-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/realtime.json
curl -sS https://supabase.github.io/supabase-js/storage-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/storage.json
curl -sS https://supabase.github.io/supabase-js/functions-js/v2/spec.json > $(REPO_DIR)/enrichments/tsdoc_v2/functions.json
download.analytics.v0:
curl -sS https://logflare.app/api/openapi > $(REPO_DIR)/analytics_v0_openapi.json
###############################################################################
# Transform docs into working files
###############################################################################
transform: dereference.api.v1 dereference.auth.v1 dereference.storage.v0 dereference.tsdoc.v2 combine.tsdoc.v2
dereference.api.v1:
pnpm exec redocly bundle --dereferenced -o $(REPO_DIR)/transforms/api_v1_openapi_deparsed.json $(REPO_DIR)/api_v1_openapi.json
dereference.auth.v1:
pnpm exec redocly bundle --dereferenced -o $(REPO_DIR)/transforms/auth_v1_openapi_deparsed.json $(REPO_DIR)/auth_v1_openapi.json
dereference.storage.v0:
pnpm exec redocly bundle --dereferenced -o $(REPO_DIR)/transforms/storage_v0_openapi_deparsed.json $(REPO_DIR)/storage_v0_openapi.json
dereference.analytics.v0:
pnpm exec redocly bundle --dereferenced -o $(REPO_DIR)/transforms/analytics_v0_openapi_deparsed.json $(REPO_DIR)/analytics_v0_openapi.json
# No longer updated
# dereference.tsdoc.v1:
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:functions:v1
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:gotrue:v1
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:postgrest:v1
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:realtime:v1
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:storage:v1
# cd $(GENERATOR_DIR) && npm run tsdoc:dereference:supabase:v1
dereference.tsdoc.v2:
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:functions:v2
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:gotrue:v2
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:postgrest:v2
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:realtime:v2
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:storage:v2
cd $(GENERATOR_DIR) && pnpm run tsdoc:dereference:supabase:v2
# No longer updated
# combine.tsdoc.v1:
# jq -s '{ name: "Combined Specs", children: [.[0], .[1], .[2], .[3], .[4], .[5]] }' \
# $(REPO_DIR)/enrichments/tsdoc_v1/supabase_dereferenced.json \
# $(REPO_DIR)/enrichments/tsdoc_v1/gotrue_dereferenced.json \
# $(REPO_DIR)/enrichments/tsdoc_v1/postgrest_dereferenced.json \
# $(REPO_DIR)/enrichments/tsdoc_v1/realtime_dereferenced.json \
# $(REPO_DIR)/enrichments/tsdoc_v1/storage_dereferenced.json \
# $(REPO_DIR)/enrichments/tsdoc_v1/functions_dereferenced.json \
# > $(REPO_DIR)/enrichments/tsdoc_v1/combined.json
combine.tsdoc.v2:
jq -s '{ name: "Combined Specs", children: [.[0], .[1], .[2], .[3], .[4], .[5]] }' \
$(REPO_DIR)/enrichments/tsdoc_v2/supabase_dereferenced.json \
$(REPO_DIR)/enrichments/tsdoc_v2/gotrue_dereferenced.json \
$(REPO_DIR)/enrichments/tsdoc_v2/postgrest_dereferenced.json \
$(REPO_DIR)/enrichments/tsdoc_v2/realtime_dereferenced.json \
$(REPO_DIR)/enrichments/tsdoc_v2/storage_dereferenced.json \
$(REPO_DIR)/enrichments/tsdoc_v2/functions_dereferenced.json \
> $(REPO_DIR)/enrichments/tsdoc_v2/combined.json
combine-raw.tsdoc.v2:
jq -s '{ name: "Combined Specs", children: [.[0], .[1], .[2], .[3], .[4], .[5]] }' \
$(REPO_DIR)/enrichments/tsdoc_v2/supabase.json \
$(REPO_DIR)/enrichments/tsdoc_v2/gotrue.json \
$(REPO_DIR)/enrichments/tsdoc_v2/postgrest.json \
$(REPO_DIR)/enrichments/tsdoc_v2/realtime.json \
$(REPO_DIR)/enrichments/tsdoc_v2/storage.json \
$(REPO_DIR)/enrichments/tsdoc_v2/functions.json \
> $(REPO_DIR)/enrichments/tsdoc_v2/combined_raw.json
###############################################################################
# Generate sections from OpenAPI 3.0
###############################################################################
generate: generate.sections.api.v1
generate.sections.api.v1:
npx tsx $(REPO_DIR)/sections/generateMgmtApiSections.cts $(REPO_DIR)/transforms/api_v1_openapi_deparsed.json $(REPO_DIR)/common-api-sections.json
###############################################################################
# Validate OpenAPI 3.0
###############################################################################
validate.analytics.v0:
pnpm exec redocly lint --extends=minimal $(REPO_DIR)/analytics_v0_openapi.json
###############################################################################
# Format everything - easier for git to track changes.
###############################################################################
format:
npx prettier --cache --write .