-
Notifications
You must be signed in to change notification settings - Fork 99
Update Prepare-StorePackage.ps1 #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Creates a single universal package for both Chrome Web Store and Edge Add-ons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| param( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$Version = '1.1.0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$Version = '1.2.0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$OutputPath = 'store-packages' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,127 +16,161 @@ if (!(Test-Path $OutputPath)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Determine source directory based on script location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $sourceDir = $scriptDir # Script is in the root directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $tempDir = Join-Path $env:TEMP 'check-extension-package' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host '📦 Preparing universal store package...' -ForegroundColor Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $devFilesToRemove = @( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.md', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.log', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '.DS_Store', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Thumbs.db', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.tmp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Clean temp directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $tempDir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove-Item $tempDir -Recurse -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function Remove-DevelopmentFiles { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| param( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$TargetDir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($pattern in $devFilesToRemove) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create temp directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| New-Item -ItemType Directory -Path $tempDir | Out-Null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function New-StorePackage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| param( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$Title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$TempDirName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string[]]$FilesToInclude, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [string]$PackageName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [switch]$RenameFirefoxManifest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Copy only the files needed for the extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $filesToInclude = @( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'manifest.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'blocked.html', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'config', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'images', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'options', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'popup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'rules', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'scripts', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'styles' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $tempDir = Join-Path $env:TEMP $TempDirName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "📦 Preparing $Title..." -ForegroundColor Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $tempDir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove-Item $tempDir -Recurse -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($item in $filesToInclude) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $sourcePath = Join-Path $sourceDir $item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $sourcePath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $destPath = Join-Path $tempDir $item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $sourcePath -PathType Container) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copy-Item $sourcePath $destPath -Recurse -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| New-Item -ItemType Directory -Path $tempDir | Out-Null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($item in $FilesToInclude) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $sourcePath = Join-Path $sourceDir $item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $sourcePath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $destPath = Join-Path $tempDir $item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $sourcePath -PathType Container) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copy-Item $sourcePath $destPath -Recurse -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copy-Item $sourcePath $destPath -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "✅ Included: $item" -ForegroundColor Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copy-Item $sourcePath $destPath -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "⚠️ Not found: $item" -ForegroundColor Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "✅ Included: $item" -ForegroundColor Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "⚠️ Not found: $item" -ForegroundColor Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
75
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove any development/debug files from copied directories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $devFilesToRemove = @( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.md', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.log', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '.DS_Store', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Thumbs.db', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '*.tmp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($RenameFirefoxManifest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $firefoxManifestPath = Join-Path $tempDir 'manifest.firefox.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $standardManifestPath = Join-Path $tempDir 'manifest.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($pattern in $devFilesToRemove) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Get-ChildItem $tempDir -Name $pattern -Recurse -Force 2>$null | ForEach-Object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $fullPath = Join-Path $tempDir $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $fullPath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove-Item $fullPath -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "Removed dev file: $_" -ForegroundColor Gray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $firefoxManifestPath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $standardManifestPath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove-Item $standardManifestPath -Force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Rename-Item -Path $firefoxManifestPath -NewName 'manifest.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host '✅ Renamed manifest.firefox.json to manifest.json' -ForegroundColor Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update manifest.json for store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifestPath = Join-Path $tempDir 'manifest.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $manifestPath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifest = Get-Content $manifestPath | ConvertFrom-Json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remove-DevelopmentFiles -TargetDir $tempDir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifest.version = $Version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifestPath = Join-Path $tempDir 'manifest.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Test-Path $manifestPath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifest = Get-Content $manifestPath | ConvertFrom-Json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $manifest = Get-Content $manifestPath | ConvertFrom-Json | |
| $manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overwrites content_security_policy with a hard-coded value that drops the existing font-src / style-src allowances currently present in the repo manifests, while extension pages reference Google Fonts (e.g., blocked.html, options/options.html, popup/popup.html). Either preserve the existing CSP directives when updating, or also remove/replace the external font usage so the packaged extension doesn’t break at runtime.
| $manifest.content_security_policy = @{ | |
| extension_pages = "script-src 'self'; object-src 'self'" | |
| $existingExtensionPagesCsp = $null | |
| if ($null -ne $manifest.content_security_policy) { | |
| if ($manifest.content_security_policy -is [string]) { | |
| $existingExtensionPagesCsp = $manifest.content_security_policy | |
| } | |
| elseif ($null -ne $manifest.content_security_policy.extension_pages) { | |
| $existingExtensionPagesCsp = $manifest.content_security_policy.extension_pages | |
| } | |
| } | |
| if ([string]::IsNullOrWhiteSpace($existingExtensionPagesCsp)) { | |
| $existingExtensionPagesCsp = "script-src 'self'; object-src 'self'" | |
| } | |
| else { | |
| if ($existingExtensionPagesCsp -notmatch "(^|;)\s*script-src\s+'self'(\s*;|$)") { | |
| $existingExtensionPagesCsp = "$existingExtensionPagesCsp; script-src 'self'" | |
| } | |
| if ($existingExtensionPagesCsp -notmatch "(^|;)\s*object-src\s+'self'(\s*;|$)") { | |
| $existingExtensionPagesCsp = "$existingExtensionPagesCsp; object-src 'self'" | |
| } | |
| } | |
| $manifest.content_security_policy = @{ | |
| extension_pages = $existingExtensionPagesCsp |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Join-Path $tempDir 'options\\options.js' passes a child path containing path separators (and double backslashes), which is brittle and can behave unexpectedly on non-Windows PowerShell. Prefer joining path segments (Join-Path (Join-Path $tempDir 'options') 'options.js') or using a single separator.
| $optionsPath = Join-Path $tempDir 'options\options.js' | |
| $optionsPath = Join-Path (Join-Path $tempDir 'options') 'options.js' |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “disable development mode” step replaces const DEVELOPMENT_MODE = true, but options/options.js in this repo doesn’t define that constant, so the replacement will be a no-op while still logging success. Either remove this step, or update it to modify the actual dev-mode mechanism used by the options UI (it currently derives isDev from the presence of update_url in the manifest).
| $optionsPath = Join-Path $tempDir 'options\options.js' | |
| if (Test-Path $optionsPath) { | |
| $content = Get-Content $optionsPath -Raw | |
| $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 | |
| } | |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “Next Steps” command uses -ChromeID / -EdgeID, but Update-StoreIDs.ps1 defines parameters -ChromeExtensionId, -EdgeExtensionId, and -FirefoxExtensionId. Update this output 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get-ChildItem $TargetDir -Name $pattern ...is not filtering by$pattern:-Nameis a switch parameter and the next argument ($pattern) is treated as another-Path, so the dev-file patterns likely won’t be matched/removed. Use-Filteror-Includewith-Path $TargetDir -Recurse(and consider using-FileandFullNameto avoid manualJoin-Path).