22# Creates a single universal package for both Chrome Web Store and Edge Add-ons
33
44param (
5- [string ]$Version = ' 1.1 .0' ,
5+ [string ]$Version = ' 1.2 .0' ,
66 [string ]$OutputPath = ' store-packages'
77)
88
@@ -16,127 +16,161 @@ if (!(Test-Path $OutputPath)) {
1616# Determine source directory based on script location
1717$scriptDir = Split-Path - Parent $MyInvocation.MyCommand.Path
1818$sourceDir = $scriptDir # Script is in the root directory
19- $tempDir = Join-Path $env: TEMP ' check-extension-package'
2019
21- Write-Host ' 📦 Preparing universal store package...' - ForegroundColor Yellow
20+ $devFilesToRemove = @ (
21+ ' *.md' ,
22+ ' *.log' ,
23+ ' .DS_Store' ,
24+ ' Thumbs.db' ,
25+ ' *.tmp'
26+ )
2227
23- # Clean temp directory
24- if (Test-Path $tempDir ) {
25- Remove-Item $tempDir - Recurse - Force
28+ function Remove-DevelopmentFiles {
29+ param (
30+ [string ]$TargetDir
31+ )
32+
33+ foreach ($pattern in $devFilesToRemove ) {
34+ Get-ChildItem $TargetDir - Name $pattern - Recurse - Force 2> $null | ForEach-Object {
35+ $fullPath = Join-Path $TargetDir $_
36+ if (Test-Path $fullPath ) {
37+ Remove-Item $fullPath - Force
38+ Write-Host " Removed dev file: $_ " - ForegroundColor Gray
39+ }
40+ }
41+ }
2642}
2743
28- # Create temp directory
29- New-Item - ItemType Directory - Path $tempDir | Out-Null
44+ function New-StorePackage {
45+ param (
46+ [string ]$Title ,
47+ [string ]$TempDirName ,
48+ [string []]$FilesToInclude ,
49+ [string ]$PackageName ,
50+ [switch ]$RenameFirefoxManifest
51+ )
3052
31- # Copy only the files needed for the extension
32- $filesToInclude = @ (
33- ' manifest.json' ,
34- ' blocked.html' ,
35- ' config' ,
36- ' images' ,
37- ' options' ,
38- ' popup' ,
39- ' rules' ,
40- ' scripts' ,
41- ' styles'
42- )
53+ $tempDir = Join-Path $env: TEMP $TempDirName
54+ Write-Host " 📦 Preparing $Title ..." - ForegroundColor Yellow
55+
56+ if (Test-Path $tempDir ) {
57+ Remove-Item $tempDir - Recurse - Force
58+ }
4359
44- foreach ($item in $filesToInclude ) {
45- $sourcePath = Join-Path $sourceDir $item
46- if (Test-Path $sourcePath ) {
47- $destPath = Join-Path $tempDir $item
48- if (Test-Path $sourcePath - PathType Container) {
49- Copy-Item $sourcePath $destPath - Recurse - Force
60+ New-Item - ItemType Directory - Path $tempDir | Out-Null
61+
62+ foreach ($item in $FilesToInclude ) {
63+ $sourcePath = Join-Path $sourceDir $item
64+ if (Test-Path $sourcePath ) {
65+ $destPath = Join-Path $tempDir $item
66+ if (Test-Path $sourcePath - PathType Container) {
67+ Copy-Item $sourcePath $destPath - Recurse - Force
68+ } else {
69+ Copy-Item $sourcePath $destPath - Force
70+ }
71+ Write-Host " ✅ Included: $item " - ForegroundColor Green
5072 } else {
51- Copy-Item $sourcePath $destPath - Force
73+ Write-Host " ⚠️ Not found: $item " - ForegroundColor Yellow
5274 }
53- Write-Host " ✅ Included: $item " - ForegroundColor Green
54- } else {
55- Write-Host " ⚠️ Not found: $item " - ForegroundColor Yellow
5675 }
57- }
5876
59- # Remove any development/debug files from copied directories
60- $devFilesToRemove = @ (
61- ' *.md' ,
62- ' *.log' ,
63- ' .DS_Store' ,
64- ' Thumbs.db' ,
65- ' *.tmp'
66- )
77+ if ($RenameFirefoxManifest ) {
78+ $firefoxManifestPath = Join-Path $tempDir ' manifest.firefox.json'
79+ $standardManifestPath = Join-Path $tempDir ' manifest.json'
6780
68- foreach ( $pattern in $devFilesToRemove ) {
69- Get-ChildItem $tempDir - Name $pattern - Recurse - Force 2> $null | ForEach-Object {
70- $fullPath = Join-Path $tempDir $_
71- if ( Test-Path $fullPath ) {
72- Remove -Item $fullPath - Force
73- Write-Host " Removed dev file: $_ " - ForegroundColor Gray
81+ if ( Test-Path $firefoxManifestPath ) {
82+ if ( Test-Path $standardManifestPath ) {
83+ Remove-Item $standardManifestPath - Force
84+ }
85+ Rename -Item - Path $firefoxManifestPath - NewName ' manifest.json '
86+ Write-Host ' ✅ Renamed manifest.firefox.json to manifest.json ' - ForegroundColor Green
7487 }
7588 }
76- }
7789
78- # Update manifest.json for store
79- $manifestPath = Join-Path $tempDir ' manifest.json'
80- if (Test-Path $manifestPath ) {
81- $manifest = Get-Content $manifestPath | ConvertFrom-Json
90+ Remove-DevelopmentFiles - TargetDir $tempDir
8291
83- # Update version
84- $manifest.version = $Version
92+ $manifestPath = Join-Path $tempDir ' manifest.json'
93+ if (Test-Path $manifestPath ) {
94+ $manifest = Get-Content $manifestPath | ConvertFrom-Json
95+ $manifest.version = $Version
96+ $manifest.content_security_policy = @ {
97+ extension_pages = " script-src 'self'; object-src 'self'"
98+ }
8599
86- # Ensure production settings
87- $manifest .content_security_policy = @ {
88- extension_pages = " script-src 'self'; object-src 'self' "
100+ $jsonString = $manifest | ConvertTo-Json - Depth 10
101+ $jsonString | Set-Content $manifestPath - Encoding UTF8
102+ Write-Host ' ✅ Updated manifest.json for store publishing ' - ForegroundColor Green
89103 }
90104
91- # Convert back to JSON with proper formatting
92- $jsonString = $manifest | ConvertTo-Json - Depth 10
93- $jsonString | Set-Content $manifestPath - Encoding UTF8
105+ $optionsPath = Join-Path $tempDir ' options\options.js'
106+ if (Test-Path $optionsPath ) {
107+ $content = Get-Content $optionsPath - Raw
108+ $content = $content -replace ' const DEVELOPMENT_MODE = true' , ' const DEVELOPMENT_MODE = false'
109+ $content | Set-Content $optionsPath - Encoding UTF8
110+ Write-Host ' ✅ Disabled development mode in options.js' - ForegroundColor Green
111+ }
94112
95- Write-Host ' ✅ Updated manifest.json for stores' - ForegroundColor Green
96- }
113+ $packagePath = Join-Path $OutputPath $PackageName
114+ if (Test-Path $packagePath ) {
115+ Remove-Item $packagePath - Force
116+ }
97117
98- # Update options.js to disable development mode
99- $optionsPath = Join-Path $tempDir ' options\options.js'
100- if (Test-Path $optionsPath ) {
101- $content = Get-Content $optionsPath - Raw
102- $content = $content -replace ' const DEVELOPMENT_MODE = true' , ' const DEVELOPMENT_MODE = false'
103- $content | Set-Content $optionsPath - Encoding UTF8
104- Write-Host ' ✅ Disabled development mode in options.js' - ForegroundColor Green
105- }
118+ Compress-Archive - Path " $tempDir \*" - DestinationPath $packagePath
119+ Remove-Item $tempDir - Recurse - Force
106120
107- # Create the package
108- $packageName = " check-extension-v$Version .zip"
109- $packagePath = Join-Path $OutputPath $packageName
121+ $size = [math ]::Round((Get-Item $packagePath ).Length / 1 MB , 2 )
122+ Write-Host " ✅ Created package: $PackageName ($size MB)" - ForegroundColor Green
110123
111- # Remove existing package if it exists
112- if (Test-Path $packagePath ) {
113- Remove-Item $packagePath - Force
124+ return @ {
125+ Name = $PackageName
126+ Size = $size
127+ }
114128}
115129
116- # Create the zip file
117- Compress-Archive - Path " $tempDir \*" - DestinationPath $packagePath
118- Write-Host " ✅ Created package: $packageName " - ForegroundColor Green
130+ $baseFilesToInclude = @ (
131+ ' blocked.html' ,
132+ ' config' ,
133+ ' images' ,
134+ ' options' ,
135+ ' popup' ,
136+ ' rules' ,
137+ ' scripts' ,
138+ ' styles'
139+ )
140+
141+ $universalFilesToInclude = @ (' manifest.json' ) + $baseFilesToInclude
142+ $firefoxFilesToInclude = @ (' manifest.firefox.json' ) + $baseFilesToInclude
119143
120- # Clean up temp directory
121- Remove-Item $tempDir - Recurse - Force
144+ $universalPackage = New-StorePackage `
145+ - Title ' universal Chrome/Edge package' `
146+ - TempDirName ' check-extension-package' `
147+ - FilesToInclude $universalFilesToInclude `
148+ - PackageName " check-extension-v$Version .zip"
122149
123- # Get file size
124- $size = [math ]::Round((Get-Item $packagePath ).Length / 1 MB , 2 )
150+ $firefoxPackage = New-StorePackage `
151+ - Title ' Firefox package' `
152+ - TempDirName ' check-extension-package-firefox' `
153+ - FilesToInclude $firefoxFilesToInclude `
154+ - PackageName " check-extension-firefox-v$Version .zip" `
155+ - RenameFirefoxManifest
125156
126157Write-Host ' '
127- Write-Host ' 🎉 Universal store package created successfully!' - ForegroundColor Green
158+ Write-Host ' 🎉 Store packages created successfully!' - ForegroundColor Green
128159Write-Host " 📁 Location: $OutputPath " - ForegroundColor Cyan
129- Write-Host " 📦 $packageName ($size MB)" - ForegroundColor White
160+ Write-Host " 📦 $ ( $universalPackage.Name ) ($ ( $universalPackage.Size ) MB)" - ForegroundColor White
161+ Write-Host " 🦊 $ ( $firefoxPackage.Name ) ($ ( $firefoxPackage.Size ) MB)" - ForegroundColor White
130162
131163Write-Host ' '
132164Write-Host ' 📋 Next Steps:' - ForegroundColor Yellow
133- Write-Host ' 1. Submit the SAME package to both stores:' - ForegroundColor White
165+ Write-Host ' 1. Submit Chrome/Edge package to their stores:' - ForegroundColor White
134166Write-Host ' 📤 Chrome Web Store: https://chrome.google.com/webstore/devconsole' - ForegroundColor Cyan
135167Write-Host ' 📤 Edge Add-ons: https://partner.microsoft.com/dashboard/microsoftedge' - ForegroundColor Cyan
136- Write-Host ' 2. Note the assigned extension IDs from each store' - ForegroundColor White
137- Write-Host ' 3. Update enterprise registry files with store IDs:' - ForegroundColor White
168+ Write-Host ' 2. Submit Firefox package to AMO:' - ForegroundColor White
169+ Write-Host ' 🦊 Firefox Add-ons: https://addons.mozilla.org/developers/' - ForegroundColor Cyan
170+ Write-Host ' 3. Note the assigned extension IDs from each store' - ForegroundColor White
171+ Write-Host ' 4. Update enterprise registry files with store IDs:' - ForegroundColor White
138172Write-Host ' .\Update-StoreIDs.ps1 -ChromeID <chrome-id> -EdgeID <edge-id>' - ForegroundColor Gray
139- Write-Host ' 4 . Test managed policies with store-installed extensions' - ForegroundColor White
173+ Write-Host ' 5 . Test managed policies with store-installed extensions' - ForegroundColor White
140174
141175Write-Host ' '
142- Write-Host ' 💡 Remember: Both stores accept the same ZIP file! ' - ForegroundColor Yellow
176+ Write-Host ' 💡 Remember: Firefox uses the dedicated Firefox ZIP from this script. ' - ForegroundColor Yellow
0 commit comments