<commit_before>$ErrorActionPreference = "Stop"

If (!([Security.Principal.WindowsPrincipal] `
     [Security.Principal.WindowsIdentity]::GetCurrent()
    ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
  Write-Error "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
}

$response = Read-host "Enter Password" -AsSecureString
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($response))

Write-Host 'Starting workup'

$WORKUP_DIR = Join-Path ${HOME} '.workup'

If (Test-Path (Join-Path ${WORKUP_DIR} 'Policyfile.lock.json')) {
  Write-Host -NoNewLine 'Updating lock file... '
  $env:GIT_SSL_NO_VERIFY = $true
  chef update "${WORKUP_DIR}/Policyfile.rb" | Out-Null
  Write-Host -ForegroundColor 'Green' 'OK'
} Else {
  Write-Host -NoNewLine 'Creating lock file... '
  $env:GIT_SSL_NO_VERIFY = $true
  chef install "${WORKUP_DIR}/Policyfile.rb" | Out-Null
  Write-Host -ForegroundColor 'Green' 'OK'
}

Write-Host -NoNewLine 'Creating chef-zero directory... '
chef export --force (Join-Path ${WORKUP_DIR} 'Policyfile.rb') (Join-Path ${WORKUP_DIR} 'chef-zero') | Out-Null
Write-Host -ForegroundColor 'Green' 'OK'

Write-Host 'Running chef-client'
Try {
  $env:PASSWORD = <PASSWORD>
  chef-client --config (Join-Path ${WORKUP_DIR} 'client.rb')
} Finally {
  Remove-Item env:\password
}<commit_msg>Detet when the powershell script has failures<commit_after>$ErrorActionPreference = "Stop"

If (!([Security.Principal.WindowsPrincipal] `
     [Security.Principal.WindowsIdentity]::GetCurrent()
    ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
  Write-Error "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
}

$response = Read-host "Enter Password" -AsSecureString
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($response))

Write-Host 'Starting workup'

$WORKUP_DIR = Join-Path ${HOME} '.workup'

If (Test-Path (Join-Path ${WORKUP_DIR} 'Policyfile.lock.json')) {
  Write-Host -NoNewLine 'Updating lock file... '
  $env:GIT_SSL_NO_VERIFY = $true
  chef update "${WORKUP_DIR}/Policyfile.rb" | Out-Null
  If ($LASTEXITCODE -eq 0) { Write-Host -ForegroundColor 'Green' 'OK' }
  Else { Write-Error 'chef update failure' }
} Else {
  Write-Host -NoNewLine 'Creating lock file... '
  $env:GIT_SSL_NO_VERIFY = $true
  chef install "${WORKUP_DIR}/Policyfile.rb" | Out-Null
  If ($LASTEXITCODE -eq 0) { Write-Host -ForegroundColor 'Green' 'OK' }
  Else { Write-Error 'chef install failure' }
}

Write-Host -NoNewLine 'Creating chef-zero directory... '
chef export --force (Join-Path ${WORKUP_DIR} 'Policyfile.rb') (Join-Path ${WORKUP_DIR} 'chef-zero') | Out-Null
If ($LASTEXITCODE -eq 0) { Write-Host -ForegroundColor 'Green' 'OK' }
Else { Write-Error 'chef export failure' }

Write-Host 'Running chef-client'
Try {
  $env:PASSWORD = <PASSWORD>
  chef-client --config (Join-Path ${WORKUP_DIR} 'client.rb')
  If ($LASTEXITCODE -ne 0) { Write-Error 'chef-client failure' }
} Finally {
  If (Test-Path env:\PASSWORD) { Remove-Item env:\PASSWORD }
}
{'fraction_non_alphanumeric': 0.1475968992248062, 'fraction_numerical': 0.00124031007751938, 'mean_word_length': 4.897623400365631, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3127195', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1079, 'n_words': 255}