$ErrorActionPreference = "Stop"

$root = Resolve-Path (Join-Path $PSScriptRoot "..")
$dist = Join-Path $root "dist"
$zip = Join-Path $dist "mazexchain-wallet-extension.zip"
$extension = Join-Path $root "extension"

if (!(Test-Path $extension)) {
  throw "Extension directory not found: $extension"
}

New-Item -ItemType Directory -Force -Path $dist | Out-Null
if (Test-Path $zip) {
  Remove-Item -LiteralPath $zip -Force
}

Compress-Archive -Path (Join-Path $extension "*") -DestinationPath $zip -Force
Write-Output "Created $zip"
