feat: last used at

This commit is contained in:
Lorenzo Migliorero
2024-07-25 22:15:40 +02:00
parent c681aa2e9f
commit 71555a15f8
2 changed files with 11 additions and 0 deletions

View File

@@ -55,7 +55,9 @@ export const apiUpdateSshKey = createSchema
.pick({ .pick({
name: true, name: true,
description: true, description: true,
lastUsedAt: true,
}) })
.partial()
.merge( .merge(
createSchema createSchema
.pick({ .pick({

View File

@@ -1,5 +1,6 @@
import { createWriteStream } from "node:fs"; import { createWriteStream } from "node:fs";
import path, { join } from "node:path"; import path, { join } from "node:path";
import { updateSSHKeyById } from "@/server/api/services/ssh-key";
import { APPLICATIONS_PATH, COMPOSE_PATH, SSH_PATH } from "@/server/constants"; import { APPLICATIONS_PATH, COMPOSE_PATH, SSH_PATH } from "@/server/constants";
import { TRPCError } from "@trpc/server"; import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory"; import { recreateDirectory } from "../filesystem/directory";
@@ -40,6 +41,13 @@ export const cloneGitRepository = async (
`\nCloning Repo Custom ${customGitUrl} to ${outputPath}: ✅\n`, `\nCloning Repo Custom ${customGitUrl} to ${outputPath}: ✅\n`,
); );
if (customGitSSHKeyId) {
await updateSSHKeyById({
sshKeyId: customGitSSHKeyId,
lastUsedAt: new Date().toISOString(),
});
}
await spawnAsync( await spawnAsync(
"git", "git",
[ [
@@ -66,6 +74,7 @@ export const cloneGitRepository = async (
}, },
}, },
); );
writeStream.write(`\nCloned Custom Git ${customGitUrl}: ✅\n`); writeStream.write(`\nCloned Custom Git ${customGitUrl}: ✅\n`);
} catch (error) { } catch (error) {
writeStream.write(`\nERROR Cloning Custom Git: ${error}: ❌\n`); writeStream.write(`\nERROR Cloning Custom Git: ${error}: ❌\n`);