feat!: configurable React Router options, RR middleware compatibility, and migration CLI - #105
Open
kevinsalerno wants to merge 1 commit into
Open
Conversation
…gration CLI Addresses reports that Juniper is rigid about React Router configuration. - client/server: add ClientRouterOptions (basename, future, window, custom createRouter factory) so createHashRouter/createMemoryRouter and subdirectory deployments are supported; server forwards the same options to createStaticHandler/createStaticRouter for SSR parity. - build: add routerOptions to BuildOptions and inject into generated main.tsx. - middleware: widen MiddlewareFunction and RouteMiddlewareArgs (adds url, pattern) so React Router middleware can be used in route modules. - cli: new `detect`, `migrate` and `generate adapter` subcommands, exported as @udibo/juniper/cli. Migration prompts for confirmation before writing. - adapters: new @udibo/juniper/adapters module with auth, logging, error, security and context middleware helpers plus composeMiddleware. - docs: docs/cli.md, middleware docs updated. Generated by MetaCode arm1 as part of an agent evaluation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses reports that Juniper is rigid about React Router configuration. Four related changes:
ClientRouterOptions(basename,future,window, and a customcreateRouterfactory) onClient, with the server forwarding the same options tocreateStaticHandler/createStaticRouterso SSR and hydration agree. This unblocks subdirectory deployments andcreateHashRouter/createMemoryRouter.routerOptionsis also plumbed throughBuildOptionsinto the generatedmain.tsx.RouteMiddlewareArgsgainsurlandpattern, andMiddlewareFunctionis widened with aResultgeneric so React Router middleware can be dropped into a route module.@udibo/juniper/cli) —detect,migrate, andgenerate adaptersubcommands.migrateprints what it found and requires explicit confirmation before writing;--dry-runand--yesare supported.@udibo/juniper/adapters) —authAdapters,loggingAdapters,errorAdapters,securityAdapters,contextAdapters, andcomposeMiddleware.Docs: new
docs/cli.md, plus a React Router compatibility section indocs/middleware.md.Provenance
This branch was written end-to-end by a coding agent (internally: MetaCode arm1) as part of an agent evaluation, from a four-prompt sequence describing the rigidity complaints. It has been reviewed by a human before submission but not hand-edited — what you see is the agent's output. Flagging that up front so you can weigh it accordingly, and please don't feel any obligation to merge it.
State of the branch — please read before reviewing
I verified this locally rather than relying on the agent's own summary. Being upfront about what does and doesn't hold:
Passes
deno checkacross all ofsrc/is clean.deno run -A src/cli.ts --help,detect, andmigrate --dry-runall produce output.Fails
deno fmt --check— 10 unformatted files.deno lint— 63 problems. Both are clean onmain, so both are introduced here and CI will go red on the first two steps. Happy to push a formatting commit if you want the branch cleaned up.src/build.test.tsfail in my environment with esbuildError: The service was stopped. I checked this against a pristine worktree at61dd69aand it fails identically there, so I believe it is environmental on my machine and not caused by this branch — but worth confirming on your CI.Known defects I would want fixed before this is mergeable
v7_*future flags referenced insrc/build.tsandsrc/build.test.ts(8 occurrences) do not exist in React Router 8.3.0 — they were removed after v7. The agent hallucinated them. They're inert rather than harmful here, but they're wrong.detectheuristic is unreliable. Onexample/it reportsTotal routes found: 91while its own breakdown sums to 75, counts*.test.tsxandmain.tsas routes, prints[middleware: 0]for routes it simultaneously flags as having middleware, and its react-router-vs-juniper classification is essentially arbitrary between sibling files.next's default return type fromPromise<RequestContext>toPromise<void>will break any existing user code doingconst ctx = await next(), despite the agent's claim of full backward compatibility.I'm submitting as-is rather than patching it up, since the point of the exercise is to see what the agent produced unaided. Entirely reasonable to close this — feedback on the approach is more valuable to me than a merge.
Testing
deno check src/*.ts src/*.tsx— clean.deno test -P=testfromsrc/— 20 passed (302 steps), 2 failed; the 2 failures reproduce identically on a pristine worktree at61dd69a(esbuildservice was stopped) and appear environmental.--help,detect --project-root ./example,migrate --project-root ./example --dry-run,generate adapter auth requireAuth.src/cli.test.ts,src/adapters.test.ts, plus cases insrc/build.test.tsandsrc/client.test.tsx.BREAKING CHANGE:
MiddlewareFunction'snextnow returnsPromise<Result>withResultdefaulting tovoid, rather thanPromise<RequestContext>. Existing middleware doingconst ctx = await next()will no longer receive the request context.RouteMiddlewareArgsalso gains requiredurlandpatternfields, so any hand-constructed args objects will need updating.