Skip to content

fix: monorepo workspace detection on Windows + OpenAPI route support#8

Merged
Houseofmvps merged 2 commits intoHouseofmvps:mainfrom
adutton:fix/monorepo-workspace-detection
Apr 8, 2026
Merged

fix: monorepo workspace detection on Windows + OpenAPI route support#8
Houseofmvps merged 2 commits intoHouseofmvps:mainfrom
adutton:fix/monorepo-workspace-detection

Conversation

@adutton
Copy link
Copy Markdown
Contributor

@adutton adutton commented Apr 8, 2026

Summary

Fixes monorepo workspace detection failing on Windows and adds support for @hono/zod-openapi route patterns. Tested against a real pnpm monorepo with SvelteKit + Hono + Drizzle that was detected as raw-http with 1 route — now correctly detects sveltekit, hono | drizzle | typescript with 141 routes.

Scanner fixes (scanner.ts)

  • Direct workspace paths not recognized — workspace patterns like app or api (without globs) were treated as parent directories to enumerate, so they were never registered as workspaces. Only glob patterns like packages/* worked.
  • Windows \r in YAML parsingpnpm-workspace.yaml with \r\n line endings produced paths like api\r, causing all package.json reads to silently fail and every workspace to fall back to raw-http.
  • raw-http fallback not cleaned up — the root package.json fallback persisted even after real frameworks were aggregated from workspaces.

Route detection fixes (routes.ts, extract-routes.ts)

  • createRoute() + .openapi() pattern — added AST support for the @hono/zod-openapi pattern where routes are defined via createRoute({ method, path }) and registered with .openapi(route, handler). Handles both inline calls and variable references.
  • Monorepo entry points missing from prefix scanresolveRoutePrefixes only checked root-level entry files. Workspace entry points like api/src/app.ts are now included, so .route('/prefix', router) mounts are discovered.
  • Windows path separator mismatch in prefix map — prefix map keys used forward slashes but route.file used backslashes, preventing prefix application on Windows.

Test plan

  • All 27 existing tests pass
  • Verify against a pnpm monorepo with direct workspace paths (not just globs)
  • Verify on Windows with \r\n line endings in pnpm-workspace.yaml
  • Verify @hono/zod-openapi createRoute() routes are detected

adutton added 2 commits April 7, 2026 19:24
…Windows

Three bugs fixed:
1. Direct workspace paths (e.g. "app", "api") were treated as parent
   directories to enumerate, not as workspaces themselves
2. Windows \r line endings in pnpm-workspace.yaml poisoned path joins,
   causing all workspace package.json reads to silently fail
3. raw-http fallback persisted after real frameworks were aggregated
   from workspaces
…s prefix resolution

- Add AST support for createRoute({ method, path }) + .openapi() pattern
  used by @hono/zod-openapi, extracting method and path from both inline
  calls and variable references
- Add monorepo workspace entry points to prefix resolution scan
  (e.g. api/src/app.ts) so .route() mount prefixes are discovered
- Normalize backslashes in route.file before prefix map lookup,
  fixing Windows path separator mismatch that prevented prefix application
@Houseofmvps Houseofmvps merged commit fab1f55 into Houseofmvps:main Apr 8, 2026
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.

2 participants