diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 2fa9816..75ba648 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -3,6 +3,12 @@ $rootDir = Join-Path $scriptDir ".." $releaseScript = Join-Path $scriptDir "release.ps1" $packageJsonPath = Join-Path $rootDir "package.json" +# tmp scripts to get lstv2 into this build and zipped up with everything +. (Join-Path $PSScriptRoot "lstV2Build.ps1") + +# will run the lstv2 build first so we know for sure its copied over +Build-LstV2-And-Copy + # Path to BUILD_NUMBER file, assuming root is one level up from scripts $buildNumberFile = Join-Path $scriptDir "..\BUILD_NUMBER" $envFile = Join-Path $rootDir ".env" @@ -139,6 +145,9 @@ try { # 5. Create Gitea release via our script npm run release + + # deleteing the temp folder so we always cleaned up + Delete-Tmp-Folder if ($LASTEXITCODE -ne 0) { throw "Failed to create Gitea release" } @@ -146,6 +155,9 @@ try { } } catch { Write-Warning "Release process failed: $_" + + # deleteing the temp folder so we always cleaned up + Delete-Tmp-Folder exit 1 } diff --git a/scripts/lstV2Build.ps1 b/scripts/lstV2Build.ps1 new file mode 100644 index 0000000..90115a7 --- /dev/null +++ b/scripts/lstV2Build.ps1 @@ -0,0 +1,67 @@ + + +#This is only temp until we make the entire transtion over to just this app...... long time but working on build process +$lstv2Loc = "C:\Users\matthes01\Documents\lstV2" +$lstv2BuildsDir = Join-Path $lstv2Loc "builds" +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$tmpLoc = Join-Path $scriptDir "\tmp" + + +function Build-LstV2-And-Copy { + if (Test-Path $tmpLoc) { + Write-Host "Temp folder for lst builds exist, moving to run the build function." + } else { + Write-Host "Tmp Folder dose not exist we will create it." + New-Item -Path $scriptDir -Name "tmp" -ItemType "Directory" + } + + Write-Host "Jumping into lstV2 to build it." + Push-Location $lstv2Loc + npm run build + + Write-Host "LSTV2 Finished building." + + Write-Host "Copy the latest build to the tmpLoc" + + # Get all build files and sort by creation time + $buildFiles = Get-ChildItem -Path $lstv2BuildsDir -File -Filter "*.zip" | + Sort-Object LastWriteTime -Descending + + if ($buildFiles.Count -eq 0) { + Write-Error "No build files found in $lstv2BuildsDir" + Pop-Location + exit 1 + } + + # Get the most recent build + $latestBuild = $buildFiles[0] + $destinationPath = Join-Path $tmpLoc $latestBuild.Name + + Write-Host "Copying latest build: $($latestBuild.Name)" + Write-Host "Created: $($latestBuild.LastWriteTime)" + Write-Host "Size: $([math]::Round($latestBuild.Length/1MB, 2)) MB" + + # Copy the file + try { + Copy-Item -Path $latestBuild.FullName -Destination $destinationPath -Force + Write-Host "Successfully copied to: $destinationPath" + } + catch { + Write-Error "Failed to copy build file: $_" + Pop-Location + exit 1 + } + + Pop-Location +} + +function Delete-Tmp-Folder +{ + Write-Host "Removing the temp folder to keep it all clean" + if (Test-Path $tmpLoc) { + Remove-Item -Path $tmpLoc -Recurse + }else { + Write-Host "Tmp folder dose not exist, nothing to delete." + } +} +