mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Rename database environment variables for consistency
This commit is contained in:
5
.changeset/great-mirrors-appear.md
Normal file
5
.changeset/great-mirrors-appear.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Rename database environment variables for consistency
|
||||||
@@ -56,8 +56,8 @@ export async function setupEnvironmentVariables(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.database === "sqlite" && options.dbSetup !== "turso") {
|
if (options.database === "sqlite" && options.dbSetup !== "turso") {
|
||||||
if (!envContent.includes("TURSO_CONNECTION_URL")) {
|
if (!envContent.includes("DATABASE_URL")) {
|
||||||
envContent += "\nTURSO_CONNECTION_URL=file:./local.db";
|
envContent += "\nDATABASE_URL=file:./local.db";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,11 +104,6 @@ function getDatabaseInstructions(
|
|||||||
instructions.push(`${pc.cyan("•")} Apply schema: ${`${runCmd} db:push`}`);
|
instructions.push(`${pc.cyan("•")} Apply schema: ${`${runCmd} db:push`}`);
|
||||||
instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`);
|
instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`);
|
||||||
} else if (orm === "drizzle") {
|
} 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("•")} Apply schema: ${`${runCmd} db:push`}`);
|
||||||
instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`);
|
instructions.push(`${pc.cyan("•")} Database UI: ${`${runCmd} db:studio`}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,10 +157,10 @@ async function createTursoDatabase(
|
|||||||
async function writeEnvFile(projectDir: string, config?: TursoConfig) {
|
async function writeEnvFile(projectDir: string, config?: TursoConfig) {
|
||||||
const envPath = path.join(projectDir, "apps/server", ".env");
|
const envPath = path.join(projectDir, "apps/server", ".env");
|
||||||
const envContent = config
|
const envContent = config
|
||||||
? `TURSO_CONNECTION_URL="${config.dbUrl}"
|
? `DATABASE_URL="${config.dbUrl}"
|
||||||
TURSO_AUTH_TOKEN="${config.authToken}"`
|
DATABASE_AUTH_TOKEN="${config.authToken}"`
|
||||||
: `TURSO_CONNECTION_URL=
|
: `DATABASE_URL=
|
||||||
TURSO_AUTH_TOKEN=`;
|
DATABASE_AUTH_TOKEN=`;
|
||||||
|
|
||||||
await fs.writeFile(envPath, envContent);
|
await fs.writeFile(envPath, envContent);
|
||||||
}
|
}
|
||||||
@@ -173,8 +173,8 @@ function displayManualSetupInstructions() {
|
|||||||
3. Get your database URL and authentication token
|
3. Get your database URL and authentication token
|
||||||
4. Add these credentials to the .env file in apps/server/.env
|
4. Add these credentials to the .env file in apps/server/.env
|
||||||
|
|
||||||
TURSO_CONNECTION_URL=your_database_url
|
DATABASE_URL=your_database_url
|
||||||
TURSO_AUTH_TOKEN=your_auth_token`);
|
DATABASE_AUTH_TOKEN=your_auth_token`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupTurso(
|
export async function setupTurso(
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ export async function getDatabaseChoice(
|
|||||||
{
|
{
|
||||||
value: "sqlite",
|
value: "sqlite",
|
||||||
label: "SQLite",
|
label: "SQLite",
|
||||||
hint: "by Turso",
|
hint: "lightweight, server-less, embedded relational database management system",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "postgres",
|
value: "postgres",
|
||||||
label: "PostgreSQL",
|
label: "PostgreSQL",
|
||||||
hint: "Traditional relational database",
|
hint: "powerful, open source object-relational database system",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "mongodb",
|
value: "mongodb",
|
||||||
label: "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,
|
initialValue: DEFAULT_CONFIG.database,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export async function getORMChoice(
|
|||||||
{
|
{
|
||||||
value: "drizzle",
|
value: "drizzle",
|
||||||
label: "Drizzle",
|
label: "Drizzle",
|
||||||
hint: "Type-safe, lightweight ORM",
|
hint: "lightweight and performant TypeScript ORM",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "prisma",
|
value: "prisma",
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ function validateDirectoryName(name: string): string | undefined {
|
|||||||
if (name.startsWith(".") || name.startsWith("-")) {
|
if (name.startsWith(".") || name.startsWith("-")) {
|
||||||
return "Project name cannot start with a dot or dash";
|
return "Project name cannot start with a dot or dash";
|
||||||
}
|
}
|
||||||
if (
|
if (name.toLowerCase() === "node_modules") {
|
||||||
name.toLowerCase() === "node_modules" ||
|
|
||||||
name.toLowerCase() === "favicon.ico"
|
|
||||||
) {
|
|
||||||
return "Project name is reserved";
|
return "Project name is reserved";
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
|
|||||||
flags.push(`--orm ${config.orm}`);
|
flags.push(`--orm ${config.orm}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.dbSetup && config.dbSetup !== "none") {
|
if (config.dbSetup) {
|
||||||
flags.push(`--db-setup ${config.dbSetup}`);
|
flags.push(`--db-setup ${config.dbSetup}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default defineConfig({
|
|||||||
out: "./src/db/migrations",
|
out: "./src/db/migrations",
|
||||||
dialect: "turso",
|
dialect: "turso",
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: process.env.TURSO_CONNECTION_URL || "",
|
url: process.env.DATABASE_URL || "",
|
||||||
authToken: process.env.TURSO_AUTH_TOKEN,
|
authToken: process.env.DATABASE_AUTH_TOKEN,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { drizzle } from "drizzle-orm/libsql";
|
|||||||
import { createClient } from "@libsql/client";
|
import { createClient } from "@libsql/client";
|
||||||
|
|
||||||
const client = createClient({
|
const client = createClient({
|
||||||
url: process.env.TURSO_CONNECTION_URL || "",
|
url: process.env.DATABASE_URL || "",
|
||||||
authToken: process.env.TURSO_AUTH_TOKEN,
|
authToken: process.env.DATABASE_AUTH_TOKEN ,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const db = drizzle({ client });
|
export const db = drizzle({ client });
|
||||||
|
|||||||
Reference in New Issue
Block a user