[CmdletBinding()]
param([Parameter(Mandatory)][string]$Url,[Parameter(Mandatory)][string]$Destination)
$ErrorActionPreference = 'Stop'
$repo = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
. (Join-Path $repo 'scripts/hash-utils.ps1')
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $Destination) | Out-Null
Invoke-WebRequest -Uri $Url -OutFile $Destination
$hash = (Get-SmartCutSha256 -LiteralPath $Destination).ToLowerInvariant()
Write-Output (ConvertTo-Json ([pscustomobject]@{url=$Url;path=(Resolve-Path -LiteralPath $Destination).Path;sha256=$hash}) -Compress)
