<commit_before># Powershell Clangbuilder package manger

$ClangbuilderRoot = Split-Path -Parent $PSScriptRoot
$Pkgdir = "$ClangbuilderRoot/pkgs"

Import-Module -Name "$Global:ClangbuilderRoot\modules\PM" # Package Manager

if (!(Test-Path "$Pkgdir")) {
    New-Item -ItemType Directory -Path $Pkgdir -Force |Out-Null
}
if (!(Test-Path "$Pkgdir\packages.lock.json")) {
    "{}"|Out-File -FilePath "$Pkgdir\packages.lock.json"
}

$packages = Get-Content -Path "$ClangbuilderRoot\config\packages.json" |ConvertFrom-Json
$ipkgs = Get-Content -Path "$Pkgdir\packages.lock.json" |ConvertFrom-Json
$pkgcaches = @{}

$pkgs = $packages.Packages
foreach ($i in $pkgs) {
    $Name = $i.Name
    if ($i.Version -eq $ipkgs.$Name) {
        $pkgcaches[$Name] = $i.Version
        Write-Host -ForegroundColor Green "$Name $($i.Version) is up to date !"
        continue
    }
    Write-Host "Install new ${Name}: $($i.Version) ..."
    if ((Test-Path "$Pkgdir\$Name")) {
        Rename-Item "$Pkgdir\$Name" "$Pkgdir\$Name.bak"
    }
    $myurl = $null
    if ($null -ne $i.URL) {
        $myurl = $i.URL
    }
    elseif ([System.Environment]::Is64BitOperatingSystem) {
        $myurl = $i.X64URL
    }
    else {
        $myurl = $i.X86URL
    }
    Install-Package -ClangbuilderRoot $ClangbuilderRoot -Name $Name -Uri $myurl -Extension $i.Extension
    if (!(Test-Path "$Pkgdir\$Name")) {
        $pkgcaches[$Name] = $ipkgs.$Name
        if (Test-Path "$Pkgdir\$Name.bak") {
            Move-Item "$Pkgdir\$Name.bak" "$Pkgdir\$Name"
        }
    }
    else {
        if (Test-Path "$Pkgdir\$Name.bak") {
            Remove-Item -Force -Recurse "$Pkgdir\$Name.bak"
        }
        $pkgcaches[$Name] = $i.Version
    }
}

ConvertTo-Json $pkgcaches |Out-File -Force -FilePath "$InstallDir/packages.lock.json"

Write-Host "Update package completed."<commit_msg>fix InstallUtils<commit_after># Powershell Clangbuilder package manger

$ClangbuilderRoot = Split-Path -Parent $PSScriptRoot
$Pkgdir = "$ClangbuilderRoot/pkgs"

Import-Module -Name "$Global:ClangbuilderRoot\modules\PM" # Package Manager

if (!(Test-Path "$Pkgdir")) {
    New-Item -ItemType Directory -Path $Pkgdir -Force |Out-Null
}
if (!(Test-Path "$Pkgdir\packages.lock.json")) {
    "{}"|Out-File -FilePath "$Pkgdir\packages.lock.json"
}

$packages = Get-Content -Path "$ClangbuilderRoot\config\packages.json" |ConvertFrom-Json
$ipkgs = Get-Content -Path "$Pkgdir\packages.lock.json" |ConvertFrom-Json
$pkgcaches = @{}

$pkgs = $packages.Packages
foreach ($i in $pkgs) {
    $Name = $i.Name
    if ($i.Version -eq $ipkgs.$Name) {
        $pkgcaches[$Name] = $i.Version
        Write-Host -ForegroundColor Green "$Name $($i.Version) is up to date !"
        continue
    }
    Write-Host "Install new ${Name}: $($i.Version) ..."
    if ((Test-Path "$Pkgdir\$Name")) {
        Rename-Item "$Pkgdir\$Name" "$Pkgdir\$Name.bak"
    }
    $myurl = $null
    if ($null -ne $i.URL) {
        $myurl = $i.URL
    }
    elseif ([System.Environment]::Is64BitOperatingSystem) {
        $myurl = $i.X64URL
    }
    else {
        $myurl = $i.X86URL
    }
    Install-Package -ClangbuilderRoot $ClangbuilderRoot -Name $Name -Uri $myurl -Extension $i.Extension
    if (!(Test-Path "$Pkgdir\$Name")) {
        $pkgcaches[$Name] = $ipkgs.$Name
        if (Test-Path "$Pkgdir\$Name.bak") {
            Move-Item "$Pkgdir\$Name.bak" "$Pkgdir\$Name"
        }
    }
    else {
        if (Test-Path "$Pkgdir\$Name.bak") {
            Remove-Item -Force -Recurse "$Pkgdir\$Name.bak"
        }
        $pkgcaches[$Name] = $i.Version
    }
}

ConvertTo-Json $pkgcaches |Out-File -Force -FilePath "$Pkgdir\packages.lock.json"

Write-Host "Update package completed."
{'fraction_non_alphanumeric': 0.16896831844029245, 'fraction_numerical': 0.003249390739236393, 'mean_word_length': 2.8161157024793386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1029028', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1313, 'n_words': 266}