Skip to content

Next.js mapper misses routes in src/app projects #29

@crissdev

Description

@crissdev

Summary

clawpatch map does not create Next.js route features for projects that use Next's valid src/app layout.

clawpatch init can still detect the project as Next.js, but map only emits package script/config features because the Next mapper searches root-level app/ and pages/ directories.

Repro

  1. Use a Next.js app with routes under src/app, and no root-level app/ or pages/ directory.
  2. Run:
clawpatch init
clawpatch map
  1. Observe the map result.

Example output from a real repo using clawpatch@0.1.0:

features: 7
new: 0
changed: 0
stale: 0
next: clawpatch review --limit 3

The generated feature files were only package scripts/config, for example:

  • Package script build
  • Package script lint
  • Package script start
  • Project config package.json
  • Project config tsconfig.json

No route features were created, despite route files such as:

src/app/(main)/page.tsx
src/app/account/login/page.tsx
src/app/api/auth/[...all]/route.ts
src/app/api/community/solutions/route.ts

Expected behavior

clawpatch map should create route features for src/app/**/(page|route).{ts,tsx,js,jsx} and src/pages/**/*.{ts,tsx,js,jsx}, just as it does for root app/ and pages/ projects.

Likely cause

The current Next mapper walks only root-level route directories:

const files = await walk(root, ["app", "pages"]);

It also derives route source/path handling from app/ and pages/ prefixes only.

Suggested fix

Include src/app and src/pages in the Next mapper, then normalize route paths before route derivation. For example, strip an optional leading src/ before applying the existing app/ / pages/ route conversion.

It would also be useful to add mapper tests covering both layouts:

  • app/page.tsx
  • src/app/page.tsx
  • pages/index.tsx
  • src/pages/index.tsx
  • dynamic routes under both roots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions