-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code and fix bugs close #19
Co-Authored-By: ruru <[email protected]>
- Loading branch information
Showing
47 changed files
with
12,816 additions
and
7,502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"workbench.colorTheme": "Tokyo Night", | ||
"workbench.startupEditor": "none", | ||
"files.autoSave": "afterDelay", | ||
"glassit.alpha": 245, | ||
"glassit.force_sway": true, | ||
"workbench.iconTheme": "material-icon-theme", | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"hediet.vscode-drawio.resizeImages": null, | ||
"[html]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"tabnine.experimentalAutoImports": true, | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"[less]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[css]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"glassit.step": 500, | ||
"bitoAI.codeCompletion.enableCommentToCode": true, | ||
"bitoAI.codeCompletion.enableAutoCompletion": true, | ||
"cmake.options.statusBarVisibility": "hidden" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const findImageUrlByUserName = async (userName: string) => { | ||
const user = await db.user.findUnique({ | ||
where: { | ||
username: userName, | ||
}, | ||
}); | ||
let image = user?.image; | ||
return image; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const fetchrepo = async (username: string, repository: string) => { | ||
if (!username && !repository) { | ||
return { error: "Invalid user!" }; | ||
} | ||
|
||
const repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
}, | ||
}); | ||
console.log(repo) | ||
return { repo: repo }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const create = async () => { | ||
const commitresult = await db.commit.create({ | ||
data: { | ||
commitId: "3", | ||
title: "Initial Commit", | ||
description: " Initial Commit of the repository", | ||
branch: "master", | ||
repositoryId: "65c339bbf67715e59d92337d", | ||
}, | ||
}); | ||
return { | ||
success: "create commit Successfully! 🎉", | ||
commitresult: commitresult, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use server"; | ||
|
||
import * as z from "zod"; | ||
|
||
import { db } from "@/lib/db"; | ||
import { RepoSchema } from "@/schemas"; | ||
import { User } from "@prisma/client"; | ||
|
||
export const create = async ( | ||
values: z.infer<typeof RepoSchema>, | ||
user: User | ||
) => { | ||
const validatedFields = RepoSchema.safeParse(values); | ||
|
||
if (!validatedFields.success) { | ||
return { error: "Invalid fields!" }; | ||
} | ||
|
||
const { name, description, visibility, branch } = validatedFields.data; | ||
|
||
if (!user?.username) { | ||
return { error: "Invalid user!" }; | ||
} | ||
const existingRepo = await db.repository.findFirst({ | ||
where: { | ||
name: name, | ||
author: user?.username, | ||
}, | ||
}); | ||
|
||
console.log(existingRepo); | ||
|
||
if (existingRepo) { | ||
return { error: "Repository already exist with this name!" }; | ||
} | ||
|
||
if (user?.username && user?.id) { | ||
const repository = await db.repository.create({ | ||
data: { | ||
name: name, | ||
description: description, | ||
Visibility: visibility, | ||
author: user?.username, | ||
authorId: user?.id, | ||
DefualtBranch: branch, | ||
}, | ||
}); | ||
|
||
await db.branch.create({ | ||
data: { | ||
name: branch, | ||
repositoryId: repository.id, | ||
}, | ||
}); | ||
return { success: "Repository create Successfully! 🎉" }; | ||
} else { | ||
return { error: "Invalid user!" }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
import { User } from "@prisma/client"; | ||
|
||
export const fetchRepo = async ( | ||
username: string, | ||
repository: string, | ||
user?: User | null | ||
) => { | ||
if (!username || !repository) { | ||
return { error: "Invalid user or repository!" }; | ||
} | ||
|
||
let repo; | ||
|
||
if (user?.username === username) { | ||
repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
}, | ||
}); | ||
} else { | ||
repo = await db.repository.findFirst({ | ||
where: { | ||
name: repository, | ||
author: username, | ||
Visibility: "public", | ||
}, | ||
}); | ||
} | ||
|
||
if (!repo) { | ||
return { error: "Repository not found!", statuscode: 404 }; | ||
} | ||
|
||
const branches = await db.branch.findMany({ | ||
where: { | ||
repositoryId: repo.id, | ||
}, | ||
}); | ||
|
||
return { repo, branchCount: branches.length }; | ||
}; |
Oops, something went wrong.