Skip to content

chore(petstore-hono): regenerate client/server/hooks on demand instead of committing them#306

Merged
benjamineckstein merged 3 commits into
mainfrom
chore/petstore-hono-regenerate-on-demand
Jun 15, 2026
Merged

chore(petstore-hono): regenerate client/server/hooks on demand instead of committing them#306
benjamineckstein merged 3 commits into
mainfrom
chore/petstore-hono-regenerate-on-demand

Conversation

@benjamineckstein

Copy link
Copy Markdown
Contributor

Summary

The petstore-hono e2e example no longer commits generated code (client, server router/service, react-query hooks, models, zod schemas). The generated/ directory is gitignored and regenerated fresh via pnpm generate, wired into build, dev, and test:e2e. This ensures CI always exercises current generator output rather than a stale committed snapshot.

Changes

  • generated/ directory is now gitignored; code regenerates on demand
  • pnpm generate command regenerates all client, server, and react-query code
  • Generation is integrated into build, dev, and e2e test pipelines
  • User-owned Zod schema file (hand-written validation messages) relocated from generated/schemas.ts to tracked src/schemas.ts
  • Both generator configs repointed to the new location
  • No generator logic changed; this mirrors the proven approach from openapi-laravel

Testing

The E2E job in CI will run pnpm build then test:e2e, which now:

  • Regenerates all code fresh
  • Resolves imports like ../src/schemas.js
  • Runs Playwright tests against the regenerated output

…d of committing them

Move user-owned src/schemas.ts out of generated/ into src/ so the
entire generated/ directory can be gitignored. Update both generator
configs (input_schema: "src/schemas.ts"). Wire pnpm generate into
build, dev, and test:e2e scripts so generated output is always fresh.
Add packages/petstore-hono/.gitignore covering generated/, test-results/,
and playwright-report/. Add CI comment noting generated code is
produced fresh from spec/api.json by the workspace generators.
@github-actions

Copy link
Copy Markdown
Contributor

Fallow audit report

Found 2 findings.

Details
Severity Rule Location Description
minor fallow/unused-dev-dependency examples/package.json:15 Package '@tanstack/react-query' is in devDependencies but never imported; imported in other workspaces: packages/integration
minor fallow/unused-dev-dependency examples/package.json:17 Package 'react' is in devDependencies but never imported; imported in other workspaces: packages/integration

Generated by fallow.

@github-actions

Copy link
Copy Markdown
Contributor

Fallow audit report

0 inline findings selected for GitHub review.

…in shims

pnpm drops bin shims at install time if the target dist file does not
yet exist (ENOENT warning). In CI, generator packages have no dist/
after a fresh pnpm install --frozen-lockfile, so the openapi-zod-ts,
openapi-server, and openapi-react-query shims are never created.
The recursive build then fails with "openapi-zod-ts: not found" even
though pnpm builds the generators before petstore-hono (topological order).

Replace bare CLI names in the generate script with explicit node
invocations via the workspace-symlinked dist paths. No bin shims
needed; the dist files are present by the time petstore-hono runs
because pnpm respects the workspace dependency order.

Verified from a clean state: removed generator dists, ran
pnpm install --frozen-lockfile then pnpm -r run build. All three
generators ran successfully and vite build produced a 289 kB bundle.
…chema path

Both packages shared petstore-hono's schema via
input_schema: "../petstore-hono/generated/schemas.ts". Moving hono's
schema to src/ broke the import in their committed generated/router.ts.

Apply the same regenerate-on-demand pattern as petstore-hono:
- Fix input_schema in openapi-server.config.json to point at
  ../petstore-hono/src/schemas.ts (always committed, no build dep).
- Replace bare CLI names in generate scripts with explicit node
  invocations to bypass the pnpm bin-shim ENOENT failure on CI.
- Wire pnpm generate into test and start so generated/ is always
  fresh before the code runs.
- Add .gitignore covering generated/ and test-results/.
- git rm --cached the 12 committed generated files.

Verified clean-room: removed generator dists, ran pnpm install
--frozen-lockfile then pnpm -r run build then pnpm -r run test.
All 2,458 tests passed across all packages including petstore-express
(5 tests) and petstore-fastify (5 tests). Regenerated routers now
import from ../../petstore-hono/src/schemas.js. Zero remaining
references to petstore-hono/generated in the repo.
@benjamineckstein benjamineckstein merged commit 9f05787 into main Jun 15, 2026
6 checks passed
@benjamineckstein benjamineckstein deleted the chore/petstore-hono-regenerate-on-demand branch June 15, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant