UmeAiRT commited on
Commit
f459246
·
verified ·
1 Parent(s): 7f18f05

Upload Update-ComfyUI.ps1

Browse files
Files changed (1) hide show
  1. scripts/ComfyUI/Update-ComfyUI.ps1 +117 -0
scripts/ComfyUI/Update-ComfyUI.ps1 ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Requires -RunAsAdministrator
2
+
3
+ <#
4
+ .SYNOPSIS
5
+ A dedicated update script for the ComfyUI installation.
6
+ .DESCRIPTION
7
+ This script performs a 'git pull' on the main ComfyUI repository,
8
+ all custom nodes, and the workflow repository. It then updates all
9
+ Python dependencies from any found 'requirements.txt' files.
10
+ It is designed to be run from a subfolder.
11
+ #>
12
+
13
+ #===========================================================================
14
+ # SECTION 1: SCRIPT CONFIGURATION & HELPER FUNCTIONS
15
+ #===========================================================================
16
+
17
+ # === CORRECTION : Le script s'exécute depuis un sous-dossier, on cible donc le dossier parent ===
18
+ $InstallPath = (Split-Path -Path $PSScriptRoot -Parent)
19
+
20
+ $comfyPath = Join-Path $InstallPath "ComfyUI"
21
+ $customNodesPath = Join-Path $InstallPath "custom_nodes"
22
+ $workflowPath = Join-Path $InstallPath "user\default\workflows\UmeAiRT-Workflow"
23
+ $venvPython = Join-Path $comfyPath "venv\Scripts\python.exe"
24
+ $logPath = Join-Path $InstallPath "logs"
25
+ $logFile = Join-Path $logPath "update_log.txt"
26
+
27
+ if (-not (Test-Path $logPath)) { New-Item -ItemType Directory -Force -Path $logPath | Out-Null }
28
+
29
+ function Write-Log {
30
+ param([string]$Message, [string]$Color = "White")
31
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
32
+ $formattedMessage = "[$timestamp] $Message"
33
+ Write-Host $Message -ForegroundColor $Color
34
+ Add-Content -Path $logFile -Value $formattedMessage
35
+ }
36
+
37
+ function Invoke-Git-Pull {
38
+ param([string]$DirectoryPath)
39
+ if (Test-Path (Join-Path $DirectoryPath ".git")) {
40
+ # On utilise cmd.exe pour lancer git pull et rediriger la sortie vers le log
41
+ $commandToRun = "git -C `"$DirectoryPath`" pull"
42
+ $cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
43
+ try {
44
+ Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
45
+ } catch {
46
+ Write-Log " - FAILED to run git pull in '$DirectoryPath'" -Color Red
47
+ }
48
+ } else {
49
+ Write-Log " - Skipping: Not a git repository." -Color Gray
50
+ }
51
+ }
52
+
53
+ function Invoke-Pip-Install {
54
+ param([string]$RequirementsPath)
55
+ if (Test-Path $RequirementsPath) {
56
+ Write-Log " - Found requirements: $RequirementsPath. Updating..." -Color Cyan
57
+ $tempLogFile = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString() + ".tmp")
58
+ try {
59
+ $commandToRun = "`"$venvPython`" -m pip install -r `"$RequirementsPath`""
60
+ $cmdArguments = "/C `"$commandToRun > `"`"$tempLogFile`"`" 2>&1`""
61
+ Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
62
+ if (Test-Path $tempLogFile) { $output = Get-Content $tempLogFile; if($output){ Add-Content -Path $logFile -Value $output } }
63
+ } finally {
64
+ if (Test-Path $tempLogFile) { Remove-Item $tempLogFile }
65
+ }
66
+ }
67
+ }
68
+
69
+ #===========================================================================
70
+ # SECTION 2: UPDATE PROCESS
71
+ #===========================================================================
72
+ Clear-Host
73
+ Write-Log "==============================================================================="
74
+ Write-Log " Starting UmeAiRT ComfyUI Update Process" -Color Yellow
75
+ Write-Log "==============================================================================="
76
+
77
+ # --- 1. Update ComfyUI Core ---
78
+ Write-Log "`n[1/4] Updating ComfyUI Core..." -Color Green
79
+ Invoke-Git-Pull -DirectoryPath $comfyPath
80
+
81
+ # --- 2. Update Custom Nodes ---
82
+ Write-Log "`n[2/4] Updating Custom Nodes..." -Color Green
83
+ if (Test-Path $customNodesPath) {
84
+ $nodeDirs = Get-ChildItem -Path $customNodesPath -Directory
85
+ foreach ($dir in $nodeDirs) {
86
+ Write-Log " - Checking node: $($dir.Name)"
87
+ Invoke-Git-Pull -DirectoryPath $dir.FullName
88
+ }
89
+ } else {
90
+ Write-Log " - Custom nodes directory not found, skipping."
91
+ }
92
+
93
+
94
+ # --- 3. Update Workflows ---
95
+ Write-Log "`n[3/4] Updating UmeAiRT Workflows..." -Color Green
96
+ if (Test-Path $workflowPath) {
97
+ Invoke-Git-Pull -DirectoryPath $workflowPath
98
+ } else {
99
+ Write-Log " - Workflow directory not found, skipping." -Color Gray
100
+ }
101
+
102
+ # --- 4. Update Python Dependencies ---
103
+ Write-Log "`n[4/4] Updating all Python dependencies..." -Color Green
104
+ Write-Log " - Checking main ComfyUI requirements..."
105
+ Invoke-Pip-Install -RequirementsPath (Join-Path $comfyPath "requirements.txt")
106
+
107
+ Write-Log " - Checking custom node requirements..."
108
+ if (Test-Path $customNodesPath) {
109
+ foreach ($dir in (Get-ChildItem -Path $customNodesPath -Directory)) {
110
+ Invoke-Pip-Install -RequirementsPath (Join-Path $dir.FullName "requirements.txt")
111
+ }
112
+ }
113
+
114
+ Write-Log "==============================================================================="
115
+ Write-Log "Update process complete!" -Color Yellow
116
+ Write-Log "==============================================================================="
117
+ Read-Host "Press Enter to exit."