-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
50 lines (43 loc) · 2.07 KB
/
build.ps1
File metadata and controls
50 lines (43 loc) · 2.07 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
# RepoLens — Chrome Extension Build Script
# Usage: .\build.ps1
# Output: repolens-<version>.zip (ready for Chrome Web Store upload)
$ErrorActionPreference = "Stop"
# ── Read version from manifest ────────────────────────────────────────────────
$manifest = Get-Content "manifest.json" | ConvertFrom-Json
$version = $manifest.version
$zipName = "repolens-$version.zip"
# ── Files to include in the package ──────────────────────────────────────────
$include = @(
"manifest.json",
"content.js",
"popup.js",
"popup.html",
"styles.css",
"icons\icon16.png",
"icons\icon48.png",
"icons\icon128.png"
)
# ── Clean previous build ──────────────────────────────────────────────────────
if (Test-Path $zipName) {
Remove-Item $zipName -Force
Write-Host "Removed old $zipName"
}
# ── Create zip ────────────────────────────────────────────────────────────────
$tempDir = New-Item -ItemType Directory -Path "$env:TEMP\repolens-build-$version" -Force
try {
foreach ($file in $include) {
$dest = Join-Path $tempDir (Split-Path $file -Parent)
if ($dest -ne $tempDir.FullName) {
New-Item -ItemType Directory -Path $dest -Force | Out-Null
}
Copy-Item $file (Join-Path $tempDir $file) -Force
}
Compress-Archive -Path "$($tempDir.FullName)\*" -DestinationPath $zipName -CompressionLevel Optimal
Write-Host ""
Write-Host "Built: $zipName" -ForegroundColor Green
Write-Host "Size: $([math]::Round((Get-Item $zipName).Length / 1KB, 1)) KB"
Write-Host ""
Write-Host "Upload at: https://chrome.google.com/webstore/devconsole"
} finally {
Remove-Item $tempDir -Recurse -Force
}