This commit is contained in:
Rizky 2024-08-15 21:19:18 +07:00
parent 08b5c64b3c
commit f9f47d861c
1 changed files with 7 additions and 9 deletions

View File

@ -27,7 +27,7 @@ export const _ = {
| { type: "redeploy"; ts: string } | { type: "redeploy"; ts: string }
) & { ) & {
id_site: string; id_site: string;
}, }
) { ) {
const { res } = apiContext(this); const { res } = apiContext(this);
@ -107,20 +107,20 @@ export const _ = {
datasource db { datasource db {
provider = "${type}" provider = "${type}"
url = env("DATABASE_URL") url = env("DATABASE_URL")
}`, }`
); );
try { try {
await Bun.write( await Bun.write(
dir("app/db/.env"), dir("app/db/.env"),
`DATABASE_URL=${ENV.DATABASE_URL}`, `DATABASE_URL=${ENV.DATABASE_URL}`
); );
await $`bun install`.cwd(dir("app/db")); await $`bun install`.cwd(dir("app/db"));
await $`bun prisma db pull --force`.cwd(dir("app/db")); await $`bun prisma db pull --force`.cwd(dir("app/db"));
await $`bun prisma generate`.cwd(dir("app/db")); await $`bun prisma generate`.cwd(dir("app/db"));
await Bun.write( await Bun.write(
dir(`${g.datadir}/db-ver`), dir(`${g.datadir}/db-ver`),
Date.now().toString(), Date.now().toString()
); );
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -168,9 +168,7 @@ export const _ = {
const deploys = fs.readdirSync(dir(`/app/web/deploy`)); const deploys = fs.readdirSync(dir(`/app/web/deploy`));
if (g.mode === "prod") { if (g.mode === "prod") {
setTimeout(() => { postMessage("restart");
process.exit();
}, 500);
} }
return { return {
@ -205,7 +203,7 @@ export const _ = {
export const downloadFile = async ( export const downloadFile = async (
url: string, url: string,
filePath: string, filePath: string,
progress?: (rec: number, total: number) => void, progress?: (rec: number, total: number) => void
) => { ) => {
try { try {
const _url = new URL(url); const _url = new URL(url);
@ -238,7 +236,7 @@ export const downloadFile = async (
if (progress) { if (progress) {
progress( progress(
receivedLength, receivedLength,
parseInt(res.headers.get("content-length") || "0"), parseInt(res.headers.get("content-length") || "0")
); );
} }
} }