<commit_before><#
.SYNOPSIS
Initializes your Rivet working directory for development.
#>
[CmdletBinding()]
param(
    [Switch]
    # Removes any previously downloaded packages and re-downloads them.
    $Clean
)

#Requires -Version 4
Set-StrictMode -Version 'Latest'

$moduleNames = @( 'Pester', 'Silk', 'Carbon' )
foreach( $moduleName in $moduleNames )
{
    $modulePath = Join-Path -Path $PSScriptRoot -ChildPath $moduleName
    if( (Test-Path -Path $modulePath -PathType Container) )
    {
        if( $Clean )
        {
            Remove-Item -Path $modulePath -Recurse -Force
        }

        continue
    }

    Save-Module -Name $moduleName -Path $PSScriptRoot -Force

    $versionDir = Join-Path -Path $modulePath -ChildPath '*.*.*'
    if( (Test-Path -Path $versionDir -PathType Container) )
    {
        $versionDir = Get-Item -Path $versionDir
        Get-ChildItem -Path $versionDir -Force | Move-Item -Destination $modulePath -Verbose
        Remove-Item -Path $versionDir
    }
}

& (Join-Path -Path $PSScriptRoot -ChildPath 'Carbon\Import-Carbon.ps1' -Resolve)

$packagesRoot = Join-Path -Path $PSScriptRoot -ChildPath 'packages'

$nugetPath = Join-Path -Path $PSScriptRoot -ChildPath '.\Silk\bin\NuGet.exe' -Resolve
& $nugetPath install 'NUnit.Console' -OutputDirectory $packagesRoot

$linkPath = Join-Path -Path $packagesRoot -ChildPath 'NUnit.ConsoleRunner'
$targetPath = Get-ChildItem -Path $packagesRoot -Filter 'NUnit.ConsoleRunner.*.*.*' -Directory | 
                Where-Object { $_.IsJunction -eq $false } |
                Select-Object -ExpandProperty 'FullName'
Install-Junction -Link $linkPath -Target $targetPath

$sourceRoot = Join-Path -Path $PSScriptRoot -ChildPath 'Source'
Get-ChildItem -Path $sourceRoot -Filter 'packages.config' -Recurse |
    ForEach-Object { & $nugetPath restore $_.FullName -SolutionDirectory $sourceRoot }<commit_msg>Install NuGet package provider for non-interactive initializations.<commit_after><#
.SYNOPSIS
Initializes your Rivet working directory for development.
#>
[CmdletBinding()]
param(
    [Switch]
    # Removes any previously downloaded packages and re-downloads them.
    $Clean
)

#Requires -Version 4
Set-StrictMode -Version 'Latest'

Get-ChildItem -Path 'env:' | Format-List | Out-String | Write-Verbose

Install-PackageProvider -Name NuGet -Force

$moduleNames = @( 'Pester', 'Silk', 'Carbon' )
foreach( $moduleName in $moduleNames )
{
    $modulePath = Join-Path -Path $PSScriptRoot -ChildPath $moduleName
    if( (Test-Path -Path $modulePath -PathType Container) )
    {
        if( $Clean )
        {
            Remove-Item -Path $modulePath -Recurse -Force
        }

        continue
    }

    Save-Module -Name $moduleName -Path $PSScriptRoot -Force

    $versionDir = Join-Path -Path $modulePath -ChildPath '*.*.*'
    if( (Test-Path -Path $versionDir -PathType Container) )
    {
        $versionDir = Get-Item -Path $versionDir
        Get-ChildItem -Path $versionDir -Force | Move-Item -Destination $modulePath -Verbose
        Remove-Item -Path $versionDir
    }
}

& (Join-Path -Path $PSScriptRoot -ChildPath 'Carbon\Import-Carbon.ps1' -Resolve)

$packagesRoot = Join-Path -Path $PSScriptRoot -ChildPath 'packages'

$nugetPath = Join-Path -Path $PSScriptRoot -ChildPath '.\Silk\bin\NuGet.exe' -Resolve
& $nugetPath install 'NUnit.Console' -OutputDirectory $packagesRoot

$linkPath = Join-Path -Path $packagesRoot -ChildPath 'NUnit.ConsoleRunner'
$targetPath = Get-ChildItem -Path $packagesRoot -Filter 'NUnit.ConsoleRunner.*.*.*' -Directory | 
                Where-Object { $_.IsJunction -eq $false } |
                Select-Object -ExpandProperty 'FullName'
Install-Junction -Link $linkPath -Target $targetPath

$sourceRoot = Join-Path -Path $PSScriptRoot -ChildPath 'Source'
Get-ChildItem -Path $sourceRoot -Filter 'packages.config' -Recurse |
    ForEach-Object { & $nugetPath restore $_.FullName -SolutionDirectory $sourceRoot }
{'fraction_non_alphanumeric': 0.11779262558772581, 'fraction_numerical': 0.000989853996535511, 'mean_word_length': 2.909090909090909, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6897133', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1244, 'n_words': 324}