From e03e92c18d660f78f59a7db5c384ded7c29921e7 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Sat, 6 Sep 2025 09:00:11 -0500 Subject: [PATCH] ci(build): changes to build then copy to new version being rewritten --- .includes | 8 +++++ server/scripts/copyToLst.ps1 | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .includes create mode 100644 server/scripts/copyToLst.ps1 diff --git a/.includes b/.includes new file mode 100644 index 0000000..b0a0db7 --- /dev/null +++ b/.includes @@ -0,0 +1,8 @@ +database +dist +frontend/dist +CHANGELOG.md +drizzle.config.ts +package.json +package-lock.json +README.md \ No newline at end of file diff --git a/server/scripts/copyToLst.ps1 b/server/scripts/copyToLst.ps1 new file mode 100644 index 0000000..3bb498e --- /dev/null +++ b/server/scripts/copyToLst.ps1 @@ -0,0 +1,61 @@ +param( + [string]$IncludesFile = ".includes", + [string]$Destination = "C:\Users\matthes01\Documents\lst\lstV2", + [string]$BaseDir = "C:\Users\matthes01\Documents\lst" +) + +# .\copy-includes.ps1 will run with defaults +# .\copy-includes.ps1 -IncludesFile ".\mylist.txt" -Destination "D:\build\lstV2" will override defaults + +if (-Not (Test-Path $IncludesFile)) { + Write-Error "Includes file not found: $IncludesFile" + exit 1 +} + +# Ensure destination exists +if (!(Test-Path -Path $Destination)) { + New-Item -ItemType Directory -Path $Destination | Out-Null + Write-Host "Folder created: $Destination" +} + +# Empty the destination folder +Get-ChildItem -Path $Destination -Recurse -Force | Remove-Item -Recurse -Force + +# If BaseDir wasn’t explicitly passed in, use IncludesFile directory +if (-not $PSBoundParameters.ContainsKey('BaseDir')) { + $BaseDir = Split-Path -Parent (Resolve-Path $IncludesFile) +} + +# Read includes list (ignore blank lines & comments) +$items = Get-Content $IncludesFile | + ForEach-Object { $_.Trim() } | + Where-Object { $_ -and -not $_.StartsWith("#") } + +foreach ($item in $items) { + if ([System.IO.Path]::IsPathRooted($item)) { + # Absolute path (rare case) + $sourcePath = $item + $relative = Split-Path $item -Leaf # just take folder/file name + } else { + # Relative to BaseDir + $sourcePath = Join-Path $BaseDir $item + $relative = $item # keep full relative path e.g. "frontend\dist" + } + + if (-Not (Test-Path $sourcePath)) { + Write-Warning "Skipping missing path: $sourcePath" + continue + } + + # Destination path should preserve the relative structure + $targetPath = Join-Path $Destination $relative + + # Ensure the parent folder exists + $targetDir = Split-Path $targetPath -Parent + if (-not (Test-Path $targetDir)) { + New-Item -ItemType Directory -Path $targetDir -Force | Out-Null + } + + Write-Host "Copying $sourcePath -> $targetPath" -ForegroundColor Cyan + Copy-Item -Path $sourcePath -Destination $targetPath -Recurse -Force +} \ No newline at end of file