Process 1 build 0203261610
This commit is contained in:
@@ -23,6 +23,14 @@ function Write-TextFile {
|
||||
[System.IO.File]::WriteAllText($fullPath, $normalized, $Utf8NoBom)
|
||||
}
|
||||
|
||||
function Assert-LastExitCode {
|
||||
param([Parameter(Mandatory = $true)][string]$CommandName)
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "$CommandName failed with exit code $LASTEXITCODE."
|
||||
}
|
||||
}
|
||||
|
||||
function Read-TextFile {
|
||||
param([Parameter(Mandatory = $true)][string]$Path)
|
||||
|
||||
@@ -171,12 +179,32 @@ function Update-BuildFiles {
|
||||
Write-TextFile -Path ".env" -Content $updatedEnv
|
||||
}
|
||||
|
||||
Push-Location frontend
|
||||
try {
|
||||
npm version $BuildNumber --no-git-tag-version --allow-same-version | Out-Null
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
$packageJson = Read-TextFile -Path "frontend/package.json"
|
||||
$packageJsonRegex = [regex]::new('"version"\s*:\s*"\d+"')
|
||||
$updatedPackageJson = $packageJsonRegex.Replace(
|
||||
$packageJson,
|
||||
"`"version`": `"$BuildNumber`"",
|
||||
1
|
||||
)
|
||||
Write-TextFile -Path "frontend/package.json" -Content $updatedPackageJson
|
||||
|
||||
$packageLock = Read-TextFile -Path "frontend/package-lock.json"
|
||||
$packageLockVersionRegex = [regex]::new('"version"\s*:\s*"\d+"')
|
||||
$updatedPackageLock = $packageLockVersionRegex.Replace(
|
||||
$packageLock,
|
||||
"`"version`": `"$BuildNumber`"",
|
||||
1
|
||||
)
|
||||
$packageLockRootRegex = [regex]::new(
|
||||
'(""\s*:\s*\{\s*"name"\s*:\s*"magent-frontend"\s*,\s*"version"\s*:\s*)"\d+"',
|
||||
[System.Text.RegularExpressions.RegexOptions]::Singleline
|
||||
)
|
||||
$updatedPackageLock = $packageLockRootRegex.Replace(
|
||||
$updatedPackageLock,
|
||||
'$1"' + $BuildNumber + '"',
|
||||
1
|
||||
)
|
||||
Write-TextFile -Path "frontend/package-lock.json" -Content $updatedPackageLock
|
||||
}
|
||||
|
||||
function Get-ChangedFilesSummary {
|
||||
@@ -211,6 +239,7 @@ try {
|
||||
|
||||
$script:CurrentStep = "rebuilding local docker stack"
|
||||
docker compose up -d --build
|
||||
Assert-LastExitCode -CommandName "docker compose up -d --build"
|
||||
|
||||
$script:CurrentStep = "verifying backend health"
|
||||
$health = Wait-ForHttp -Url "http://127.0.0.1:8000/health"
|
||||
@@ -226,6 +255,7 @@ try {
|
||||
|
||||
$script:CurrentStep = "committing changes"
|
||||
git add -A
|
||||
Assert-LastExitCode -CommandName "git add -A"
|
||||
$changedFiles = Get-ChangedFilesSummary
|
||||
if ((git status --short).Trim()) {
|
||||
if (-not $SkipCommit) {
|
||||
@@ -233,6 +263,7 @@ try {
|
||||
$CommitMessage = "Process 1 build $buildNumber"
|
||||
}
|
||||
git commit -m $CommitMessage
|
||||
Assert-LastExitCode -CommandName "git commit"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user