[PR #8624] fix: warn when old CLI is used with better-auth v1.5.x+ #16348

Open
opened 2026-04-13 10:29:59 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8624

State: open
Merged: No


Closes #8622

What changed

Added a version check in packages/cli/src/index.ts that warns the user when the old @better-auth/cli is being used with a better-auth v1.5.x+ project.

Why

The old CLI can produce unexpected behavior when used with better-auth v1.5.x or later (e.g. generating a verifications table even when KV is configured). The warning guides the user to the new auth CLI before any damage is done.

How

  • Resolves the installed better-auth entry point via createRequire (works with npm, pnpm, Yarn PnP and hoisted monorepos)
  • Walks up the directory tree to find the nearest package.json with name === "better-auth"
  • Compares the version against 1.5.0 using semver (already a dependency)
  • Prints a warning to stderr and suggests npx auth@latest if the version is >= 1.5.0
  • Silently ignored if better-auth is not installed yet

Summary by cubic

Warns when the old @better-auth/cli runs in projects using better-auth v1.5.x+, and points users to the new auth CLI to avoid incorrect codegen.

  • New Features

    • Resolves better-auth from the project CWD (not the CLI install path) using createRequire, walks up to find its package.json, then checks the version with semver (>= 1.5.0).
    • Prints a yellow warning with the CLI and better-auth versions, and suggests npx auth@latest.
    • Silently skips if better-auth isn’t installed.
  • Refactors

    • Applied Biome formatting, fixed trailing newline, and minor comment cleanup.
    • Separated ANSI escape from the npx command to satisfy cspell.

Written for commit 7e3467f4e5. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8624 **State:** open **Merged:** No --- Closes #8622 ## What changed Added a version check in `packages/cli/src/index.ts` that warns the user when the old `@better-auth/cli` is being used with a `better-auth` v1.5.x+ project. ## Why The old CLI can produce unexpected behavior when used with better-auth v1.5.x or later (e.g. generating a `verifications` table even when KV is configured). The warning guides the user to the new `auth` CLI before any damage is done. ## How * Resolves the installed `better-auth` entry point via `createRequire` (works with npm, pnpm, Yarn PnP and hoisted monorepos) * Walks up the directory tree to find the nearest `package.json` with `name === "better-auth"` * Compares the version against `1.5.0` using `semver` (already a dependency) * Prints a warning to stderr and suggests `npx auth@latest` if the version is >= 1.5.0 * Silently ignored if `better-auth` is not installed yet <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Warns when the old `@better-auth/cli` runs in projects using `better-auth` v1.5.x+, and points users to the new `auth` CLI to avoid incorrect codegen. - **New Features** - Resolves `better-auth` from the project CWD (not the CLI install path) using `createRequire`, walks up to find its `package.json`, then checks the version with `semver` (>= 1.5.0). - Prints a yellow warning with the CLI and `better-auth` versions, and suggests `npx auth@latest`. - Silently skips if `better-auth` isn’t installed. - **Refactors** - Applied Biome formatting, fixed trailing newline, and minor comment cleanup. - Separated ANSI escape from the `npx` command to satisfy cspell. <sup>Written for commit 7e3467f4e5d0097484726db3658f66ce2264450e. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:29:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16348