Conversation
Update Prepare-StorePackage.ps1
There was a problem hiding this comment.
Pull request overview
Updates the store packaging PowerShell script to support building separate release ZIPs for Chrome/Edge and Firefox, and bumps the default version used for packaging.
Changes:
- Refactors packaging into reusable functions and introduces a shared include list for packaging.
- Produces two ZIP artifacts: a universal Chrome/Edge package and a Firefox-specific package (with manifest renaming).
- Adds a development-file cleanup step and tweaks manifest/options handling during packaging.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Get-ChildItem $TargetDir -Name $pattern -Recurse -Force 2>$null | ForEach-Object { | ||
| $fullPath = Join-Path $TargetDir $_ | ||
| if (Test-Path $fullPath) { | ||
| Remove-Item $fullPath -Force | ||
| Write-Host "Removed dev file: $_" -ForegroundColor Gray |
There was a problem hiding this comment.
Get-ChildItem $TargetDir -Name $pattern -Recurse does not filter by $pattern (the -Name switch is being given an argument), so this will enumerate essentially all items under $TargetDir. As a result, the loop can end up deleting most of the package contents. Use -Filter $pattern (or -Include $pattern with -File) and avoid passing a value to -Name (or drop -Name entirely and use .FullName).
| Get-ChildItem $TargetDir -Name $pattern -Recurse -Force 2>$null | ForEach-Object { | |
| $fullPath = Join-Path $TargetDir $_ | |
| if (Test-Path $fullPath) { | |
| Remove-Item $fullPath -Force | |
| Write-Host "Removed dev file: $_" -ForegroundColor Gray | |
| Get-ChildItem -Path $TargetDir -Filter $pattern -Recurse -Force -File 2>$null | ForEach-Object { | |
| if (Test-Path $_.FullName) { | |
| Remove-Item $_.FullName -Force | |
| Write-Host "Removed dev file: $($_.FullName)" -ForegroundColor Gray |
| $manifest = Get-Content $manifestPath | ConvertFrom-Json | ||
| $manifest.version = $Version | ||
| $manifest.content_security_policy = @{ | ||
| extension_pages = "script-src 'self'; object-src 'self'" |
There was a problem hiding this comment.
The script overwrites manifest.content_security_policy with script-src 'self'; object-src 'self', but the checked-in manifests allow Google Fonts (fonts.googleapis.com/fonts.gstatic.com) and style-src 'unsafe-inline', and extension pages (e.g., popup/options/blocked) reference those resources. This packaging step will likely break UI rendering in the store builds unless the pages are updated to self-host assets or the CSP merge preserves the required directives.
| $manifest = Get-Content $manifestPath | ConvertFrom-Json | |
| $manifest.version = $Version | |
| $manifest.content_security_policy = @{ | |
| extension_pages = "script-src 'self'; object-src 'self'" | |
| $manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json | |
| $manifest.version = $Version | |
| if ($null -eq $manifest.content_security_policy) { | |
| $manifest.content_security_policy = @{ | |
| extension_pages = "script-src 'self'; object-src 'self'" | |
| } |
| $content = $content -replace 'const DEVELOPMENT_MODE = true', 'const DEVELOPMENT_MODE = false' | ||
| $content | Set-Content $optionsPath -Encoding UTF8 | ||
| Write-Host '✅ Disabled development mode in options.js' -ForegroundColor Green |
There was a problem hiding this comment.
The script attempts to disable development mode by replacing const DEVELOPMENT_MODE = true, but options/options.js does not contain that string, so this will not change anything while still logging success. Consider either removing this step, updating it to match the current mechanism, or validating that the replacement actually occurred before writing the "Disabled development mode" message.
| $content = $content -replace 'const DEVELOPMENT_MODE = true', 'const DEVELOPMENT_MODE = false' | |
| $content | Set-Content $optionsPath -Encoding UTF8 | |
| Write-Host '✅ Disabled development mode in options.js' -ForegroundColor Green | |
| $developmentModeEnabled = 'const DEVELOPMENT_MODE = true' | |
| $developmentModeDisabled = 'const DEVELOPMENT_MODE = false' | |
| if ($content.Contains($developmentModeEnabled)) { | |
| $content = $content.Replace($developmentModeEnabled, $developmentModeDisabled) | |
| $content | Set-Content $optionsPath -Encoding UTF8 | |
| Write-Host '✅ Disabled development mode in options.js' -ForegroundColor Green | |
| } else { | |
| Write-Host '⚠️ Could not find development mode flag in options.js; no changes made' -ForegroundColor Yellow | |
| } |
| Compress-Archive -Path "$tempDir\*" -DestinationPath $packagePath | ||
| Remove-Item $tempDir -Recurse -Force | ||
|
|
||
| # Create the package | ||
| $packageName = "check-extension-v$Version.zip" | ||
| $packagePath = Join-Path $OutputPath $packageName | ||
| $size = [math]::Round((Get-Item $packagePath).Length / 1MB, 2) | ||
| Write-Host "✅ Created package: $PackageName ($size MB)" -ForegroundColor Green |
There was a problem hiding this comment.
If Compress-Archive fails, the script still removes $tempDir and then calls Get-Item $packagePath, which will throw and also removes the build artifacts needed for debugging. Consider using -ErrorAction Stop plus try/catch/finally so cleanup happens reliably, but only after you’ve confirmed the archive was created (and report a clear error when it isn’t).
| Write-Host ' 🦊 Firefox Add-ons: https://addons.mozilla.org/developers/' -ForegroundColor Cyan | ||
| Write-Host '3. Note the assigned extension IDs from each store' -ForegroundColor White | ||
| Write-Host '4. Update enterprise registry files with store IDs:' -ForegroundColor White | ||
| Write-Host ' .\Update-StoreIDs.ps1 -ChromeID <chrome-id> -EdgeID <edge-id>' -ForegroundColor Gray |
There was a problem hiding this comment.
The usage hint for Update-StoreIDs.ps1 uses parameter names -ChromeID / -EdgeID, but Update-StoreIDs.ps1 defines -ChromeExtensionId / -EdgeExtensionId (and -FirefoxExtensionId). Update this line so users can copy/paste a working command.
| Write-Host ' .\Update-StoreIDs.ps1 -ChromeID <chrome-id> -EdgeID <edge-id>' -ForegroundColor Gray | |
| Write-Host ' .\Update-StoreIDs.ps1 -ChromeExtensionId <chrome-id> -EdgeExtensionId <edge-id> -FirefoxExtensionId <firefox-id>' -ForegroundColor Gray |
| @@ -2,7 +2,7 @@ | |||
| # Creates a single universal package for both Chrome Web Store and Edge Add-ons | |||
There was a problem hiding this comment.
Header comment says this script "Creates a single universal package for both Chrome Web Store and Edge Add-ons", but the script now also builds a separate Firefox ZIP. Update the header comment to match the current behavior so the script’s purpose is accurate.
| # Creates a single universal package for both Chrome Web Store and Edge Add-ons | |
| # Creates a universal package for Chrome Web Store and Edge Add-ons, plus a separate Firefox ZIP |
No description provided.