You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(cli): opt-in Mockatoo GitHub sign-in addon for dev and tests - #1306
Implements #1305: an opt-in --addons mockatoo that adds GitHub sign-in to the Better Auth template, using a mock OAuth provider outside production.
// server auth template (only with --addons mockatoo)
-socialProviders: {},+socialProviders: isProduction ? { github } : {},+plugins: isProduction ? [...] : [mockGitHub(github), ...],
// Next.js sign-in form
+<Button>Continue with GitHub</Button>
Opt-in: defaults are unchanged; nothing loads unless the addon is selected.
Development and tests: sign-in goes through Mockatoo (free hosted mock of GitHub OAuth). No GitHub OAuth app or secrets needed; E2E tests sign in with a Mockatoo test account.
Production: unchanged — Better Auth's normal GitHub provider; the mock plugin isn't loaded. GitHub env vars are @required=forEnv(production) in the Varlock schema.
Before: email/password only; the first social sign-in needs a registered GitHub OAuth app and secrets before dev runs. After:create-better-t-stack --frontend next --auth better-auth --addons mockatoo scaffolds a "Continue with GitHub" button that works immediately in dev. Verified end-to-end today against a generated split-origin app (web on :3001, API server on :3002): Playwright drives the full flow — click the button → Mockatoo consent → callback on the API origin → back to the web app's /dashboard, signed in.
Checks on this branch:bun run check, bun run build:cli, and the CLI test suite (bun test ./test --timeout 30000) all pass; 112/112 tests. (At the default 5s timeout one test times out on main as well.)
Summary by CodeRabbit
New Features
Added Mockatoo as a selectable add-on in the Development & Testing category.
Generated projects using Better Auth can include GitHub sign-in. In development and tests, GitHub authentication is mocked; production uses GitHub credentials.
GitHub credential settings are included in generated projects and required only in production.
Compatibility
Mockatoo is supported with Next.js and Better Auth, except when using Convex.
A relative callbackURL resolves against the Better Auth server, which is a
separate origin from the web app in non-self backends, so sign-in landed on
the API server's /dashboard (404). Use the web app's origin.
Review was skipped as selected files did not have any reviewable changes.
Files ignored due to path filters: 1
packages/template-generator/src/templates.generated.ts is excluded by !**/*.generated.*
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: ab3bec5e-7d54-442c-8267-1d37141c0b36
Commits
Reviewing files that changed from the base of the PR and between 1b8e4bd and b951cd9.
Files ignored due to path filters: 1
packages/template-generator/src/templates.generated.ts is excluded by !**/*.generated.*
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Walkthrough
The change adds the Mockatoo addon to project configuration and CLI selection, and limits its supported stack. Generated projects receive Better Auth GitHub sign-in configuration, conditional environment variables, a development and test mock plugin, and a GitHub sign-in button.
Changes
Mockatoo GitHub sign-in
Layer / File(s)
Summary
Addon contract and selection packages/types/src/schemas.ts, packages/types/src/compatibility.ts, apps/cli/src/prompts/addons.ts, apps/cli/test/generated-builds/samples.ts
The addon schema accepts mockatoo. Compatibility validation requires Better Auth and rejects Convex. The CLI lists Mockatoo in “Development & Testing,” and the generated-build samples include a Mockatoo configuration.
Generated dependency and environment setup packages/template-generator/src/utils/add-deps.ts, packages/template-generator/src/processors/auth-deps.ts, packages/template-generator/src/processors/env-vars.ts, packages/template-generator/src/processors/varlock.ts
When Mockatoo is enabled, the generated project includes the Better Auth connector dependency and GitHub client environment variables. Varlock marks both credentials as required in production and marks the client ID as non-sensitive.
Better Auth and sign-in flow packages/template-generator/templates/auth/better-auth/server/base/src/index.ts.hbs, packages/template-generator/templates/auth/better-auth/web/react/next/src/components/sign-in-form.tsx.hbs
When Mockatoo is enabled, the generated server configures GitHub as a social provider in production and includes the Mockatoo plugin outside production. The sign-in form displays a GitHub button that starts social sign-in with a /dashboard callback URL.
Merge Risk: Moderate · previous review 1b8e4
Generated apps use the mock GitHub login whenever NODE_ENV is not exactly "production", so a deployment without that variable would not use the real GitHub login. Adding Mockatoo to an existing project reports success without changing anything. Fix the environment gating and the add-flow behavior before merging. The missing error message on the sign-in button is a minor follow-up.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(cli): opt-in Mockatoo GitHub sign-in addon for dev and tests" matches the main change. The PR adds an opt-in mockatoo addon to the CLI. The addon gives a GitHub sign-in button that u…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title "feat(cli): opt-in Mockatoo GitHub sign-in addon for dev and tests" matches the main change. The PR adds an opt-in mockatoo addon to the CLI. The addon gives a GitHub sign-in button that uses Mockatoo in development and tests. The changeset covers the CLI addon registry, compatibility rules, schemas, template generation, env vars, and the Better Auth templates, which all support this addon. The title is specific and concise, and it fits the changes described in the summary.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Mockatoo add flow for existing projects writes no changes.
Selecting mockatoo for an existing project does not add its files, dependency, env keys, or sign-in button. addHandler still records the addon and reports success. The Mockatoo branches are in creation-only processors (processAuthDeps, the env processors, and base templates). processAddonsDeps and processAddonTemplates have no matching output. Users can therefore see "Added mockatoo" without GitHub sign-in being enabled.
Either implement the existing-project path, or reject mockatoo in the add command before the addon is recorded. The implementation path must update the auth server, the sign-in form, the env schema, and the dependency set. The rejection path must keep mockatoo unavailable to existing-project adds.
The reason will be displayed to describe this comment to others. Learn more.
Major · Security & Privacy · Quick win
Enable mock authentication only in development and tests.
If NODE_ENV is unset or has an unexpected value in a deployed server, this branch enables mockGitHub. Line 69 also disables the real GitHub provider. Production therefore depends on an exact environment value to exclude mock authentication.
Use an explicit allowlist for "development" and "test" in both branches. Default all other values to the real provider.
Based on learnings, development-only behavior must default to production-safe behavior when the environment is unset or misconfigured.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Show an error when GitHub sign-in fails to start.
The GitHub button discards the result of authClient.signIn.social. If the request returns an error, the user can remain on the form with no message. The email sign-in path reports the same kind of failure with toast.error.
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
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
Implements #1305: an opt-in
--addons mockatoothat adds GitHub sign-in to the Better Auth template, using a mock OAuth provider outside production.@required=forEnv(production)in the Varlock schema.Evidence
devruns.After:
create-better-t-stack --frontend next --auth better-auth --addons mockatooscaffolds a "Continue with GitHub" button that works immediately in dev. Verified end-to-end today against a generated split-origin app (web on:3001, API server on:3002): Playwright drives the full flow — click the button → Mockatoo consent → callback on the API origin → back to the web app's/dashboard, signed in.bun run check,bun run build:cli, and the CLI test suite (bun test ./test --timeout 30000) all pass; 112/112 tests. (At the default 5s timeout one test times out onmainas well.)Summary by CodeRabbit