-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ps1
More file actions
64 lines (53 loc) · 2.14 KB
/
Copy pathpackage.ps1
File metadata and controls
64 lines (53 loc) · 2.14 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
# package.ps1
# Genera un pacchetto ZIP pronto per il rilascio dell'estensione, escludendo i file di sviluppo.
$ErrorActionPreference = "Stop"
Write-Host "=== CREAZIONE PACCHETTO ESTENSIONE ===" -ForegroundColor Cyan
$buildDir = "dist"
$archiveName = "$buildDir/cerca-indirizzo-su-google-maps.zip"
# 1. Crea la cartella dist se non esiste
if (!(Test-Path -Path $buildDir)) {
New-Item -ItemType Directory -Path $buildDir | Out-Null
Write-Host "Creata cartella $buildDir/" -ForegroundColor Yellow
}
# 2. Rimuove eventuali archivi precedenti
if (Test-Path -Path $archiveName) {
Remove-Item -Path $archiveName -Force
Write-Host "Rimosso vecchio archivio $archiveName" -ForegroundColor Yellow
}
# 3. Definisce i file e le cartelle da includere nell'estensione
$filesToInclude = @(
"manifest.json",
"LICENSE",
"assets",
"content",
"options",
"src"
)
# 4. Crea una cartella temporanea per il packaging
$tempDir = "$buildDir/temp_package"
if (Test-Path -Path $tempDir) {
Remove-Item -Recurse -Force $tempDir
}
New-Item -ItemType Directory -Path $tempDir | Out-Null
# 5. Copia solo i file selezionati nella cartella temporanea
Write-Host "Copia dei file dell'estensione..." -ForegroundColor Yellow
foreach ($item in $filesToInclude) {
if (Test-Path -Path $item) {
$dest = Join-Path $tempDir $item
# Crea la cartella di destinazione se necessario per il caricamento ricorsivo
if (Test-Path -Path $item -PathType Container) {
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Copy-Item -Path "$item\*" -Destination $dest -Recurse -Force
} else {
Copy-Item -Path $item -Destination $dest -Force
}
Write-Host " [+] $item" -ForegroundColor Gray
}
}
# 6. Comprime la cartella temporanea in formato ZIP
Write-Host "Compressione dei file..." -ForegroundColor Yellow
Compress-Archive -Path "$tempDir\*" -DestinationPath $archiveName -Force
# 7. Pulisce la cartella temporanea
Remove-Item -Recurse -Force $tempDir
Write-Host "=== PACCHETTO CREATO CON SUCCESSO! ===" -ForegroundColor Green
Write-Host "File salvato in: $archiveName" -ForegroundColor Green