?# gov_pipeline_run_safe_v1.1.ps1 (fixed default Root + normalization) param( [string]$Root="\\DS-918\chatgpt\ChatGPT-Gouvernance-Projets\_registry", [switch]$Utf8Console, [switch]$RunAcceptance ) if($Utf8Console){ try{ [Console]::OutputEncoding = [Text.Encoding]::UTF8 }catch{} } function Exists([string]$p){ (-not [string]::IsNullOrWhiteSpace($p)) -and (Test-Path -LiteralPath $p) } function Fail([int]$code,[string]$msg){ Write-Host $msg; exit $code } # normalize leading slashes (collapse //// to \\) if($Root -like "\\\\\\\\*"){ $Root = $Root -replace "^[\\]+","\\\\" } $scriptsDir = Join-Path $Root "scripts" $doctor1 = Join-Path $scriptsDir "gov_pipeline_doctor_ultra_min_v1.2.ps1" $doctor2 = Join-Path $scriptsDir "gov_pipeline_doctor_ultra_min_v1.1.ps1" $doctor = $null; if(Exists $doctor1){ $doctor=$doctor1 } elseif(Exists $doctor2){ $doctor=$doctor2 } $interactive= Join-Path $scriptsDir "gov_pipeline_interactive_write_v1.0.ps1" $acceptance = Join-Path $scriptsDir "kb_acceptance_tests_v1.0.1.ps1" Write-Host "== GOV PIPELINE :: SAFE-RUN v1.1 ==" Write-Host ("Root : {0}" -f $Root) if(-not $doctor){ Fail 3 ("[FATAL] missing doctor: " + $doctor1 + " / " + $doctor2) } if(-not (Exists $interactive)){ Fail 3 ("[FATAL] missing: " + $interactive) } if($RunAcceptance -and -not (Exists $acceptance)){ Write-Host ("[WARN] acceptance not found: {0}" -f $acceptance) } Write-Host "[1/3] Preflight doctor..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$doctor,"-Root",$Root,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Preflight failed." } Write-Host "[2/3] Interactive pipeline..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$interactive,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Interactive pipeline failed." } Write-Host "[3/3] Postflight doctor..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$doctor,"-Root",$Root,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Postflight doctor failed." } if($RunAcceptance -and (Test-Path -LiteralPath $acceptance)){ Write-Host "[+A] Acceptance..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$acceptance,$Root) if($p.ExitCode -ne 0){ Fail 2 "[STOP] Acceptance failed." } } Write-Host "[DONE] Safe-run completed successfully."