<commit_before>param([string]$recipes_dir="")

$script_dir = split-path -parent $MyInvocation.MyCommand.Definition

. "$script_dir\service-funcs.ps1"

clear_log

if ( $recipes_dir.Length -eq 0 )
{
    log "Recepies dir not specified. Only preparing build tools and env."
}
else
{
    if( Test-Path "$recipes_dir" )
    {
        log "Attempting to build recepies at $recipes_dir"
    }
    else
    {
        log "Error: recepies dir at $recipes_dir does not exist"
        exit 1
    }
}

$temp_dir="$script_dir\temp"
$tools_dir="$temp_dir\tools"

$nuget_dir="$tools_dir\nuget"
$nuget_exe="$nuget_dir\nuget.exe"
$nuget_exe_dist="$script_dir\dist\nuget\nuget-3.4.4.exe"

$cake_dir="$tools_dir\cake"
$cake_exe="$cake_dir\Cake.exe"
$cake_dist="$script_dir\dist\cake\Cake-bin-v0.13.0.zip"
$cake_extra="$script_dir\roslyn"

$patch_dir="$tools_dir\patch"
$patch_exe="$patch_dir\patch.exe"
$patch_dist="$script_dir\dist\patch\patch.zip"

$unzip_dir="$tools_dir\unzip"
$unzip_exe="$unzip_dir\unzip.exe"
$unzip_exe_dist="$script_dir\dist\unzip\unzip.exe"

if(!(Test-Path "$temp_dir"))
{
    log "Creating temp dir at $temp_dir"
    mkdir -Force "$temp_dir" | Out-Null
    check_error
}

if(!(Test-Path "$tools_dir"))
{
    log "Creating tools dir at $tools_dir"
    mkdir -Force "$tools_dir" | Out-Null
    check_error
}

if(!(Test-Path -PathType Leaf "$unzip_exe"))
{
    log "Creating unzip dir at $unzip_dir"
    mkdir -Force "$unzip_dir" | Out-Null
    check_error
    log "Copying unzip exe from $unzip_exe_dist"
    cp "$unzip_exe_dist" "$unzip_dir\unzip.exe"
    check_error
}

$env:Path += ";$unzip_dir"

if(!(Test-Path -PathType Leaf "$nuget_exe"))
{
    log "Creating nuget dir at $nuget_dir"
    mkdir -Force "$nuget_dir" | Out-Null
    check_error
    log "Copying nuget exe from $nuget_exe_dist"
    cp "$nuget_exe_dist" "$nuget_dir\nuget.exe"
    check_error
}

if(!(Test-Path -PathType Leaf "$cake_exe"))
{
    log "Creating cake dir at $cake_dir"
    mkdir -Force "$cake_dir" | Out-Null
    check_error
    log "Extracting cake dist from $cake_dist"
    unzip -File "$cake_dist" -Destination "$cake_dir"
    check_error
    log "Copying cake addons from $cake_extra"
    Copy-Item -path "$cake_extra" -include "*.dll" -Destination "$cake_dir"
    check_error
}

if(!(Test-Path -PathType Leaf "$patch_exe"))
{
    log "Creating patch dir at $patch_dir"
    mkdir -Force "$patch_dir" | Out-Null
    check_error
    log "Extracting patch dist from $patch_dist"
    unzip -File "$patch_dist" -Destination "$patch_dir"
    check_error
}

if ( $recipes_dir.Length -eq 0 )
{
    log "Exiting"
    exit 0
}

$env:Path += ";$patch_dir"

$curdir=Get-Location

cd "$recipes_dir"
check_error

$recipes=Get-ChildItem -Depth 1 -File -Filter *.recipe | Sort-Object name

