# Create distributable plugin zip with correct name for WordPress # WordPress requires: zip root = single folder "ai-chat-by-agis" containing plugin files # Uses robocopy for reliable exclusion of vendor, .git, .cursor, etc. Add-Type -AssemblyName System.IO.Compression.FileSystem $pluginDir = $PSScriptRoot $parentDir = Split-Path -Parent $pluginDir $zipPath = Join-Path $parentDir "ai-chat-by-agis.zip" $tempDir = Join-Path $env:TEMP "ai-chat-by-agis-build-$(Get-Random)" $buildFolder = Join-Path $tempDir "ai-chat-by-agis" # Remove existing zip if (Test-Path $zipPath) { Remove-Item $zipPath -Force -ErrorAction SilentlyContinue } if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue } # Use robocopy to copy plugin files, explicitly excluding dev folders # /E = copy subdirs including empty, /XD = exclude directories, /XF = exclude files $excludeDirs = "vendor", ".git", "node_modules", ".cursor", ".curson" $excludeFiles = "create-zip.ps1", "*.zip" New-Item -ItemType Directory -Path $buildFolder -Force | Out-Null $robocopyArgs = @($pluginDir, $buildFolder, "/E", "/NFL", "/NDL", "/NJH", "/NJS", "/nc", "/ns", "/np") foreach ($d in $excludeDirs) { $robocopyArgs += "/XD", $d } foreach ($f in $excludeFiles) { $robocopyArgs += "/XF", $f } $null = & robocopy @robocopyArgs # Create zip - root contains "ai-chat-by-agis" folder (WordPress requirement) [System.IO.Compression.ZipFile]::CreateFromDirectory($tempDir, $zipPath, [System.IO.Compression.CompressionLevel]::Optimal, $false) # Cleanup Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue if (Test-Path $zipPath) { $size = (Get-Item $zipPath).Length / 1MB Write-Host "Created: $zipPath" Write-Host "Size: $([math]::Round($size, 2)) MB" } else { Write-Error "Failed to create zip" exit 1 }