diff --git a/.changeset/great-mirrors-appear.md b/.changeset/great-mirrors-appear.md new file mode 100644 index 0000000..98b2dfd --- /dev/null +++ b/.changeset/great-mirrors-appear.md @@ -0,0 +1,5 @@ +--- +"create-better-t-stack": patch +--- + +Rename database environment variables for consistency diff --git a/apps/cli/src/helpers/env-setup.ts b/apps/cli/src/helpers/env-setup.ts index 2ae5a3c..04eece0 100644 --- a/apps/cli/src/helpers/env-setup.ts +++ b/apps/cli/src/helpers/env-setup.ts @@ -56,8 +56,8 @@ export async function setupEnvironmentVariables( } if (options.database === "sqlite" && options.dbSetup !== "turso") { - if (!envContent.includes("TURSO_CONNECTION_URL")) { - envContent += "\nTURSO_CONNECTION_URL=file:./local.db"; + if (!envContent.includes("DATABASE_URL")) { + envContent += "\nDATABASE_URL=file:./local.db"; } } } diff --git a/apps/cli/src/helpers/post-installation.ts b/apps/cli/src/helpers/post-installation.ts index 1e43c5f..0b629c1 100644 --- a/apps/cli/src/helpers/post-installation.ts +++ b/apps/cli/src/helpers/post-installation.ts @@ -104,11 +104,6 @@ function getDatabaseInstructions( instructions.push(`${pc.cyan("•")} Apply schema: ${`${runCmd} db:push`}`); instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`); } else if (orm === "drizzle") { - if (database === "sqlite") { - instructions.push( - `${pc.cyan("•")} Start local DB: ${`cd apps/server && ${runCmd} db:local`}`, - ); - } instructions.push(`${pc.cyan("•")} Apply schema: ${`${runCmd} db:push`}`); instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`); } diff --git a/apps/cli/src/helpers/turso-setup.ts b/apps/cli/src/helpers/turso-setup.ts index 71f9af5..7b3f5f7 100644 --- a/apps/cli/src/helpers/turso-setup.ts +++ b/apps/cli/src/helpers/turso-setup.ts @@ -157,10 +157,10 @@ async function createTursoDatabase( async function writeEnvFile(projectDir: string, config?: TursoConfig) { const envPath = path.join(projectDir, "apps/server", ".env"); const envContent = config - ? `TURSO_CONNECTION_URL="${config.dbUrl}" -TURSO_AUTH_TOKEN="${config.authToken}"` - : `TURSO_CONNECTION_URL= -TURSO_AUTH_TOKEN=`; + ? `DATABASE_URL="${config.dbUrl}" +DATABASE_AUTH_TOKEN="${config.authToken}"` + : `DATABASE_URL= +DATABASE_AUTH_TOKEN=`; await fs.writeFile(envPath, envContent); } @@ -173,8 +173,8 @@ function displayManualSetupInstructions() { 3. Get your database URL and authentication token 4. Add these credentials to the .env file in apps/server/.env -TURSO_CONNECTION_URL=your_database_url -TURSO_AUTH_TOKEN=your_auth_token`); +DATABASE_URL=your_database_url +DATABASE_AUTH_TOKEN=your_auth_token`); } export async function setupTurso( diff --git a/apps/cli/src/prompts/database.ts b/apps/cli/src/prompts/database.ts index 7f79cf7..484b7ab 100644 --- a/apps/cli/src/prompts/database.ts +++ b/apps/cli/src/prompts/database.ts @@ -19,17 +19,17 @@ export async function getDatabaseChoice( { value: "sqlite", label: "SQLite", - hint: "by Turso", + hint: "lightweight, server-less, embedded relational database management system", }, { value: "postgres", label: "PostgreSQL", - hint: "Traditional relational database", + hint: "powerful, open source object-relational database system", }, { value: "mongodb", label: "MongoDB", - hint: "NoSQL document-oriented database", + hint: "open-source NoSQL database that stores data in JSON-like documents called BSON", }, ], initialValue: DEFAULT_CONFIG.database, diff --git a/apps/cli/src/prompts/orm.ts b/apps/cli/src/prompts/orm.ts index 0daabf0..56d5070 100644 --- a/apps/cli/src/prompts/orm.ts +++ b/apps/cli/src/prompts/orm.ts @@ -22,7 +22,7 @@ export async function getORMChoice( { value: "drizzle", label: "Drizzle", - hint: "Type-safe, lightweight ORM", + hint: "lightweight and performant TypeScript ORM", }, { value: "prisma", diff --git a/apps/cli/src/prompts/project-name.ts b/apps/cli/src/prompts/project-name.ts index 2727f13..0058ca6 100644 --- a/apps/cli/src/prompts/project-name.ts +++ b/apps/cli/src/prompts/project-name.ts @@ -21,10 +21,7 @@ function validateDirectoryName(name: string): string | undefined { if (name.startsWith(".") || name.startsWith("-")) { return "Project name cannot start with a dot or dash"; } - if ( - name.toLowerCase() === "node_modules" || - name.toLowerCase() === "favicon.ico" - ) { + if (name.toLowerCase() === "node_modules") { return "Project name is reserved"; } return undefined; diff --git a/apps/cli/src/utils/generate-reproducible-command.ts b/apps/cli/src/utils/generate-reproducible-command.ts index e04fc17..200377c 100644 --- a/apps/cli/src/utils/generate-reproducible-command.ts +++ b/apps/cli/src/utils/generate-reproducible-command.ts @@ -12,7 +12,7 @@ export function generateReproducibleCommand(config: ProjectConfig): string { flags.push(`--orm ${config.orm}`); } - if (config.dbSetup && config.dbSetup !== "none") { + if (config.dbSetup) { flags.push(`--db-setup ${config.dbSetup}`); } } diff --git a/apps/cli/template/with-drizzle-sqlite/apps/server/drizzle.config.ts b/apps/cli/template/with-drizzle-sqlite/apps/server/drizzle.config.ts index a36b162..b2190e7 100644 --- a/apps/cli/template/with-drizzle-sqlite/apps/server/drizzle.config.ts +++ b/apps/cli/template/with-drizzle-sqlite/apps/server/drizzle.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ out: "./src/db/migrations", dialect: "turso", dbCredentials: { - url: process.env.TURSO_CONNECTION_URL || "", - authToken: process.env.TURSO_AUTH_TOKEN, + url: process.env.DATABASE_URL || "", + authToken: process.env.DATABASE_AUTH_TOKEN, }, }); diff --git a/apps/cli/template/with-drizzle-sqlite/apps/server/src/db/index.ts b/apps/cli/template/with-drizzle-sqlite/apps/server/src/db/index.ts index 9a1e9eb..6797ec0 100644 --- a/apps/cli/template/with-drizzle-sqlite/apps/server/src/db/index.ts +++ b/apps/cli/template/with-drizzle-sqlite/apps/server/src/db/index.ts @@ -2,8 +2,8 @@ import { drizzle } from "drizzle-orm/libsql"; import { createClient } from "@libsql/client"; const client = createClient({ - url: process.env.TURSO_CONNECTION_URL || "", - authToken: process.env.TURSO_AUTH_TOKEN, + url: process.env.DATABASE_URL || "", + authToken: process.env.DATABASE_AUTH_TOKEN , }); export const db = drizzle({ client });