From a5e8c05ff68b7f9e2488df5b6948acde21df0695 Mon Sep 17 00:00:00 2001 From: abgox Date: Thu, 15 Aug 2024 07:53:27 +0800 Subject: [PATCH] chore(scripts): add check-guid-valid.ps1 --- scripts/check-guid-valid.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/check-guid-valid.ps1 diff --git a/scripts/check-guid-valid.ps1 b/scripts/check-guid-valid.ps1 new file mode 100644 index 00000000..15acf7dd --- /dev/null +++ b/scripts/check-guid-valid.ps1 @@ -0,0 +1,25 @@ +$invalideGuid = @() +Get-ChildItem -Path "$PSScriptRoot\..\completions\" -Directory | ForEach-Object { + # $url = "https://raw.githubusercontent.com/abgox/PSCompletions/main/completions/$($_.Name)/guid.txt" + $url = "https://gitee.com/abgox/PSCompletions/raw/main/completions/$($_.Name)/guid.txt" + try { + $content = Invoke-WebRequest -Uri $url + $content = $content.Content.Trim() + $content + if (!($content -match "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$")) { + $invalideGuid += $_.Name + } + } + catch {} +} +if ($invalideGuid) { + write-host "------------------------------------" -ForegroundColor Yellow + Write-Host "The following guid.txt are invalid:" -ForegroundColor Yellow + foreach ($item in $invalideGuid) { + Write-Host $item -ForegroundColor Red + } +} +else { + write-host "------------------------------------" -ForegroundColor Green + Write-Host "All guid.txt are valid." -ForegroundColor Green +}