37 lines
2.4 KiB
PowerShell
37 lines
2.4 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$source = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..')).TrimEnd('\')
|
|
$target = 'C:\Dev\aeternalis'
|
|
if ($source -ne 'C:\Dev\RPGTheory\aeternalis-build') { throw 'Unexpected source workspace.' }
|
|
if (-not (Test-Path -LiteralPath (Join-Path $target 'planning\VISION.md'))) { throw 'Original target planning document not found.' }
|
|
$visionHash = (Get-FileHash -LiteralPath (Join-Path $target 'planning\VISION.md') -Algorithm SHA256).Hash
|
|
$excluded = @('.git', '.tools', '.local', 'node_modules', 'test-results', 'playwright-report')
|
|
$copied = 0
|
|
foreach ($entry in Get-ChildItem -Force -LiteralPath $source) {
|
|
if ($entry.Name -in $excluded) { continue }
|
|
if ($entry.PSIsContainer) {
|
|
foreach ($file in Get-ChildItem -File -Recurse -Force -LiteralPath $entry.FullName) {
|
|
$relative = $file.FullName.Substring($source.Length + 1)
|
|
if ($relative -eq 'planning\VISION.md') { continue }
|
|
$destination = [IO.Path]::GetFullPath((Join-Path $target $relative))
|
|
if (-not $destination.StartsWith($target + '\', [StringComparison]::OrdinalIgnoreCase)) { throw 'Copy escaped destination.' }
|
|
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $destination) | Out-Null
|
|
Copy-Item -LiteralPath $file.FullName -Destination $destination -Force
|
|
if ((Get-FileHash -LiteralPath $destination -Algorithm SHA256).Hash -ne (Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash) { throw "Copy mismatch: $relative" }
|
|
$copied++
|
|
}
|
|
} else {
|
|
Copy-Item -LiteralPath $entry.FullName -Destination (Join-Path $target $entry.Name) -Force
|
|
$copied++
|
|
}
|
|
}
|
|
if ((Get-FileHash -LiteralPath (Join-Path $target 'planning\VISION.md') -Algorithm SHA256).Hash -ne $visionHash) { throw 'Original vision changed unexpectedly.' }
|
|
$binary = Join-Path $source '.local\world-001.exe'
|
|
if (Test-Path -LiteralPath $binary) {
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $target '.local') | Out-Null
|
|
$binaryDestination = Join-Path $target '.local\world-001.exe'
|
|
Copy-Item -LiteralPath $binary -Destination $binaryDestination -Force
|
|
if ((Get-FileHash -LiteralPath $binaryDestination -Algorithm SHA256).Hash -ne (Get-FileHash -LiteralPath $binary -Algorithm SHA256).Hash) { throw 'Server binary copy mismatch.' }
|
|
$copied++
|
|
}
|
|
Write-Output "Copied $copied files into $target. Original vision and .git preserved."
|