* 创建项目 * - 校验项目路径是否存在且为目录 * - 允许非 Git 目录作为本地项目打开 * - 允许对空目录执行 Git 初始化
(input: CreateProjectInput)
| 323 | inReview: 0, |
| 324 | done: 0, |
| 325 | }; |
| 326 | |
| 327 | for (const task of project.tasks) { |
| 328 | switch (task.status) { |
| 329 | case TaskStatus.TODO: |
| 330 | taskStats.todo++; |
| 331 | break; |
| 332 | case TaskStatus.IN_PROGRESS: |
| 333 | taskStats.inProgress++; |
| 334 | break; |
| 335 | case TaskStatus.IN_REVIEW: |
| 336 | taskStats.inReview++; |
| 337 | break; |
| 338 | case TaskStatus.DONE: |
| 339 | taskStats.done++; |
| 340 | break; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | return { ...this.withGitMetadata(project), taskStats }; |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * 创建项目 |
| 349 | * - 校验项目路径是否存在且为目录 |
| 350 | * - 允许非 Git 目录作为本地项目打开 |
| 351 | * - 允许对空目录执行 Git 初始化 |
| 352 | */ |
| 353 | async create(input: CreateProjectInput) { |
| 354 | // 检查同名项目 |
| 355 | const existing = await prisma.project.findFirst({ |
| 356 | where: { name: input.name }, |
| 357 | }); |
| 358 | if (existing) { |
| 359 | throw new ValidationError( |
| 360 | `A project with name "${input.name}" already exists` |
| 361 | ); |
| 362 | } |
| 363 | |
| 364 | const { resolvedPath, repoRemoteUrl, initialized } = await prepareRepoForProjectCreate( |
no test coverage detected