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

Open
opened 2026-04-15 22:41:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8624
Author: @luchersou
Created: 3/16/2026
Status: 🔄 Open

Base: mainHead: fix/cli-version-warning-1.5.x


📝 Commits (8)

  • 6811b3d fix: warn when old CLI is used with better-auth v1.5.x+
  • 8907ac2 fix: use import.meta.resolve for better-auth version detection
  • acf0142 fix: apply biome formatting
  • 75e4a87 fix: remove unknown word from comment
  • 5ffec34 fix: separate ANSI escape from npx to fix cspell
  • 17e59d8 fix: use createRequire + walk-up for robust better-auth version detection
  • 21b5aef style: fix trailing newline
  • 7e3467f fix: resolve better-auth from project cwd, not CLI install path

📊 Changes

1 file changed (+39 additions, -0 deletions)

View changed files

📝 packages/cli/src/index.ts (+39 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8624 **Author:** [@luchersou](https://github.com/luchersou) **Created:** 3/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cli-version-warning-1.5.x` --- ### 📝 Commits (8) - [`6811b3d`](https://github.com/better-auth/better-auth/commit/6811b3d1a8e2b595b509daf5a4a8dc9f83ad95dd) fix: warn when old CLI is used with better-auth v1.5.x+ - [`8907ac2`](https://github.com/better-auth/better-auth/commit/8907ac2c79d8cbb941bb92355761e6a64f4f16d5) fix: use import.meta.resolve for better-auth version detection - [`acf0142`](https://github.com/better-auth/better-auth/commit/acf014239b8aaf26b1969be467940e1db5809499) fix: apply biome formatting - [`75e4a87`](https://github.com/better-auth/better-auth/commit/75e4a87d5d80ec62ca1a80f7b0afa5a8652890fb) fix: remove unknown word from comment - [`5ffec34`](https://github.com/better-auth/better-auth/commit/5ffec34a17b9b7f14a7c44afad164c87c10b71ab) fix: separate ANSI escape from npx to fix cspell - [`17e59d8`](https://github.com/better-auth/better-auth/commit/17e59d860117b89efa807d3c014c3919b904dee0) fix: use createRequire + walk-up for robust better-auth version detection - [`21b5aef`](https://github.com/better-auth/better-auth/commit/21b5aefde95f549967bb26e854b849f718339a18) style: fix trailing newline - [`7e3467f`](https://github.com/better-auth/better-auth/commit/7e3467f4e5d0097484726db3658f66ce2264450e) fix: resolve better-auth from project cwd, not CLI install path ### 📊 Changes **1 file changed** (+39 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/index.ts` (+39 -0) </details> ### 📄 Description 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:41:10 -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#25002