(dispatch: TaskEventDispatcher)
| 408 | } |
| 409 | |
| 410 | export async function cloneComfyUI(dispatch: TaskEventDispatcher): Promise<boolean> { |
| 411 | let success = false; |
| 412 | let lastError = null; |
| 413 | const { PIP_PATH, PYTHON_PATH } = conda.getCondaPaths(); |
| 414 | |
| 415 | for (let i = 0; i < 3; i++) { |
| 416 | try { |
| 417 | const repoPath = getComfyUIDir(); |
| 418 | const parentDir = path.dirname(repoPath); |
| 419 | await fsExtra.ensureDir(parentDir); |
| 420 | |
| 421 | if (!await checkIfInstalledComfyUI()) { |
| 422 | dispatch({ |
| 423 | message: 'Start cloning ComfyUI...' |
| 424 | }); |
| 425 | await runCommand(`git clone https://github.com/comfyanonymous/ComfyUI.git`, dispatch, { |
| 426 | cwd: parentDir |
| 427 | }); |
| 428 | } |
| 429 | |
| 430 | await runCommand(`${PIP_PATH} install -r requirements.txt`, dispatch, { |
| 431 | cwd: repoPath |
| 432 | }); |
| 433 | |
| 434 | const sdPath = getStableDiffusionDir() |
| 435 | if (sdPath !== "") { |
| 436 | createOrUpdateExtraConfigFileFromStableDiffusion(sdPath) |
| 437 | } |
| 438 | |
| 439 | dispatch({ |
| 440 | message: "clone comfyui success" |
| 441 | }); |
| 442 | |
| 443 | success = true; |
| 444 | break; |
| 445 | } catch (error: any) { |
| 446 | lastError = error; |
| 447 | } |
| 448 | } |
| 449 | if (!success) { |
| 450 | throw new Error(`clone comfyui error: ${lastError.message}`); |
| 451 | } |
| 452 | return true; |
| 453 | } |
no test coverage detected