refactor(cli): simplify database selection flags

This commit is contained in:
Aman Varshney
2025-02-18 09:59:17 +05:30
parent 6d03d6b97e
commit 64fc644235
7 changed files with 19 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
refactor(cli): simplify database selection flags

View File

@@ -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,

View File

@@ -50,7 +50,7 @@ export async function createProject(options: ProjectConfig) {
await tasks(tasksList);
if (options.database === "libsql") {
if (options.database === "sqlite") {
await setupTurso(projectDir);
}

View File

@@ -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 <type>", "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<ProjectConfig> = {
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"

View File

@@ -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";

View File

@@ -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) {

View File

@@ -17,8 +17,6 @@ export const TITLE_TEXT = `
║ ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗ ║
║ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║
║ ║
║ The Modern Full-Stack Framework ║
║ ║
╚════════════════════════════════════════════════════════════╝
`;