[PR #4280] [CLOSED] fix(cli): simplify and correct comma insertion logic in plugin array #22189

Closed
opened 2026-04-15 20:52:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4280
Author: @bytaesu
Created: 8/28/2025
Status: Closed

Base: canaryHead: fix/cli-generator-bug


📝 Commits (10+)

  • dbaae0a docs: hero section alignment with feature section on big screens (#4018)
  • ef481d8 chore: fix broken testomnial link
  • 9c46196 fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization
  • 5fdf5cd chore: update sso docs
  • efa60af chore: fix import typo
  • 3fd8581 docs: hero section alignment with feature section on big screens (#4018)
  • 64216f1 chore: fix broken testomnial link
  • 28e331a fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization
  • efa0c0b chore: update sso docs
  • 95f9e9a chore: fix import typo

📊 Changes

16 files changed (+1154 additions, -66 deletions)

View changed files

📝 docs/app/global.css (+1 -1)
📝 docs/components/sidebar-content.tsx (+20 -0)
docs/content/blogs/0-supabase-auth-to-planetscale-migration.mdx (+370 -0)
📝 docs/content/docs/concepts/users-accounts.mdx (+1 -1)
docs/content/docs/guides/auth0-migration-guide.mdx (+654 -0)
📝 docs/content/docs/integrations/remix.mdx (+2 -2)
📝 docs/content/docs/integrations/svelte-kit.mdx (+1 -1)
📝 docs/content/docs/plugins/2fa.mdx (+2 -0)
📝 docs/content/docs/plugins/admin.mdx (+44 -39)
📝 docs/content/docs/plugins/community-plugins.mdx (+2 -0)
📝 docs/content/docs/reference/resources.mdx (+16 -3)
docs/public/blogs/supabase-ps.png (+0 -0)
📝 docs/source.config.ts (+0 -2)
📝 packages/better-auth/package.json (+1 -0)
📝 packages/cli/src/generators/auth-config.ts (+9 -17)
📝 packages/cli/test/generate.test.ts (+31 -0)

📄 Description


This PR fixes an edge case bug by simplifying and cleaning up the plugin insertion logic.


For example:

◇  Would you like to set up plugins?
│  Yes
│
◇  Select your new plugins
│  none
│
◇  It looks like you're using NextJS. Do you want to add the next-cookies plugin? (Recommended)
│  Yes

Result:

import { nextCookies } from "better-auth/next-js";
import { betterAuth } from "better-auth";

export const auth = betterAuth({
    appName: "testing",
    plugins: [, nextCookies()],
});

Bug fix test:

before after

Summary by cubic

Fixes the CLI generator so adding a plugin never produces an empty element or stray commas in the plugins array. This prevents invalid configs like plugins: [, nextCookies()] and makes plugin insertion reliable.

  • Bug Fixes

    • Simplified plugin insertion: detect empty arrays and trailing commas, then insert with or without a comma as needed.
    • Fixed return path to use the new content directly.
    • Added a test to cover insertion into an empty plugins array.
  • Docs

    • Added “Auth0 Migration Guide” and a blog: “Migrate from Supabase Auth to Better Auth + PlanetScale PostgreSQL”; updated sidebar navigation.
    • Fixed small issues: Remix auth-client import paths, SvelteKit version callout, admin listUsers params (now under query), 2FA table reference.
    • Added new community plugins and resource videos; tweaked site selection color and simplified blog author schema.

🔄 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/4280 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 8/28/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/cli-generator-bug` --- ### 📝 Commits (10+) - [`dbaae0a`](https://github.com/better-auth/better-auth/commit/dbaae0ab2bc39de87dd4719e37f48e4b94ea2262) docs: hero section alignment with feature section on big screens (#4018) - [`ef481d8`](https://github.com/better-auth/better-auth/commit/ef481d8dcce32d377b412ad1a96ecb8e604c1787) chore: fix broken testomnial link - [`9c46196`](https://github.com/better-auth/better-auth/commit/9c4619626856bd4adbaa4564dd8c110921b1f498) fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization - [`5fdf5cd`](https://github.com/better-auth/better-auth/commit/5fdf5cd31a6099ee96e922470eca8adf92c5bc51) chore: update sso docs - [`efa60af`](https://github.com/better-auth/better-auth/commit/efa60af1c2d45a735ed397171bfca513b7e202ca) chore: fix import typo - [`3fd8581`](https://github.com/better-auth/better-auth/commit/3fd858163a393153386c4bb2795abfacd09f091e) docs: hero section alignment with feature section on big screens (#4018) - [`64216f1`](https://github.com/better-auth/better-auth/commit/64216f13250200169717f47225a17df08d2fee2a) chore: fix broken testomnial link - [`28e331a`](https://github.com/better-auth/better-auth/commit/28e331a114ad0cb4e5968c29685c2f7e24187fcc) fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization - [`efa0c0b`](https://github.com/better-auth/better-auth/commit/efa0c0ba1b4793d14a2f3f355a82e4086ed4338a) chore: update sso docs - [`95f9e9a`](https://github.com/better-auth/better-auth/commit/95f9e9a39a5b3ca5192dcd174025da1427f01458) chore: fix import typo ### 📊 Changes **16 files changed** (+1154 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `docs/app/global.css` (+1 -1) 📝 `docs/components/sidebar-content.tsx` (+20 -0) ➕ `docs/content/blogs/0-supabase-auth-to-planetscale-migration.mdx` (+370 -0) 📝 `docs/content/docs/concepts/users-accounts.mdx` (+1 -1) ➕ `docs/content/docs/guides/auth0-migration-guide.mdx` (+654 -0) 📝 `docs/content/docs/integrations/remix.mdx` (+2 -2) 📝 `docs/content/docs/integrations/svelte-kit.mdx` (+1 -1) 📝 `docs/content/docs/plugins/2fa.mdx` (+2 -0) 📝 `docs/content/docs/plugins/admin.mdx` (+44 -39) 📝 `docs/content/docs/plugins/community-plugins.mdx` (+2 -0) 📝 `docs/content/docs/reference/resources.mdx` (+16 -3) ➕ `docs/public/blogs/supabase-ps.png` (+0 -0) 📝 `docs/source.config.ts` (+0 -2) 📝 `packages/better-auth/package.json` (+1 -0) 📝 `packages/cli/src/generators/auth-config.ts` (+9 -17) 📝 `packages/cli/test/generate.test.ts` (+31 -0) </details> ### 📄 Description --- This PR fixes an edge case bug by simplifying and cleaning up the plugin insertion logic. --- For example: ``` ◇ Would you like to set up plugins? │ Yes │ ◇ Select your new plugins │ none │ ◇ It looks like you're using NextJS. Do you want to add the next-cookies plugin? (Recommended) │ Yes ``` Result: ```ts import { nextCookies } from "better-auth/next-js"; import { betterAuth } from "better-auth"; export const auth = betterAuth({ appName: "testing", plugins: [, nextCookies()], }); ``` Bug fix test: <img width="400" alt="before" src="https://github.com/user-attachments/assets/038d8d11-98d3-412d-89c1-5fa00d855018" /> <img width="400" alt="after" src="https://github.com/user-attachments/assets/48574ad5-0476-4ec3-ac37-377cee241f08" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes the CLI generator so adding a plugin never produces an empty element or stray commas in the plugins array. This prevents invalid configs like plugins: [, nextCookies()] and makes plugin insertion reliable. - **Bug Fixes** - Simplified plugin insertion: detect empty arrays and trailing commas, then insert with or without a comma as needed. - Fixed return path to use the new content directly. - Added a test to cover insertion into an empty plugins array. - **Docs** - Added “Auth0 Migration Guide” and a blog: “Migrate from Supabase Auth to Better Auth + PlanetScale PostgreSQL”; updated sidebar navigation. - Fixed small issues: Remix auth-client import paths, SvelteKit version callout, admin listUsers params (now under query), 2FA table reference. - Added new community plugins and resource videos; tweaked site selection color and simplified blog author schema. <!-- 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 20:52:38 -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#22189