feat(build and zip): migrated build and zip process from v1

This commit is contained in:
2025-03-14 09:06:19 -05:00
parent d5e9176d53
commit df85a30dff
2 changed files with 163 additions and 33 deletions

View File

@@ -2,6 +2,7 @@ param (
[string]$dir,
[string]$app
)
# dir is the location of the root folder.
# Store the original directory
$originalDir = Get-Location
@@ -23,38 +24,12 @@ if (-not (Test-Path $dir)) {
# Navigate to the directory
Set-Location -Path $dir
Write-Host "Cleaning the app."
# Run npm run build
Write-Host "Running 'npm run build' in directory: $dir"
npm run build
# Function to delete all `dist` and `.turbo` folders recursively
function Delete-Folders {
param (
[string]$folderName
)
Write-Host "Build completed successfully."
# 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"
# Restore the original directory
Set-Location -Path $originalDir
exit 0