-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_clean_zip.ps1
More file actions
executable file
·135 lines (120 loc) · 4.47 KB
/
Copy pathcreate_clean_zip.ps1
File metadata and controls
executable file
·135 lines (120 loc) · 4.47 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
param(
[string]$OutputZip = "",
[switch]$BuildInstallerExe,
[bool]$IncludeInstallerExe = $true,
[switch]$IncludeDocsAndImages
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$RepoRoot = if ($PSScriptRoot) { $PSScriptRoot } else { (Get-Location).Path }
if (-not $OutputZip) {
$OutputZip = Join-Path $RepoRoot ("Foxforge_clean_{0:yyyyMMdd_HHmmss}.zip" -f (Get-Date))
}
$OutputZip = [System.IO.Path]::GetFullPath($OutputZip)
$outputDir = Split-Path $OutputZip -Parent
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
}
$stageRoot = Join-Path $env:TEMP ("foxforge_clean_stage_{0}" -f ([Guid]::NewGuid().ToString("N")))
New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null
function Copy-RelativePath {
param([string]$RelativePath)
$sourcePath = Join-Path $RepoRoot $RelativePath
if (-not (Test-Path $sourcePath)) {
Write-Warning "Skipping missing path: $RelativePath"
return
}
$destPath = Join-Path $stageRoot $RelativePath
$item = Get-Item $sourcePath
if ($item.PSIsContainer) {
Copy-Item -Path $sourcePath -Destination $destPath -Recurse -Force
}
else {
$destDir = Split-Path $destPath -Parent
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
Copy-Item -Path $sourcePath -Destination $destPath -Force
}
}
try {
Write-Host "Creating clean Foxforge ZIP..." -ForegroundColor Cyan
Write-Host "Stage: $stageRoot"
$installerExeRelative = "FoxforgeInstaller.exe"
$installerExePath = Join-Path $RepoRoot $installerExeRelative
if ($BuildInstallerExe) {
$buildScript = Join-Path $RepoRoot "build_installer_exe.ps1"
if (-not (Test-Path $buildScript)) {
throw "build_installer_exe.ps1 not found at $buildScript"
}
Write-Host "Building installer launcher EXE..." -ForegroundColor Cyan
& powershell -ExecutionPolicy Bypass -File $buildScript -OutputExe $installerExePath -Force
if ($LASTEXITCODE -ne 0) {
throw "Failed to build installer EXE."
}
}
$includeDirectories = @(
"SourceCode",
"tools",
"tests",
"Fonts"
)
if ($IncludeDocsAndImages) {
$includeDirectories += @(
"docs",
"Images"
)
}
$includeFiles = @(
".gitignore",
"README.md",
"INSTALL_GUIDE.md",
"LICENSE",
"THIRD_PARTY_NOTICES.md",
"CONTRIBUTING.md",
"requirements.txt",
"start_foxforge.ps1",
"start_foxforge_web.ps1",
"start_web_foraging_stack.ps1",
"install_foxforge.ps1",
"build_installer_exe.ps1",
"create_clean_zip.ps1",
"run_integration_tests.py",
"smoke_test.py"
)
if ($IncludeInstallerExe) {
if (Test-Path $installerExePath) {
$includeFiles += $installerExeRelative
}
else {
Write-Warning "Installer EXE not found ($installerExeRelative). Run with -BuildInstallerExe to generate it."
}
}
foreach ($relative in $includeDirectories) {
Copy-RelativePath -RelativePath $relative
}
foreach ($relative in $includeFiles) {
Copy-RelativePath -RelativePath $relative
}
# Add empty runtime/project folders for first boot, without user data.
New-Item -ItemType Directory -Path (Join-Path $stageRoot "Runtime") -Force | Out-Null
New-Item -ItemType Directory -Path (Join-Path $stageRoot "Projects") -Force | Out-Null
# Remove cache and compiled artifacts if any were copied.
Get-ChildItem -Path $stageRoot -Recurse -Directory -Filter "__pycache__" -ErrorAction SilentlyContinue |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem -Path $stageRoot -Recurse -File -Include "*.pyc", "*.pyo" -ErrorAction SilentlyContinue |
Remove-Item -Force -ErrorAction SilentlyContinue
if (Test-Path $OutputZip) {
Remove-Item -Path $OutputZip -Force
}
Compress-Archive -Path (Join-Path $stageRoot "*") -DestinationPath $OutputZip -Force
Write-Host ""
Write-Host "Clean package created:" -ForegroundColor Green
Write-Host " $OutputZip"
Write-Host ""
Write-Host "Excluded by design:"
Write-Host " - Runtime user data"
Write-Host " - Projects outputs"
Write-Host " - Conversation history and generated source files"
}
finally {
Remove-Item -Path $stageRoot -Recurse -Force -ErrorAction SilentlyContinue
}