update schema option - #73
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
@proofkit/better-auth
@proofkit/cli
create-proofkit
@proofkit/fmdapi
@proofkit/typegen
@proofkit/webviewer
commit: |
WalkthroughUpdated CLI add prompts to conditionally show Schema based on presence of data sources, added a new Data Source option, and introduced React Email in the main add flow. Adjusted shadcn component installation by removing the --overwrite flag from the command construction. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant CLI as CLI Add (runAddFromRegistry)
participant P as Prompt
U->>CLI: invoke add from registry
CLI->>P: build choices
alt dataSources.length > 0
Note over P: Include Schema option
else
Note over P: Omit Schema option
end
Note over P: Always include Data Source
P-->>U: present choices
U-->>P: select category
P-->>CLI: return selection
CLI->>CLI: proceed with selected category flow
sequenceDiagram
autonumber
participant U as User
participant CLI as CLI Add (runAdd)
participant P as Prompt
U->>CLI: invoke add
CLI->>P: build choices
alt dataSources.length > 0
Note over P: Include Schema
else
Note over P: Omit Schema
end
Note over P: Include Page, Data Source, React Email
P-->>U: present choices
U-->>P: select category
P-->>CLI: return selection
CLI->>CLI: proceed with selected category flow
sequenceDiagram
autonumber
participant C as Caller
participant H as shadcn-cli helper
participant EX as execa
C->>H: shadcnInstall(componentsArray)
H->>EX: run ["shadcn@latest","add",...componentsArray]
Note over H,EX: No --overwrite flag
EX-->>H: result / error
H-->>C: propagate outcome
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/cli/src/cli/add/index.ts (1)
141-155: Make the schema visibility check null-safe; addition of React Email looks goodGuard
settings.dataSourcesaccess. The new "React Email" option and "Data Source" entry integrate cleanly with the subsequent handlers.- // only show schema option if there is at least one data source - ...(settings.dataSources.length > 0 + // only show schema option if there is at least one data source + ...(((settings.dataSources?.length ?? 0) > 0) ? [ { label: "Schema", value: "schema", hint: "load data from a new table or layout from an existing data source", }, ] : []),
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/cli/src/cli/add/index.ts(2 hunks)packages/cli/src/helpers/shadcn-cli.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: build
| // only show schema option if there is at least one data source | ||
| ...(settings.dataSources.length > 0 | ||
| ? [ | ||
| { | ||
| label: "Data Source", | ||
| value: "data", | ||
| hint: "to connect to a new database or FileMaker file", | ||
| label: "Schema", | ||
| value: "schema", | ||
| hint: "load data from a new table or layout from an existing data source", | ||
| }, | ||
| ] | ||
| : []), | ||
|
|
||
| { | ||
| label: "Data Source", | ||
| value: "data", | ||
| hint: "to connect to a new database or FileMaker file", | ||
| }, | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Avoid collisions with registry categories; make data source check null-safe
Using values "schema" and "data" can collide with registry categories of the same name, causing the wrong branch to run. Also guard against settings.dataSources being undefined.
Apply:
- // only show schema option if there is at least one data source
- ...(settings.dataSources.length > 0
+ // only show schema option if there is at least one data source
+ ...(((settings.dataSources?.length ?? 0) > 0)
? [
{
- label: "Schema",
- value: "schema",
+ label: "Schema",
+ value: "__builtin:schema",
hint: "load data from a new table or layout from an existing data source",
},
]
: []),
- {
- label: "Data Source",
- value: "data",
- hint: "to connect to a new database or FileMaker file",
- },
+ {
+ label: "Data Source",
+ value: "__builtin:data",
+ hint: "to connect to a new database or FileMaker file",
+ },
- // show the rest of the categories
- ...categories
- .filter((category) => category !== "page")
+ // show the rest of the categories (exclude built-ins that we handle specially)
+ ...categories
+ .filter((category) => !["page", "schema", "data"].includes(category))
.map((category) => ({
label: capitalize(category),
value: category,
})),And update the selection handling:
- if (addType === "schema") {
+ if (addType === "__builtin:schema") {
await runAddSchemaAction();
- } else if (addType === "data") {
+ } else if (addType === "__builtin:data") {
await runAddDataSourceCommand();If you prefer not to change the selected values, at least exclude "schema" and "data" from the categories list to prevent duplicate options mapping to the same value.
Also applies to: 72-79, 83-87
| ) { | ||
| const componentsArray = Array.isArray(components) ? components : [components]; | ||
| const command = ["shadcn@latest", "add", ...componentsArray, "--overwrite"]; | ||
| const command = ["shadcn@latest", "add", ...componentsArray]; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Dropping --overwrite can cause interactive conflicts and non-idempotent installs
Without --overwrite, re-adding an already-added component may prompt/hang (especially in CI) or silently skip updates, leading to drift. Prefer a controlled toggle rather than removing it outright.
Proposed non-breaking toggle (opt-in), preserving current default:
export async function shadcnInstall(
components: string | string[],
- friendlyComponentName?: string
+ friendlyComponentName?: string,
+ options?: { overwrite?: boolean }
) {
const componentsArray = Array.isArray(components) ? components : [components];
- const command = ["shadcn@latest", "add", ...componentsArray];
+ const command = ["shadcn@latest", "add", ...componentsArray, ...(options?.overwrite ? ["--overwrite"] : [])];Optionally, auto-enable overwrite in CI to avoid prompts (verify state shape first):
- const command = ["shadcn@latest", "add", ...componentsArray, ...(options?.overwrite ? ["--overwrite"] : [])];
+ const shouldOverwrite = options?.overwrite ?? Boolean((state as any)?.ci || (process.env.CI === "true"));
+ const command = ["shadcn@latest", "add", ...componentsArray, ...(shouldOverwrite ? ["--overwrite"] : [])];To verify whether state.ci exists and is set by ciOption, run:
🏁 Script executed:
#!/bin/bash
rg -n -C2 'ciOption|state\.(ci|program\..*ci)|initProgramState' packages/cliLength of output: 17388
Add optional --overwrite toggle to shadcnInstall
Without --overwrite, re-running shadcn add can prompt, hang, or silently skip updates, causing drift. Extend the helper’s signature and command array:
export async function shadcnInstall(
components: string | string[],
- friendlyComponentName?: string
+ friendlyComponentName?: string,
+ options?: { overwrite?: boolean }
) {
const componentsArray = Array.isArray(components) ? components : [components];
- const command = ["shadcn@latest", "add", ...componentsArray];
+ const shouldOverwrite = options?.overwrite ?? state.ci;
+ const command = [
+ "shadcn@latest",
+ "add",
+ ...componentsArray,
+ ...(shouldOverwrite ? ["--overwrite"] : []),
+ ];state.ci is already set via ciOption and initProgramState, so CI runs will default to overwrite and avoid interactive prompts.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const command = ["shadcn@latest", "add", ...componentsArray]; | |
| export async function shadcnInstall( | |
| components: string | string[], | |
| friendlyComponentName?: string, | |
| options?: { overwrite?: boolean } | |
| ) { | |
| const componentsArray = Array.isArray(components) ? components : [components]; | |
| const shouldOverwrite = options?.overwrite ?? state.ci; | |
| const command = [ | |
| "shadcn@latest", | |
| "add", | |
| ...componentsArray, | |
| ...(shouldOverwrite ? ["--overwrite"] : []), | |
| ]; | |
| // …rest of function… | |
| } |
🤖 Prompt for AI Agents
In packages/cli/src/helpers/shadcn-cli.ts around line 16, the constructed
command array lacks an optional '--overwrite' flag; update the shadcnInstall
helper signature to accept an optional overwrite boolean (default false) or use
state.ci to decide behavior, then conditionally push '--overwrite' into the
command array when overwrite === true || state.ci === true so CI runs and
explicit calls avoid interactive prompts and file-skipping issues; ensure the
function's call sites are adjusted or the default preserves current behavior.

Summary by CodeRabbit
New Features
Chores