fix: 修复 Vercel 部署时的 TypeScript 类型和 ESLint 错误
- 修复 prisma/seed.ts 中显式连接表的类型错误 - 将 webhook 路由中的 console.log 改为 console.warn - 添加非空断言修复 badges.ts 中的类型错误 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+18
-4
@@ -125,21 +125,35 @@ async function main() {
|
|||||||
const { tagSlugs, links, ...rest } = projectData
|
const { tagSlugs, links, ...rest } = projectData
|
||||||
const projectTags = tags.filter(t => tagSlugs.includes(t.slug))
|
const projectTags = tags.filter(t => tagSlugs.includes(t.slug))
|
||||||
|
|
||||||
await prisma.project.upsert({
|
const project = await prisma.project.upsert({
|
||||||
where: { slug: rest.slug },
|
where: { slug: rest.slug },
|
||||||
update: {},
|
update: {},
|
||||||
create: {
|
create: {
|
||||||
...rest,
|
...rest,
|
||||||
status: ProjectStatus.ACTIVE,
|
status: ProjectStatus.ACTIVE,
|
||||||
source: 'manual',
|
source: 'manual',
|
||||||
tags: {
|
|
||||||
connect: projectTags.map(t => ({ id: t.id }))
|
|
||||||
},
|
|
||||||
links: {
|
links: {
|
||||||
create: links
|
create: links
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Create ProjectTag connections manually since it's an explicit join table
|
||||||
|
for (const tag of projectTags) {
|
||||||
|
await prisma.projectTag.upsert({
|
||||||
|
where: {
|
||||||
|
projectId_tagId: {
|
||||||
|
projectId: project.id,
|
||||||
|
tagId: tag.id
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: {},
|
||||||
|
create: {
|
||||||
|
projectId: project.id,
|
||||||
|
tagId: tag.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Created ${projects.length} projects`)
|
console.log(`Created ${projects.length} projects`)
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const duration = Date.now() - startTime
|
const duration = Date.now() - startTime
|
||||||
|
|
||||||
console.log(
|
console.warn(
|
||||||
`[CheckDuplicates] Checked ${stats.total} projects in ${duration}ms: ${stats.exists} exist, ${stats.new} new`
|
`[CheckDuplicates] Checked ${stats.total} projects in ${duration}ms: ${stats.exists} exist, ${stats.new} new`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ async function findExistingProject(projectData: ProjectInput) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (existingByGithub) {
|
if (existingByGithub) {
|
||||||
console.log(
|
console.warn(
|
||||||
`[Webhook] Found existing project by GitHub URL: ${githubLink.url}`
|
`[Webhook] Found existing project by GitHub URL: ${githubLink.url}`
|
||||||
)
|
)
|
||||||
return existingByGithub.project
|
return existingByGithub.project
|
||||||
@@ -64,7 +64,7 @@ async function findExistingProject(projectData: ProjectInput) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (existingByWebsite) {
|
if (existingByWebsite) {
|
||||||
console.log(
|
console.warn(
|
||||||
`[Webhook] Found existing project by Website URL: ${websiteLink.url}`
|
`[Webhook] Found existing project by Website URL: ${websiteLink.url}`
|
||||||
)
|
)
|
||||||
return existingByWebsite.project
|
return existingByWebsite.project
|
||||||
@@ -84,11 +84,11 @@ async function findExistingProject(projectData: ProjectInput) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (existingBySlug) {
|
if (existingBySlug) {
|
||||||
console.log(`[Webhook] Found existing project by slug: ${slug}`)
|
console.warn(`[Webhook] Found existing project by slug: ${slug}`)
|
||||||
return existingBySlug
|
return existingBySlug
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[Webhook] No existing project found, will create new one`)
|
console.warn(`[Webhook] No existing project found, will create new one`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ export async function POST(request: NextRequest) {
|
|||||||
? 'url'
|
? 'url'
|
||||||
: 'unknown'
|
: 'unknown'
|
||||||
|
|
||||||
console.log(
|
console.warn(
|
||||||
`[Webhook] Updating project "${validProject.name}" (matched by ${matchMethod}, id: ${existingProject.id})`
|
`[Webhook] Updating project "${validProject.name}" (matched by ${matchMethod}, id: ${existingProject.id})`
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ export async function POST(request: NextRequest) {
|
|||||||
results.updated++
|
results.updated++
|
||||||
} else {
|
} else {
|
||||||
// Create new project
|
// Create new project
|
||||||
console.log(
|
console.warn(
|
||||||
`[Webhook] Creating new project "${validProject.name}" (slug: ${slug})`
|
`[Webhook] Creating new project "${validProject.name}" (slug: ${slug})`
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const duration = Date.now() - startTime
|
const duration = Date.now() - startTime
|
||||||
|
|
||||||
// Log request
|
// Log request
|
||||||
console.log(
|
console.warn(
|
||||||
`[Webhook] Processed ${results.processed} projects in ${duration}ms: ${results.created} created, ${results.updated} updated, ${results.failed} failed`
|
`[Webhook] Processed ${results.processed} projects in ${duration}ms: ${results.created} created, ${results.updated} updated, ${results.failed} failed`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ export function parseGitHubUrl(url: string): { owner: string; repo: string } | n
|
|||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
const match = url.match(pattern)
|
const match = url.match(pattern)
|
||||||
if (match) {
|
if (match) {
|
||||||
const repo = match[2].replace(/\.git$/, '').replace(/\/$/, '')
|
const repo = match[2]!.replace(/\.git$/, '').replace(/\/$/, '')
|
||||||
return { owner: match[1], repo }
|
return { owner: match[1]!, repo }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user