Skip to content

Update Prepare-StorePackage.ps1#135

Merged
Zacgoose merged 1 commit intoCyberDrain:devfrom
Zacgoose:package
Apr 7, 2026
Merged

Update Prepare-StorePackage.ps1#135
Zacgoose merged 1 commit intoCyberDrain:devfrom
Zacgoose:package

Conversation

@Zacgoose
Copy link
Copy Markdown
Contributor

@Zacgoose Zacgoose commented Apr 7, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 7, 2026 11:50
@Zacgoose Zacgoose merged commit 7ad6fd5 into CyberDrain:dev Apr 7, 2026
2 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the store packaging PowerShell script to generate separate ZIPs for Chrome/Edge and Firefox, while centralizing packaging logic into reusable functions.

Changes:

  • Bumps the default $Version and refactors packaging into New-StorePackage / Remove-DevelopmentFiles.
  • Produces two artifacts: a universal Chrome/Edge ZIP and a dedicated Firefox ZIP (renaming manifest.firefox.json during packaging).
  • Adds additional packaging steps (dev-file cleanup, manifest mutation, and attempted “dev mode” disabling).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +40
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
}
}
Copy link

Copilot AI Apr 7, 2026

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: -Name is 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 -Filter or -Include with -Path $TargetDir -Recurse (and consider using -File and FullName to avoid manual Join-Path).

Suggested change
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
}
}
if ($pattern -like '*`**' -or $pattern -like '*?*') {
Get-ChildItem -Path $TargetDir -Recurse -Force -File -Filter $pattern 2>$null | ForEach-Object {
Remove-Item $_.FullName -Force
Write-Host "Removed dev file: $($_.FullName)" -ForegroundColor Gray
}
}
else {
Get-ChildItem -Path $TargetDir -Recurse -Force -File 2>$null | Where-Object { $_.Name -eq $pattern } | ForEach-Object {
Remove-Item $_.FullName -Force
Write-Host "Removed dev file: $($_.FullName)" -ForegroundColor Gray
}
}

Copilot uses AI. Check for mistakes.
$manifest.version = $Version
$manifestPath = Join-Path $tempDir 'manifest.json'
if (Test-Path $manifestPath) {
$manifest = Get-Content $manifestPath | ConvertFrom-Json
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get-Content $manifestPath | ConvertFrom-Json will fail for multi-line JSON because the pipeline feeds ConvertFrom-Json one line at a time. Use Get-Content -Raw (or otherwise read the whole file as a single string) before ConvertFrom-Json.

Suggested change
$manifest = Get-Content $manifestPath | ConvertFrom-Json
$manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +97
$manifest.content_security_policy = @{
extension_pages = "script-src 'self'; object-src 'self'"
Copy link

Copilot AI Apr 7, 2026

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.

Suggested change
$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 uses AI. Check for mistakes.
Comment on lines +62 to 75
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
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a required file (notably the manifest) is missing, the script only logs a warning and still produces a ZIP, which can lead to invalid store uploads while still reporting success. Consider treating missing required inputs as a terminating error (fail fast) and returning a non-zero exit code.

Copilot uses AI. Check for mistakes.
# Convert back to JSON with proper formatting
$jsonString = $manifest | ConvertTo-Json -Depth 10
$jsonString | Set-Content $manifestPath -Encoding UTF8
$optionsPath = Join-Path $tempDir 'options\options.js'
Copy link

Copilot AI Apr 7, 2026

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.

Suggested change
$optionsPath = Join-Path $tempDir 'options\options.js'
$optionsPath = Join-Path (Join-Path $tempDir 'options') 'options.js'

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Apr 7, 2026

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +105 to 112
$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
}

Copy link

Copilot AI Apr 7, 2026

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).

Suggested change
$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 uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants