-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ps1
More file actions
86 lines (71 loc) · 2.51 KB
/
package.ps1
File metadata and controls
86 lines (71 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# PowerShell script to package the Link Fetch extension
# Run this script to create a ZIP file for submission to the Chrome Web Store
# Set variables
$extensionName = "Link-Fetch"
$version = (Get-Content -Raw -Path manifest.json | ConvertFrom-Json).version
$outputFileName = "${extensionName}-v${version}.zip"
$releaseFileName = "${extensionName}-Release-v${version}.zip"
# Ensure we're in the correct directory
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptPath
# Define files to include/exclude
$filesToInclude = @(
"manifest.json",
"background.js",
"content.js",
"popup.html",
"popup.js",
"styles.css",
"README.md",
"icons/*"
)
$filesToExclude = @(
"*.zip",
"*.bak",
"*.ps1",
"screenshots/*",
".git/*",
"*.md"
)
# Create temporary directory
$tempDir = New-Item -ItemType Directory -Path "$scriptPath\temp_packaging" -Force
# Copy files to temp directory
foreach ($filePattern in $filesToInclude) {
# Check if it's a directory with wildcard
if ($filePattern -like "*/*") {
$directory = $filePattern.Split('/')[0]
$pattern = $filePattern.Split('/')[1]
# Create directory in temp if needed
New-Item -ItemType Directory -Path "$tempDir\$directory" -Force | Out-Null
# Copy files
if ($pattern -eq "*") {
Copy-Item "$scriptPath\$directory\*" "$tempDir\$directory\" -Recurse
} else {
Copy-Item "$scriptPath\$directory\$pattern" "$tempDir\$directory\" -Recurse
}
} else {
# It's a regular file
Copy-Item "$scriptPath\$filePattern" "$tempDir\" -Recurse
}
}
# Remove files that should be excluded
foreach ($excludePattern in $filesToExclude) {
Get-ChildItem -Path $tempDir -Recurse -Include $excludePattern | Remove-Item -Force -Recurse
}
# Create regular zip file
if (Test-Path $outputFileName) {
Remove-Item $outputFileName -Force
}
Add-Type -Assembly System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($tempDir, "$scriptPath\$outputFileName")
# Create release zip file
if (Test-Path $releaseFileName) {
Remove-Item $releaseFileName -Force
}
Copy-Item "$scriptPath\$outputFileName" "$scriptPath\$releaseFileName"
# Cleanup
Remove-Item -Path $tempDir -Recurse -Force
Write-Host "Packages created:" -ForegroundColor Green
Write-Host "- $outputFileName" -ForegroundColor Green
Write-Host "- $releaseFileName" -ForegroundColor Green
Write-Host "Ready for submission to Chrome Web Store."