mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix(cli): remove dublicate prisma db file
This commit is contained in:
@@ -203,32 +203,6 @@ async function addPrismaAccelerateExtension(serverDir: string) {
|
|||||||
projectDir: serverDir,
|
projectDir: serverDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
const prismaIndexPath = path.join(serverDir, "prisma/index.ts");
|
|
||||||
const prismaIndexContent = `
|
|
||||||
import { PrismaClient } from "./generated/client";
|
|
||||||
import { withAccelerate } from "@prisma/extension-accelerate";
|
|
||||||
|
|
||||||
const prisma = new PrismaClient().$extends(withAccelerate());
|
|
||||||
|
|
||||||
export default prisma;
|
|
||||||
`;
|
|
||||||
await fs.writeFile(prismaIndexPath, prismaIndexContent.trim());
|
|
||||||
|
|
||||||
const dbFilePath = path.join(serverDir, "src/db/index.ts");
|
|
||||||
if (await fs.pathExists(dbFilePath)) {
|
|
||||||
let dbFileContent = await fs.readFile(dbFilePath, "utf8");
|
|
||||||
|
|
||||||
if (!dbFileContent.includes("@prisma/extension-accelerate")) {
|
|
||||||
dbFileContent = `import { withAccelerate } from "@prisma/extension-accelerate";\n${dbFileContent}`;
|
|
||||||
|
|
||||||
dbFileContent = dbFileContent.replace(
|
|
||||||
"export const db = new PrismaClient();",
|
|
||||||
"export const db = new PrismaClient().$extends(withAccelerate());",
|
|
||||||
);
|
|
||||||
|
|
||||||
await fs.writeFile(dbFilePath, dbFileContent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
log.warn(
|
log.warn(
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import handlebars from "handlebars";
|
|||||||
import type { ProjectConfig } from "../types";
|
import type { ProjectConfig } from "../types";
|
||||||
import { formatFileWithBiome } from "./biome-formatter";
|
import { formatFileWithBiome } from "./biome-formatter";
|
||||||
|
|
||||||
const BINARY_EXTENSIONS = new Set([
|
const BINARY_EXTENSIONS = new Set([".png", ".ico", ".svg"]);
|
||||||
".png", ".ico", ".svg",
|
|
||||||
]);
|
|
||||||
|
|
||||||
function isBinaryFile(filePath: string): boolean {
|
function isBinaryFile(filePath: string): boolean {
|
||||||
const ext = path.extname(filePath).toLowerCase();
|
const ext = path.extname(filePath).toLowerCase();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { PrismaClient } from "../../prisma/generated/client";
|
import { PrismaClient } from "../../prisma/generated/client";
|
||||||
|
{{#if (or (eq dbSetup "prisma-postgres") (eq orm "prisma"))}}
|
||||||
|
import { withAccelerate } from "@prisma/extension-accelerate";
|
||||||
|
|
||||||
|
const prisma = new PrismaClient().$extends(withAccelerate());
|
||||||
|
{{else}}
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
"!**/schema.json",
|
"!**/schema.json",
|
||||||
"!**/_generated",
|
"!**/_generated",
|
||||||
"!**/.smoke",
|
"!**/.smoke",
|
||||||
"!**/global.css"
|
"!**/global.css",
|
||||||
|
"!**/package.json"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"formatter": {
|
"formatter": {
|
||||||
|
|||||||
Reference in New Issue
Block a user