ForEach ($recipe in $recipes)
{<commit_msg>prepare-and-build.ps1 - some minor change<commit_after>param([string]$recipes_dir="")

$script_dir = split-path -parent $MyInvocation.MyCommand.Definition

. "$script_dir\service-funcs.ps1"

clear_log

if ( $recipes_dir.Length -eq 0 )
{
    log "Recepies dir not specified. Only preparing build tools and env."
}
else
{
    if( Test-Path "$recipes_dir" )
    {
        log "Attempting to build recepies at $recipes_dir"
    }
    else
    {
        log "Error: recepies dir at $recipes_dir does not exist"
        exit 1
    }
}

$temp_dir="$script_dir\temp"
$tools_dir="$temp_dir\tools"

$nuget_dir="$tools_dir\nuget"
$nuget_exe="$nuget_dir\nuget.exe"
$nuget_exe_dist="$script_dir\dist\nuget\nuget-3.4.4.exe"

$cake_dir="$tools_dir\cake"
$cake_exe="$cake_dir\Cake.exe"
$cake_dist="$script_dir\dist\cake\Cake-bin-v0.13.0.zip"
$cake_extra="$script_dir\roslyn"

$patch_dir="$tools_dir\patch"
$patch_exe="$patch_dir\patch.exe"
$patch_dist="$script_dir\dist\patch\patch.zip"

$unzip_dir="$tools_dir\unzip"
$unzip_exe="$unzip_dir\unzip.exe"
$unzip_exe_dist="$script_dir\dist\unzip\unzip.exe"

if(!(Test-Path "$temp_dir"))
{
    log "Creating temp dir at $temp_dir"
    mkdir -Force "$temp_dir" | Out-Null
    check_error
}

if(!(Test-Path "$tools_dir"))
{
    log "Creating tools dir at $tools_dir"
    mkdir -Force "$tools_dir" | Out-Null
    check_error
}

if(!(Test-Path -PathType Leaf "$unzip_exe"))
{
    log "Creating unzip dir at $unzip_dir"
    mkdir -Force "$unzip_dir" | Out-Null
    check_error
    log "Copying unzip exe from $unzip_exe_dist"
    cp "$unzip_exe_dist" "$unzip_dir\unzip.exe"
    check_error
}

$env:Path += ";$unzip_dir"

if(!(Test-Path -PathType Leaf "$nuget_exe"))
{
    log "Creating nuget dir at $nuget_dir"
    mkdir -Force "$nuget_dir" | Out-Null
    check_error
    log "Copying nuget exe from $nuget_exe_dist"
    cp "$nuget_exe_dist" "$nuget_dir\nuget.exe"
    check_error
}

if(!(Test-Path -PathType Leaf "$cake_exe"))
{
    log "Creating cake dir at $cake_dir"
    mkdir -Force "$cake_dir" | Out-Null
    check_error
    log "Extracting cake dist from $cake_dist"
    unzip -File "$cake_dist" -Destination "$cake_dir"
    check_error
    log "Copying cake addons from $cake_extra"
    Copy-Item -path "$cake_extra" -include "*.dll" -Destination "$cake_dir"
    check_error
}

if(!(Test-Path -PathType Leaf "$patch_exe"))
{
    log "Creating patch dir at $patch_dir"
    mkdir -Force "$patch_dir" | Out-Null
    check_error
    log "Extracting patch dist from $patch_dist"
    unzip -File "$patch_dist" -Destination "$patch_dir"
    check_error
}

$env:Path += ";$patch_dir"

if ( $recipes_dir.Length -eq 0 )
{
    log "Exiting"
    exit 0
}

$curdir=Get-Location

cd "$recipes_dir"
check_error

$recipes=Get-ChildItem -Depth 1 -File -Filter *.recipe | Sort-Object name

ForEach ($recipe in $recipes)
{
{'fraction_non_alphanumeric': 0.14214817440623892, 'fraction_numerical': 0.00478553704360156, 'mean_word_length': 3.83547557840617, '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': '1164897', 'n_tokens_mistral': 2290, 'n_tokens_neox': 2169, 'n_words': 467}