feat(web): improve docs and refactor cli (#476)

This commit is contained in:
Aman Varshney
2025-08-08 16:00:10 +05:30
committed by GitHub
parent defa0e9464
commit 51cfb35912
34 changed files with 1336 additions and 1154 deletions

View File

@@ -2,6 +2,10 @@ import { cancel, isCancel, multiselect } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { API, Backend, Database, Examples, Frontend } from "../types";
import {
isExampleAIAllowed,
isExampleTodoAllowed,
} from "../utils/compatibility-rules";
export async function getExamplesChoice(
examples?: Examples[],
@@ -30,15 +34,17 @@ export async function getExamplesChoice(
if (noFrontendSelected) return [];
let response: Examples[] | symbol = [];
const options: { value: Examples; label: string; hint: string }[] = [
{
const options: { value: Examples; label: string; hint: string }[] = [];
if (isExampleTodoAllowed(backend, database)) {
options.push({
value: "todo" as const,
label: "Todo App",
hint: "A simple CRUD example app",
},
];
});
}
if (backend !== "elysia" && !frontends?.includes("solid")) {
if (isExampleAIAllowed(backend, frontends ?? [])) {
options.push({
value: "ai" as const,
label: "AI Chat",
@@ -46,11 +52,15 @@ export async function getExamplesChoice(
});
}
if (options.length === 0) return [];
response = await multiselect<Examples>({
message: "Include examples",
options: options,
required: false,
initialValues: DEFAULT_CONFIG.examples,
initialValues: DEFAULT_CONFIG.examples?.filter((ex) =>
options.some((o) => o.value === ex),
),
});
if (isCancel(response)) {