forked from t3-oss/create-t3-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbContainer.ts
28 lines (25 loc) · 881 Bytes
/
dbContainer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import fs from "fs";
import path from "path";
import { PKG_ROOT } from "~/consts.js";
import { type Installer } from "~/installers/index.js";
import { parseNameAndPath } from "~/utils/parseNameAndPath.js";
export const dbContainerInstaller: Installer = ({
projectDir,
databaseProvider,
projectName,
}) => {
const scriptSrc = path.join(
PKG_ROOT,
`template/extras/start-database/${databaseProvider}.sh`
);
const scriptText = fs.readFileSync(scriptSrc, "utf-8");
const scriptDest = path.join(projectDir, "start-database.sh");
// for configuration with postgresql and mysql when project is created with '.' project name
const [projectNameParsed] =
projectName == "." ? parseNameAndPath(projectDir) : [projectName];
fs.writeFileSync(
scriptDest,
scriptText.replaceAll("project1", projectNameParsed)
);
fs.chmodSync(scriptDest, "755");
};