From 64fc64423561000304f72cde1e2886b677796f62 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Tue, 18 Feb 2025 09:59:17 +0530 Subject: [PATCH] refactor(cli): simplify database selection flags --- .changeset/real-pillows-beam.md | 5 +++++ apps/cli/src/consts.ts | 2 +- apps/cli/src/helpers/create-project.ts | 2 +- apps/cli/src/index.ts | 15 ++++++++++----- apps/cli/src/types.ts | 2 +- .../src/utils/generate-reproducible-command.ts | 2 +- apps/cli/src/utils/render-title.ts | 2 -- 7 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 .changeset/real-pillows-beam.md diff --git a/.changeset/real-pillows-beam.md b/.changeset/real-pillows-beam.md new file mode 100644 index 0000000..3bf87ba --- /dev/null +++ b/.changeset/real-pillows-beam.md @@ -0,0 +1,5 @@ +--- +"create-better-t-stack": patch +--- + +refactor(cli): simplify database selection flags diff --git a/apps/cli/src/consts.ts b/apps/cli/src/consts.ts index 4232374..de14d87 100644 --- a/apps/cli/src/consts.ts +++ b/apps/cli/src/consts.ts @@ -8,7 +8,7 @@ export const PKG_ROOT = path.join(distPath, "../"); export const DEFAULT_CONFIG: ProjectConfig = { projectName: "my-better-t-app", - database: "libsql", + database: "sqlite", auth: true, features: [], git: true, diff --git a/apps/cli/src/helpers/create-project.ts b/apps/cli/src/helpers/create-project.ts index b57dc27..a50e599 100644 --- a/apps/cli/src/helpers/create-project.ts +++ b/apps/cli/src/helpers/create-project.ts @@ -50,7 +50,7 @@ export async function createProject(options: ProjectConfig) { await tasks(tasksList); - if (options.database === "libsql") { + if (options.database === "sqlite") { await setupTurso(projectDir); } diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index b05ae40..805647a 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -90,9 +90,9 @@ async function gatherConfig( message: "Which database would you like to use?", options: [ { - value: "libsql", - label: "libSQL", - hint: "Turso's embedded SQLite database (recommended)", + value: "sqlite", + label: "SQLite", + hint: "by Turso (recommended)", }, { value: "postgres", @@ -232,7 +232,8 @@ async function main() { .version(getVersion()) .argument("[project-directory]", "Project name/directory") .option("-y, --yes", "Use default configuration") - .option("--database ", "Database type (libsql or postgres)") + .option("--sqlite", "Use SQLite database") + .option("--postgres", "Use PostgreSQL database") .option("--auth", "Include authentication") .option("--no-auth", "Exclude authentication") .option("--docker", "Include Docker setup") @@ -251,7 +252,11 @@ async function main() { const flagConfig: Partial = { projectName: projectDirectory || undefined, - database: options.database as ProjectDatabase | undefined, + database: options.sqlite + ? "sqlite" + : options.postgres + ? "postgres" + : undefined, auth: "auth" in options ? options.auth : undefined, packageManager: options.npm ? "npm" diff --git a/apps/cli/src/types.ts b/apps/cli/src/types.ts index 7446e5a..11f5983 100644 --- a/apps/cli/src/types.ts +++ b/apps/cli/src/types.ts @@ -1,6 +1,6 @@ export type ProjectFeature = "docker" | "github-actions" | "SEO"; -export type ProjectDatabase = "libsql" | "postgres"; +export type ProjectDatabase = "sqlite" | "postgres"; export type PackageManager = "npm" | "yarn" | "pnpm" | "bun"; diff --git a/apps/cli/src/utils/generate-reproducible-command.ts b/apps/cli/src/utils/generate-reproducible-command.ts index 8d22300..f4b6c35 100644 --- a/apps/cli/src/utils/generate-reproducible-command.ts +++ b/apps/cli/src/utils/generate-reproducible-command.ts @@ -15,7 +15,7 @@ export function generateReproducibleCommand(config: ProjectConfig): string { } if (config.database !== DEFAULT_CONFIG.database) { - flags.push(`--database ${config.database}`); + flags.push(config.database === "sqlite" ? "--sqlite" : "--postgres"); } if (config.auth !== DEFAULT_CONFIG.auth) { diff --git a/apps/cli/src/utils/render-title.ts b/apps/cli/src/utils/render-title.ts index ab5bdaf..92c3b34 100644 --- a/apps/cli/src/utils/render-title.ts +++ b/apps/cli/src/utils/render-title.ts @@ -17,8 +17,6 @@ export const TITLE_TEXT = ` ║ ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗ ║ ║ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║ ║ ║ - ║ The Modern Full-Stack Framework ║ - ║ ║ ╚════════════════════════════════════════════════════════════╝ `;