mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
refactor(cli): simplify database selection flags
This commit is contained in:
5
.changeset/real-pillows-beam.md
Normal file
5
.changeset/real-pillows-beam.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
refactor(cli): simplify database selection flags
|
||||||
@@ -8,7 +8,7 @@ export const PKG_ROOT = path.join(distPath, "../");
|
|||||||
|
|
||||||
export const DEFAULT_CONFIG: ProjectConfig = {
|
export const DEFAULT_CONFIG: ProjectConfig = {
|
||||||
projectName: "my-better-t-app",
|
projectName: "my-better-t-app",
|
||||||
database: "libsql",
|
database: "sqlite",
|
||||||
auth: true,
|
auth: true,
|
||||||
features: [],
|
features: [],
|
||||||
git: true,
|
git: true,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export async function createProject(options: ProjectConfig) {
|
|||||||
|
|
||||||
await tasks(tasksList);
|
await tasks(tasksList);
|
||||||
|
|
||||||
if (options.database === "libsql") {
|
if (options.database === "sqlite") {
|
||||||
await setupTurso(projectDir);
|
await setupTurso(projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ async function gatherConfig(
|
|||||||
message: "Which database would you like to use?",
|
message: "Which database would you like to use?",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
value: "libsql",
|
value: "sqlite",
|
||||||
label: "libSQL",
|
label: "SQLite",
|
||||||
hint: "Turso's embedded SQLite database (recommended)",
|
hint: "by Turso (recommended)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "postgres",
|
value: "postgres",
|
||||||
@@ -232,7 +232,8 @@ async function main() {
|
|||||||
.version(getVersion())
|
.version(getVersion())
|
||||||
.argument("[project-directory]", "Project name/directory")
|
.argument("[project-directory]", "Project name/directory")
|
||||||
.option("-y, --yes", "Use default configuration")
|
.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("--auth", "Include authentication")
|
||||||
.option("--no-auth", "Exclude authentication")
|
.option("--no-auth", "Exclude authentication")
|
||||||
.option("--docker", "Include Docker setup")
|
.option("--docker", "Include Docker setup")
|
||||||
@@ -251,7 +252,11 @@ async function main() {
|
|||||||
|
|
||||||
const flagConfig: Partial<ProjectConfig> = {
|
const flagConfig: Partial<ProjectConfig> = {
|
||||||
projectName: projectDirectory || undefined,
|
projectName: projectDirectory || undefined,
|
||||||
database: options.database as ProjectDatabase | undefined,
|
database: options.sqlite
|
||||||
|
? "sqlite"
|
||||||
|
: options.postgres
|
||||||
|
? "postgres"
|
||||||
|
: undefined,
|
||||||
auth: "auth" in options ? options.auth : undefined,
|
auth: "auth" in options ? options.auth : undefined,
|
||||||
packageManager: options.npm
|
packageManager: options.npm
|
||||||
? "npm"
|
? "npm"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export type ProjectFeature = "docker" | "github-actions" | "SEO";
|
export type ProjectFeature = "docker" | "github-actions" | "SEO";
|
||||||
|
|
||||||
export type ProjectDatabase = "libsql" | "postgres";
|
export type ProjectDatabase = "sqlite" | "postgres";
|
||||||
|
|
||||||
export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
|
export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.database !== DEFAULT_CONFIG.database) {
|
if (config.database !== DEFAULT_CONFIG.database) {
|
||||||
flags.push(`--database ${config.database}`);
|
flags.push(config.database === "sqlite" ? "--sqlite" : "--postgres");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.auth !== DEFAULT_CONFIG.auth) {
|
if (config.auth !== DEFAULT_CONFIG.auth) {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ export const TITLE_TEXT = `
|
|||||||
║ ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗ ║
|
║ ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗ ║
|
||||||
║ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║
|
║ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║
|
||||||
║ ║
|
║ ║
|
||||||
║ The Modern Full-Stack Framework ║
|
|
||||||
║ ║
|
|
||||||
╚════════════════════════════════════════════════════════════╝
|
╚════════════════════════════════════════════════════════════╝
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user