chore(telemetry): add container-level self-healing repository folder migration hook

This commit is contained in:
2026-06-09 13:52:14 -07:00
parent 1284078799
commit b43dddac4e

View File

@@ -433,6 +433,32 @@ export async function execInDevContainer(
await resumeDevContainer(opts.projectId);
}
// Self-healing migration hook: Migrate legacy nested repositories to root /workspace
try {
const projectRow = await queryOne<{ slug: string }>(
`SELECT slug FROM fs_projects WHERE id = $1 LIMIT 1`,
[opts.projectId],
);
if (projectRow?.slug) {
const slug = projectRow.slug;
const migrationCmd =
`if [ -d "/workspace/${slug}" ] && [ ! -d "/workspace/.git" ]; then ` +
`mv /workspace/${slug}/* /workspace/ 2>/dev/null; ` +
`mv /workspace/${slug}/.* /workspace/ 2>/dev/null; ` +
`rmdir /workspace/${slug} 2>/dev/null; ` +
`fi`;
await execInCoolifyApp({
appUuid: row.service_uuid,
service: "vibn-dev",
command: migrationCmd,
user: "vibn",
timeoutMs: 10000,
}).catch(() => null);
}
} catch (err) {
// non-fatal best effort
}
const cwd = opts.cwd && opts.cwd.trim() ? opts.cwd.trim() : "/workspace";
const envPrefix = opts.env
? Object.entries(opts.env)