[PR #7832] [CLOSED] feat(cli): init command refactor #15826

Closed
opened 2026-04-13 10:14:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7832
Author: @jslno
Created: 2/6/2026
Status: Closed

Base: canaryHead: 02-06-2026/init-cli


📝 Commits (10+)

📊 Changes

40 files changed (+14178 additions, -2448 deletions)

View changed files

📝 knip.jsonc (+19 -2)
📝 packages/cli/package.json (+1 -0)
packages/cli/src/commands/init.ts (+0 -1175)
packages/cli/src/commands/init/configs/databases.config.ts (+444 -0)
packages/cli/src/commands/init/configs/frameworks.config.ts (+212 -0)
packages/cli/src/commands/init/configs/social-providers.config.ts (+252 -0)
packages/cli/src/commands/init/configs/temp-plugins.config.ts (+1813 -0)
packages/cli/src/commands/init/generate-auth-client.ts (+66 -0)
packages/cli/src/commands/init/generate-auth.ts (+180 -0)
packages/cli/src/commands/init/index.ts (+1650 -0)
packages/cli/src/commands/init/utility/auth-client-config.ts (+37 -0)
packages/cli/src/commands/init/utility/auth-config.test.ts (+80 -0)
packages/cli/src/commands/init/utility/auth-config.ts (+109 -0)
packages/cli/src/commands/init/utility/database.test.ts (+200 -0)
packages/cli/src/commands/init/utility/database.ts (+200 -0)
packages/cli/src/commands/init/utility/env.test.ts (+252 -0)
packages/cli/src/commands/init/utility/env.ts (+74 -0)
packages/cli/src/commands/init/utility/format.ts (+7 -0)
packages/cli/src/commands/init/utility/framework.test.ts (+572 -0)
packages/cli/src/commands/init/utility/framework.ts (+48 -0)

...and 20 more files

📄 Description

Upstream #7964
Based upon #6325


Summary by cubic

Refactors the better-auth init into a modular generator that auto-detects frameworks/databases, scaffolds route handlers, and generates auth + auth-client with smarter env and config-path discovery. Improves package manager detection/installs and centralizes CLI version/title while fixing default paths and DB adapter installs.

  • New Features

    • Auto-detect frameworks (package.json + file scan) and scaffold route handlers with framework-specific auth-client imports.
    • Generate auth/auth-client with plugins and social providers; scan/update .env*; discover auth/client config paths via new utility.
    • Detect package manager from env, lockfiles, and monorepo/workspaces; install with correct flags across npm/yarn/pnpm/bun.
  • Refactors

    • Replaced legacy init and old generator with modular configs/utilities (frameworks, databases, plugins, imports, env, prompts).
    • Centralized CLI version export and improved title; enhanced get-package-info (hasDependency, monorepo root).
    • Removed pnpm catalog support and unused utils; added comprehensive memfs-based tests for init flow, env/framework/imports/plugins, installers, and package manager detection; updated knip (implicit deps + project globs).

Written for commit bb46ce6b88. 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/7832 **Author:** [@jslno](https://github.com/jslno) **Created:** 2/6/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `02-06-2026/init-cli` --- ### 📝 Commits (10+) - [`4af846f`](https://github.com/better-auth/better-auth/commit/4af846fcca1eb8e9c8feb08962e257d6f982262c) refactor: `init`cmd - [`a83a687`](https://github.com/better-auth/better-auth/commit/a83a6878b911a5d5033daabd1b5aed6c382d9165) chore: add tests - [`b0665b9`](https://github.com/better-auth/better-auth/commit/b0665b9a26e7fb201f53aa229d6b2667727c66db) chore: update tests - [`0643bcc`](https://github.com/better-auth/better-auth/commit/0643bccda9330df9139c09744e2917bbb073b09b) chore: undo unwanted changes - [`af838bc`](https://github.com/better-auth/better-auth/commit/af838bcae1816b1f9beed9bc6bd05b0b9d2d8a0b) chore: update tests - [`2c6d04e`](https://github.com/better-auth/better-auth/commit/2c6d04ea11ec85fca84fe718717dfa01fdb17a8d) chore: cleanup - [`0498cfc`](https://github.com/better-auth/better-auth/commit/0498cfcfbf5186ec3816666f4588f33890469b51) chore: fix import - [`b4f0d0c`](https://github.com/better-auth/better-auth/commit/b4f0d0c267d793b41e0cd305598ef8e7cfc1ea80) chore: fix duplicate flag - [`91a11a9`](https://github.com/better-auth/better-auth/commit/91a11a9e213a1d3dd8e47c0e07aefd690384ca85) chore: update - [`aae6081`](https://github.com/better-auth/better-auth/commit/aae6081b048890f037614becc16013996ac0aeba) chore: update ### 📊 Changes **40 files changed** (+14178 additions, -2448 deletions) <details> <summary>View changed files</summary> 📝 `knip.jsonc` (+19 -2) 📝 `packages/cli/package.json` (+1 -0) ➖ `packages/cli/src/commands/init.ts` (+0 -1175) ➕ `packages/cli/src/commands/init/configs/databases.config.ts` (+444 -0) ➕ `packages/cli/src/commands/init/configs/frameworks.config.ts` (+212 -0) ➕ `packages/cli/src/commands/init/configs/social-providers.config.ts` (+252 -0) ➕ `packages/cli/src/commands/init/configs/temp-plugins.config.ts` (+1813 -0) ➕ `packages/cli/src/commands/init/generate-auth-client.ts` (+66 -0) ➕ `packages/cli/src/commands/init/generate-auth.ts` (+180 -0) ➕ `packages/cli/src/commands/init/index.ts` (+1650 -0) ➕ `packages/cli/src/commands/init/utility/auth-client-config.ts` (+37 -0) ➕ `packages/cli/src/commands/init/utility/auth-config.test.ts` (+80 -0) ➕ `packages/cli/src/commands/init/utility/auth-config.ts` (+109 -0) ➕ `packages/cli/src/commands/init/utility/database.test.ts` (+200 -0) ➕ `packages/cli/src/commands/init/utility/database.ts` (+200 -0) ➕ `packages/cli/src/commands/init/utility/env.test.ts` (+252 -0) ➕ `packages/cli/src/commands/init/utility/env.ts` (+74 -0) ➕ `packages/cli/src/commands/init/utility/format.ts` (+7 -0) ➕ `packages/cli/src/commands/init/utility/framework.test.ts` (+572 -0) ➕ `packages/cli/src/commands/init/utility/framework.ts` (+48 -0) _...and 20 more files_ </details> ### 📄 Description Upstream #7964 Based upon #6325 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Refactors the better-auth init into a modular generator that auto-detects frameworks/databases, scaffolds route handlers, and generates auth + auth-client with smarter env and config-path discovery. Improves package manager detection/installs and centralizes CLI version/title while fixing default paths and DB adapter installs. - **New Features** - Auto-detect frameworks (package.json + file scan) and scaffold route handlers with framework-specific auth-client imports. - Generate auth/auth-client with plugins and social providers; scan/update .env*; discover auth/client config paths via new utility. - Detect package manager from env, lockfiles, and monorepo/workspaces; install with correct flags across npm/yarn/pnpm/bun. - **Refactors** - Replaced legacy init and old generator with modular configs/utilities (frameworks, databases, plugins, imports, env, prompts). - Centralized CLI version export and improved title; enhanced get-package-info (hasDependency, monorepo root). - Removed pnpm catalog support and unused utils; added comprehensive memfs-based tests for init flow, env/framework/imports/plugins, installers, and package manager detection; updated knip (implicit deps + project globs). <sup>Written for commit bb46ce6b882ed46ddc25bfca61f07e82c0738db7. 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-13 10:14:51 -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#15826