Add backend framework selection between hono, elysiajs

This commit is contained in:
Aman Varshney
2025-03-26 11:41:41 +05:30
parent b6b113766e
commit 91fe9f861f
40 changed files with 451 additions and 345 deletions

View File

@@ -1,5 +1,6 @@
import { cancel, isCancel, multiselect } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectAddons } from "../types";
export async function getAddonsChoice(
@@ -31,6 +32,7 @@ export async function getAddonsChoice(
hint: "Add Git hooks with Husky, lint-staged (requires Biome)",
},
],
initialValues: DEFAULT_CONFIG.addons,
required: false,
});

View File

@@ -1,5 +1,6 @@
// import { cancel, isCancel, select } from "@clack/prompts";
// import pc from "picocolors";
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { BackendFramework } from "../types";
export async function getBackendFrameworkChoice(
@@ -7,24 +8,27 @@ export async function getBackendFrameworkChoice(
): Promise<BackendFramework> {
if (backendFramework !== undefined) return backendFramework;
return "hono";
const response = await select<BackendFramework>({
message: "Which backend framework would you like to use?",
options: [
{
value: "hono",
label: "Hono",
hint: "Lightweight, ultrafast web framework",
},
{
value: "elysia",
label: "Elysia",
hint: "TypeScript framework with end-to-end type safety)",
},
],
initialValue: DEFAULT_CONFIG.backendFramework,
});
// const response = await select<BackendFramework>({
// message: "Which backend framework would you like to use?",
// options: [
// {
// value: "hono",
// label: "Hono",
// hint: "Lightweight, ultrafast web framework",
// },
// ],
// initialValue: "hono",
// });
if (isCancel(response)) {
cancel(pc.red("Operation cancelled"));
process.exit(0);
}
// if (isCancel(response)) {
// cancel(pc.red("Operation cancelled"));
// process.exit(0);
// }
// return response;
return response;
}

View File

@@ -46,8 +46,8 @@ export async function gatherConfig(
projectName: async () => {
return getProjectName(flags.projectName);
},
runtime: () => getRuntimeChoice(flags.runtime),
backendFramework: () => getBackendFrameworkChoice(flags.backendFramework),
runtime: () => getRuntimeChoice(flags.runtime),
database: () => getDatabaseChoice(flags.database),
orm: ({ results }) =>
getORMChoice(flags.orm, results.database !== "none"),

View File

@@ -1,5 +1,6 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectDatabase } from "../types";
export async function getDatabaseChoice(
@@ -26,7 +27,7 @@ export async function getDatabaseChoice(
hint: "Traditional relational database",
},
],
initialValue: "sqlite",
initialValue: DEFAULT_CONFIG.database,
});
if (isCancel(response)) {

View File

@@ -1,5 +1,6 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { ProjectOrm } from "../types";
export async function getORMChoice(
@@ -23,7 +24,7 @@ export async function getORMChoice(
hint: "Powerful, feature-rich ORM with schema migrations",
},
],
initialValue: "drizzle",
initialValue: DEFAULT_CONFIG.orm,
});
if (isCancel(response)) {

View File

@@ -1,5 +1,6 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
import type { Runtime } from "../types";
export async function getRuntimeChoice(runtime?: Runtime): Promise<Runtime> {
@@ -19,7 +20,7 @@ export async function getRuntimeChoice(runtime?: Runtime): Promise<Runtime> {
hint: "Traditional Node.js runtime",
},
],
initialValue: "bun",
initialValue: DEFAULT_CONFIG.runtime,
});
if (isCancel(response)) {

View File

@@ -1,12 +1,13 @@
import { cancel, confirm, isCancel } from "@clack/prompts";
import pc from "picocolors";
import { DEFAULT_CONFIG } from "../constants";
export async function getTursoSetupChoice(turso?: boolean): Promise<boolean> {
if (turso !== undefined) return turso;
const response = await confirm({
message: "Set up a Turso database for this project?",
initialValue: true,
initialValue: DEFAULT_CONFIG.turso,
});
if (isCancel(response)) {