mirror of
https://github.com/web3privacy/explorer-app.git
synced 2024-10-15 16:46:26 +02:00
Merge pull request #36 from web3privacy/dw/fix-project-id
fix: project id check
This commit is contained in:
commit
82a878933d
1 changed files with 54 additions and 49 deletions
|
@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody<{ project: Project, image?: { type: string, data: string } }>(event)
|
const body = await readBody<{ project: Project, image?: { type: string, data: string } }>(event)
|
||||||
const { appId, privateKey, installationId, baseBranch, owner, repo } = useRuntimeConfig().app.github
|
const { appId, privateKey, installationId, baseBranch, owner, repo } = useRuntimeConfig().app.github
|
||||||
|
|
||||||
const id = (body.project.id && body.project.id === body.project.name.toLowerCase().replace(/\s+/g, '-'))
|
const id = (body.project.id && body.project.id.toLowerCase() === body.project.name.toLowerCase().replace(/\s+/g, '-'))
|
||||||
? body.project.id
|
? body.project.id
|
||||||
: body.project.name.toLowerCase().replace(/\s+/g, '-')
|
: body.project.name.toLowerCase().replace(/\s+/g, '-')
|
||||||
|
|
||||||
|
@ -131,6 +131,7 @@ export default defineEventHandler(async (event) => {
|
||||||
files: { path: string, content: string, encoding: string }[],
|
files: { path: string, content: string, encoding: string }[],
|
||||||
deletedFiles: string[] = [],
|
deletedFiles: string[] = [],
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
const { data: latestCommit } = await octokit.rest.repos.getCommit({
|
const { data: latestCommit } = await octokit.rest.repos.getCommit({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
|
@ -187,6 +188,10 @@ export default defineEventHandler(async (event) => {
|
||||||
sha: newCommit.sha,
|
sha: newCommit.sha,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error('Error during commit operation:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function createPullRequest(owner: string, repo: string, head: string, base: string, title: string, body: string) {
|
async function createPullRequest(owner: string, repo: string, head: string, base: string, title: string, body: string) {
|
||||||
const { data: pullRequest } = await octokit.rest.pulls.create({
|
const { data: pullRequest } = await octokit.rest.pulls.create({
|
||||||
|
@ -206,7 +211,7 @@ export default defineEventHandler(async (event) => {
|
||||||
console.log(`Branch ${newBranchName} created successfully!`)
|
console.log(`Branch ${newBranchName} created successfully!`)
|
||||||
|
|
||||||
const deletedFiles = []
|
const deletedFiles = []
|
||||||
if (body.project.id && body.project.id !== body.project.name.toLowerCase().replace(/\s+/g, '-')) {
|
if (body.project.id && body.project.id.toLowerCase() !== body.project.name.toLowerCase().replace(/\s+/g, '-')) {
|
||||||
const oldId = body.project.id
|
const oldId = body.project.id
|
||||||
const oldFolderPath = `src/projects/${oldId}`
|
const oldFolderPath = `src/projects/${oldId}`
|
||||||
await deleteOldProjectFolder(owner, repo, newBranchName, oldFolderPath)
|
await deleteOldProjectFolder(owner, repo, newBranchName, oldFolderPath)
|
||||||
|
|
Loading…
Reference in a new issue