|
| 1 | +# Build and package ReplyQueue for Chrome Web Store submission |
| 2 | +# Usage: .\scripts\package.ps1 |
| 3 | + |
| 4 | +$ErrorActionPreference = "Stop" |
| 5 | + |
| 6 | +$projectRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) |
| 7 | +Set-Location $projectRoot |
| 8 | + |
| 9 | +# Get version from manifest.json |
| 10 | +$manifest = Get-Content "manifest.json" | ConvertFrom-Json |
| 11 | +$version = $manifest.version |
| 12 | + |
| 13 | +Write-Host "Building ReplyQueue v$version..." -ForegroundColor Cyan |
| 14 | + |
| 15 | +# Clean dist folder |
| 16 | +if (Test-Path "dist") { |
| 17 | + Remove-Item -Recurse -Force "dist" |
| 18 | + Write-Host "Cleaned dist folder" -ForegroundColor Gray |
| 19 | +} |
| 20 | + |
| 21 | +# Run build |
| 22 | +Write-Host "Running pnpm build..." -ForegroundColor Gray |
| 23 | +pnpm build |
| 24 | +if ($LASTEXITCODE -ne 0) { |
| 25 | + Write-Host "Build failed!" -ForegroundColor Red |
| 26 | + exit 1 |
| 27 | +} |
| 28 | + |
| 29 | +# Create packages folder if it doesn't exist |
| 30 | +$packagesDir = "packages" |
| 31 | +if (-not (Test-Path $packagesDir)) { |
| 32 | + New-Item -ItemType Directory -Path $packagesDir | Out-Null |
| 33 | +} |
| 34 | + |
| 35 | +# Create zip file |
| 36 | +$zipName = "replyqueue-v$version.zip" |
| 37 | +$zipPath = Join-Path $packagesDir $zipName |
| 38 | + |
| 39 | +# Remove existing zip if present |
| 40 | +if (Test-Path $zipPath) { |
| 41 | + Remove-Item $zipPath |
| 42 | +} |
| 43 | + |
| 44 | +Write-Host "Creating $zipName..." -ForegroundColor Gray |
| 45 | +Compress-Archive -Path "dist\*" -DestinationPath $zipPath |
| 46 | + |
| 47 | +# Get file size |
| 48 | +$size = (Get-Item $zipPath).Length / 1KB |
| 49 | +$sizeFormatted = "{0:N1} KB" -f $size |
| 50 | + |
| 51 | +Write-Host "" |
| 52 | +Write-Host "Package created successfully!" -ForegroundColor Green |
| 53 | +Write-Host " File: $zipPath" -ForegroundColor White |
| 54 | +Write-Host " Size: $sizeFormatted" -ForegroundColor White |
| 55 | +Write-Host "" |
| 56 | +Write-Host "Upload this file to the Chrome Developer Dashboard" -ForegroundColor Yellow |
0 commit comments