Repository navigation
feat: add clerk auth support with convex #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1ac5946
292b8d1
a16a583
e6f1519
bff057c
e4c2b5f
da9f8cd
28c5b8e
39aa67d
5ab75f2
18e52cd
6846bd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ export async function addAddonsToProject( | |||||||||||||||
| frontend: detectedConfig.frontend || [], | ||||||||||||||||
| addons: input.addons, | ||||||||||||||||
| examples: detectedConfig.examples || [], | ||||||||||||||||
| auth: detectedConfig.auth || false, | ||||||||||||||||
| auth: detectedConfig.auth || "none", | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainNormalize legacy boolean If - auth: detectedConfig.auth || "none",
+ auth:
+ detectedConfig.auth === true
+ ? "better-auth"
+ : detectedConfig.auth === false || detectedConfig.auth == null
+ ? "none"
+ : detectedConfig.auth,Run to spot any remaining boolean usages or boolean fallbacks for 🏁 Script executed: #!/bin/bash
# Boolean comparisons against auth (should be none)
rg -nP -C2 '\bauth\s*===?\s*(true|false)\b' --type=ts --type=tsx
# Old-style fallbacks like `|| false` when assigning auth
rg -nP -C2 'auth\s*:\s*[^,]*\|\|\s*false' --type=ts --type=tsx
# Types that still declare auth as boolean
rg -nP -C2 '\bauth\s*:\s*boolean\b' --type=ts --type=tsx
# Configs that still store boolean auth
rg -nP -C2 '"auth"\s*:\s*(true|false)'Length of output: 613 Normalize legacy boolean
- auth: detectedConfig.auth || "none",
+ auth:
+ detectedConfig.auth === true
+ ? "better-auth"
+ : detectedConfig.auth === false || detectedConfig.auth == null
+ ? "none"
+ : detectedConfig.auth,
- "auth": true,
+ "auth": "better-auth",📝 Committable suggestion
Suggested change
|
||||||||||||||||
| git: false, | ||||||||||||||||
| packageManager: | ||||||||||||||||
| input.packageManager || detectedConfig.packageManager || "npm", | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import fs from "fs-extra"; | |||||||||||||||||||||||||||||||
| import type { | ||||||||||||||||||||||||||||||||
| Addons, | ||||||||||||||||||||||||||||||||
| API, | ||||||||||||||||||||||||||||||||
| Auth, | ||||||||||||||||||||||||||||||||
| Database, | ||||||||||||||||||||||||||||||||
| DatabaseSetup, | ||||||||||||||||||||||||||||||||
| Frontend, | ||||||||||||||||||||||||||||||||
|
|
@@ -98,7 +99,11 @@ This project uses Convex as a backend. You'll need to set up Convex before runni | |||||||||||||||||||||||||||||||
| ${packageManagerRunCmd} dev:setup | ||||||||||||||||||||||||||||||||
| \`\`\` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Follow the prompts to create a new Convex project and connect it to your application.` | ||||||||||||||||||||||||||||||||
| Follow the prompts to create a new Convex project and connect it to your application.${ | ||||||||||||||||||||||||||||||||
| auth === "clerk" | ||||||||||||||||||||||||||||||||
| ? " See [Convex + Clerk guide](https://docs.convex.dev/auth/clerk) for auth setup." | ||||||||||||||||||||||||||||||||
| : "" | ||||||||||||||||||||||||||||||||
| }` | ||||||||||||||||||||||||||||||||
| : generateDatabaseSetup( | ||||||||||||||||||||||||||||||||
| database, | ||||||||||||||||||||||||||||||||
| auth, | ||||||||||||||||||||||||||||||||
|
|
@@ -135,6 +140,7 @@ ${generateProjectStructure( | |||||||||||||||||||||||||||||||
| addons, | ||||||||||||||||||||||||||||||||
| isConvex, | ||||||||||||||||||||||||||||||||
| api, | ||||||||||||||||||||||||||||||||
| auth, | ||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||
| \`\`\` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -258,6 +264,7 @@ function generateProjectStructure( | |||||||||||||||||||||||||||||||
| addons: Addons[], | ||||||||||||||||||||||||||||||||
| isConvex: boolean, | ||||||||||||||||||||||||||||||||
| api: API, | ||||||||||||||||||||||||||||||||
| auth: Auth, | ||||||||||||||||||||||||||||||||
| ): string { | ||||||||||||||||||||||||||||||||
| const structure: string[] = [`${projectName}/`, "├── apps/"]; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -317,6 +324,12 @@ function generateProjectStructure( | |||||||||||||||||||||||||||||||
| structure.push( | ||||||||||||||||||||||||||||||||
| "│ └── backend/ # Convex backend functions and schema", | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| if (auth === "clerk") { | ||||||||||||||||||||||||||||||||
| structure.push( | ||||||||||||||||||||||||||||||||
| "│ ├── convex/ # Convex functions and schema", | ||||||||||||||||||||||||||||||||
| "│ └── .env.local # Convex environment variables", | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+327
to
+332
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Always show convex/ dir; gate .env.local by Clerk; fix tree connectors. Apply this diff: - if (auth === "clerk") {
- structure.push(
- "│ ├── convex/ # Convex functions and schema",
- "│ └── .env.local # Convex environment variables",
- );
- }
+ {
+ const hasClerkEnv = auth === "clerk";
+ structure.push(
+ `│ ${hasClerkEnv ? "├──" : "└──"} convex/ # Convex functions and schema`,
+ );
+ if (hasClerkEnv) {
+ structure.push("│ └── .env.local # Convex environment variables");
+ }
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } else if (!isBackendNone) { | ||||||||||||||||||||||||||||||||
| const backendName = backend[0].toUpperCase() + backend.slice(1); | ||||||||||||||||||||||||||||||||
| const apiName = api !== "none" ? api.toUpperCase() : ""; | ||||||||||||||||||||||||||||||||
|
|
@@ -329,7 +342,7 @@ function generateProjectStructure( | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| function generateFeaturesList( | ||||||||||||||||||||||||||||||||
| database: Database, | ||||||||||||||||||||||||||||||||
| auth: boolean, | ||||||||||||||||||||||||||||||||
| auth: Auth, | ||||||||||||||||||||||||||||||||
| addons: Addons[], | ||||||||||||||||||||||||||||||||
| orm: ORM, | ||||||||||||||||||||||||||||||||
| runtime: Runtime, | ||||||||||||||||||||||||||||||||
|
|
@@ -449,10 +462,9 @@ function generateFeaturesList( | |||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (auth && !isConvex) { | ||||||||||||||||||||||||||||||||
| addonsList.push( | ||||||||||||||||||||||||||||||||
| "- **Authentication** - Email & password authentication with Better Auth", | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| if (auth !== "none") { | ||||||||||||||||||||||||||||||||
| const authLabel = auth === "clerk" ? "Clerk" : "Better-Auth"; | ||||||||||||||||||||||||||||||||
| addonsList.push(`- **Authentication** - ${authLabel}`); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for (const addon of addons) { | ||||||||||||||||||||||||||||||||
|
|
@@ -476,7 +488,7 @@ function generateFeaturesList( | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| function generateDatabaseSetup( | ||||||||||||||||||||||||||||||||
| database: Database, | ||||||||||||||||||||||||||||||||
| _auth: boolean, | ||||||||||||||||||||||||||||||||
| _auth: Auth, | ||||||||||||||||||||||||||||||||
| packageManagerRunCmd: string, | ||||||||||||||||||||||||||||||||
| orm: ORM, | ||||||||||||||||||||||||||||||||
| dbSetup: DatabaseSetup, | ||||||||||||||||||||||||||||||||
|
|
@@ -575,7 +587,7 @@ function generateScriptsList( | |||||||||||||||||||||||||||||||
| packageManagerRunCmd: string, | ||||||||||||||||||||||||||||||||
| database: Database, | ||||||||||||||||||||||||||||||||
| orm: ORM, | ||||||||||||||||||||||||||||||||
| _auth: boolean, | ||||||||||||||||||||||||||||||||
| _auth: Auth, | ||||||||||||||||||||||||||||||||
| hasNative: boolean, | ||||||||||||||||||||||||||||||||
| addons: Addons[], | ||||||||||||||||||||||||||||||||
| backend: string, | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Good switch to discriminated union default for auth; verify there are no boolean remnants.
Setting
auth: "better-auth"with the enclosingas constis correct. Please ensure all CLI types, prompts, and templates no longer treatauthas boolean.Run to catch leftovers:
🏁 Script executed:
Length of output: 164051
Update CLI docs to use string-based
authinstead of booleanIn apps/web/content/docs/cli/programmatic-api.mdx (around lines 36, 272, 289), replace all
auth: trueexamples with the appropriate union values ("better-auth" | "clerk" | "none") and update theauth?: booleandeclaration to reflect the newAuthenum (auth?: "better-auth" | "clerk" | "none").🤖 Prompt for AI Agents