Skip to content

Commit 98310e4

Browse files
[autofix.ci] apply automated fixes
1 parent e6d05a7 commit 98310e4

File tree

2 files changed

+105
-87
lines changed

2 files changed

+105
-87
lines changed

packages/server/src/services/application.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import {
1313
} from "@dokploy/server/utils/builders";
1414
import { sendBuildErrorNotifications } from "@dokploy/server/utils/notifications/build-error";
1515
import { sendBuildSuccessNotifications } from "@dokploy/server/utils/notifications/build-success";
16-
import { execAsync, execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
16+
import {
17+
execAsync,
18+
execAsyncRemote,
19+
} from "@dokploy/server/utils/process/execAsync";
1720
import {
1821
cloneBitbucketRepository,
1922
getBitbucketCloneCommand,
@@ -102,7 +105,11 @@ const tryUpdateWithGitInfoLocal = async (
102105
};
103106

104107
const tryUpdateWithGitInfoRemote = async (
105-
application: Application & { appName: string; env: string | null; serverId: string },
108+
application: Application & {
109+
appName: string;
110+
env: string | null;
111+
serverId: string;
112+
},
106113
deploymentId: string,
107114
defaultTitle: string,
108115
defaultDescription: string,

packages/server/src/services/compose.ts

Lines changed: 96 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -54,95 +54,106 @@ import { eq } from "drizzle-orm";
5454
import { encodeBase64 } from "../utils/docker/utils";
5555
import { paths } from "@dokploy/server/constants";
5656
import { join } from "node:path";
57-
import { execAsync, execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
57+
import {
58+
execAsync,
59+
execAsyncRemote,
60+
} from "@dokploy/server/utils/process/execAsync";
5861
import { getDokployUrl } from "./admin";
59-
import { createDeploymentCompose, updateDeployment, updateDeploymentStatus } from "./deployment";
62+
import {
63+
createDeploymentCompose,
64+
updateDeployment,
65+
updateDeploymentStatus,
66+
} from "./deployment";
6067
import { validUniqueServerAppName } from "./project";
6168

6269
export type Compose = typeof compose.$inferSelect;
6370

6471
const tryUpdateWithGitInfoLocal = async (
65-
composeEntity: Compose & { appName: string; env: string | null },
66-
deploymentId: string,
67-
defaultTitle: string,
68-
defaultDescription: string,
72+
composeEntity: Compose & { appName: string; env: string | null },
73+
deploymentId: string,
74+
defaultTitle: string,
75+
defaultDescription: string,
6976
) => {
70-
try {
71-
const { COMPOSE_PATH } = paths();
72-
const codePath = join(COMPOSE_PATH, composeEntity.appName, "code");
73-
const { stdout: hashStdout } = await execAsync(
74-
`git -C ${codePath} rev-parse HEAD`,
75-
);
76-
const gitHash = hashStdout.trim();
77-
const { stdout: msgStdout } = await execAsync(
78-
`git -C ${codePath} log -1 --pretty=%B`,
79-
);
80-
const gitMessage = msgStdout.trim();
81-
82-
if (gitHash) {
83-
const current = composeEntity.env || "";
84-
const withoutOld = current
85-
.split("\n")
86-
.filter((l) => l.trim() && !l.startsWith("GIT_HASH="))
87-
.join("\n");
88-
const newEnv = `${withoutOld}${withoutOld ? "\n" : ""}GIT_HASH=${gitHash}`;
89-
90-
// Update the database immediately
91-
await updateCompose(composeEntity.composeId as string, { env: newEnv });
92-
93-
// Update the local entity for consistency
94-
composeEntity.env = newEnv;
95-
}
96-
await updateDeployment(deploymentId, {
97-
title: gitMessage || defaultTitle,
98-
description: gitHash ? `Hash: ${gitHash}` : defaultDescription,
99-
});
100-
} catch (error) {
101-
// ignore if git data can't be fetched
102-
}
77+
try {
78+
const { COMPOSE_PATH } = paths();
79+
const codePath = join(COMPOSE_PATH, composeEntity.appName, "code");
80+
const { stdout: hashStdout } = await execAsync(
81+
`git -C ${codePath} rev-parse HEAD`,
82+
);
83+
const gitHash = hashStdout.trim();
84+
const { stdout: msgStdout } = await execAsync(
85+
`git -C ${codePath} log -1 --pretty=%B`,
86+
);
87+
const gitMessage = msgStdout.trim();
88+
89+
if (gitHash) {
90+
const current = composeEntity.env || "";
91+
const withoutOld = current
92+
.split("\n")
93+
.filter((l) => l.trim() && !l.startsWith("GIT_HASH="))
94+
.join("\n");
95+
const newEnv = `${withoutOld}${withoutOld ? "\n" : ""}GIT_HASH=${gitHash}`;
96+
97+
// Update the database immediately
98+
await updateCompose(composeEntity.composeId as string, { env: newEnv });
99+
100+
// Update the local entity for consistency
101+
composeEntity.env = newEnv;
102+
}
103+
await updateDeployment(deploymentId, {
104+
title: gitMessage || defaultTitle,
105+
description: gitHash ? `Hash: ${gitHash}` : defaultDescription,
106+
});
107+
} catch (error) {
108+
// ignore if git data can't be fetched
109+
}
103110
};
104111

105112
const tryUpdateWithGitInfoRemote = async (
106-
composeEntity: Compose & { appName: string; env: string | null; serverId: string },
107-
deploymentId: string,
108-
defaultTitle: string,
109-
defaultDescription: string,
113+
composeEntity: Compose & {
114+
appName: string;
115+
env: string | null;
116+
serverId: string;
117+
},
118+
deploymentId: string,
119+
defaultTitle: string,
120+
defaultDescription: string,
110121
) => {
111-
try {
112-
const { COMPOSE_PATH } = paths(true);
113-
const codePath = join(COMPOSE_PATH, composeEntity.appName, "code");
114-
const { stdout: hashStdout } = await execAsyncRemote(
115-
composeEntity.serverId,
116-
`git -C ${codePath} rev-parse HEAD | tr -d '\n'`,
117-
);
118-
const gitHash = (hashStdout || "").trim();
119-
const { stdout: msgStdout } = await execAsyncRemote(
120-
composeEntity.serverId,
121-
`git -C ${codePath} log -1 --pretty=%B`,
122-
);
123-
const gitMessage = (msgStdout || "").trim();
124-
125-
if (gitHash) {
126-
const current = composeEntity.env || "";
127-
const withoutOld = current
128-
.split("\n")
129-
.filter((l) => l.trim() && !l.startsWith("GIT_HASH="))
130-
.join("\n");
131-
const newEnv = `${withoutOld}${withoutOld ? "\n" : ""}GIT_HASH=${gitHash}`;
132-
133-
// Update the database
134-
await updateCompose(composeEntity.composeId as string, { env: newEnv });
135-
136-
// Update the local entity for consistency
137-
composeEntity.env = newEnv;
138-
}
139-
await updateDeployment(deploymentId, {
140-
title: gitMessage || defaultTitle,
141-
description: gitHash ? `Hash: ${gitHash}` : defaultDescription,
142-
});
143-
} catch (error) {
144-
// ignore if git data can't be fetched
145-
}
122+
try {
123+
const { COMPOSE_PATH } = paths(true);
124+
const codePath = join(COMPOSE_PATH, composeEntity.appName, "code");
125+
const { stdout: hashStdout } = await execAsyncRemote(
126+
composeEntity.serverId,
127+
`git -C ${codePath} rev-parse HEAD | tr -d '\n'`,
128+
);
129+
const gitHash = (hashStdout || "").trim();
130+
const { stdout: msgStdout } = await execAsyncRemote(
131+
composeEntity.serverId,
132+
`git -C ${codePath} log -1 --pretty=%B`,
133+
);
134+
const gitMessage = (msgStdout || "").trim();
135+
136+
if (gitHash) {
137+
const current = composeEntity.env || "";
138+
const withoutOld = current
139+
.split("\n")
140+
.filter((l) => l.trim() && !l.startsWith("GIT_HASH="))
141+
.join("\n");
142+
const newEnv = `${withoutOld}${withoutOld ? "\n" : ""}GIT_HASH=${gitHash}`;
143+
144+
// Update the database
145+
await updateCompose(composeEntity.composeId as string, { env: newEnv });
146+
147+
// Update the local entity for consistency
148+
composeEntity.env = newEnv;
149+
}
150+
await updateDeployment(deploymentId, {
151+
title: gitMessage || defaultTitle,
152+
description: gitHash ? `Hash: ${gitHash}` : defaultDescription,
153+
});
154+
} catch (error) {
155+
// ignore if git data can't be fetched
156+
}
146157
};
147158

148159
export const createCompose = async (input: typeof apiCreateCompose._type) => {
@@ -370,14 +381,14 @@ export const deployCompose = async ({
370381
} else if (compose.sourceType === "raw") {
371382
await createComposeFile(compose, deployment.logPath);
372383
}
373-
384+
374385
// Refresh compose object from database to get updated environment variables
375386
const updatedCompose = await findComposeById(composeId);
376387
await buildCompose(updatedCompose, deployment.logPath);
377-
388+
378389
// Ensure environment update is completed before marking deployment as done
379-
await new Promise(resolve => setTimeout(resolve, 100));
380-
390+
await new Promise((resolve) => setTimeout(resolve, 100));
391+
381392
await updateDeploymentStatus(deployment.deploymentId, "done");
382393
await updateCompose(composeId, {
383394
composeStatus: "done",
@@ -438,7 +449,7 @@ export const rebuildCompose = async ({
438449
descriptionLog,
439450
);
440451
}
441-
452+
442453
// Refresh compose object from database to get updated environment variables
443454
const updatedCompose = await findComposeById(composeId);
444455
await buildCompose(updatedCompose, deployment.logPath);
@@ -518,7 +529,7 @@ export const deployRemoteCompose = async ({
518529
}
519530

520531
await execAsyncRemote(compose.serverId, command);
521-
532+
522533
// Update with git info for git-based source types
523534
if (compose.sourceType !== "raw") {
524535
await tryUpdateWithGitInfoRemote(
@@ -528,7 +539,7 @@ export const deployRemoteCompose = async ({
528539
descriptionLog,
529540
);
530541
}
531-
542+
532543
// Refresh compose object from database to get updated environment variables
533544
const updatedCompose = await findComposeById(composeId);
534545
await getBuildComposeCommand(updatedCompose, deployment.logPath);

0 commit comments

Comments
 (0)