From dd88f258edf4d7c0cefd8d6baa290c7cf2b9b805 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 14 Mar 2025 07:36:33 -0500 Subject: [PATCH] test(buildserver): build serer checks --- server/scripts/build.ps1 | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 server/scripts/build.ps1 diff --git a/server/scripts/build.ps1 b/server/scripts/build.ps1 new file mode 100644 index 0000000..a596191 --- /dev/null +++ b/server/scripts/build.ps1 @@ -0,0 +1,60 @@ +param ( + [string]$dir, + [string]$app +) + +# Store the original directory +$originalDir = Get-Location + +Write-Host $originalDir + +# Check if the directory is provided +if (-not $dir) { + Write-Host "Error: Directory parameter is required." + exit 1 +} + +# Check if the directory exists +if (-not (Test-Path $dir)) { + Write-Host "Error: Directory '$dir' does not exist." + exit 1 +} + +# Navigate to the directory +Set-Location -Path $dir + +Write-Host "Cleaning the app." + +# Function to delete all `dist` and `.turbo` folders recursively +function Delete-Folders { + param ( + [string]$folderName + ) + + # Define the directories to search (packages and apps) + $searchDirectories = @("/", "frontend") + + foreach ($searchDir in $searchDirectories) { + $fullSearchPath = Join-Path -Path $dir -ChildPath $searchDir + + # Check if the directory exists + if (Test-Path $fullSearchPath) { + # Find all folders matching the name + $folders = Get-ChildItem -Path $fullSearchPath -Recurse -Directory -Filter $folderName -ErrorAction SilentlyContinue + + if ($folders) { + #Write-Host "Deleting all '$folderName' folders in $fullSearchPath and its subdirectories..." + foreach ($folder in $folders) { + #Write-Host "Deleting: $($folder.FullName)" + Remove-Item -Path $folder.FullName -Recurse -Force + } + } else { + # Write-Host "No '$folderName' folders found in $fullSearchPath and its subdirectories." + } + } else { + # Write-Host "Directory '$fullSearchPath' does not exist." + } + } +} + +Delete-Folders -folderName "dist" \ No newline at end of file