38 lines
1.9 KiB
PowerShell
38 lines
1.9 KiB
PowerShell
param(
|
|
[switch]$Apply,
|
|
[int]$Number,
|
|
[ValidateSet('Backlog','Ready','In Progress','Blocked','Code Review','Testing','Ready to Deploy','Done')]
|
|
[string]$Column,
|
|
[int]$BatchSize = 8,
|
|
[int]$MaxBatches = 0,
|
|
[ValidatePattern('^[a-zA-Z0-9_-]+$')]
|
|
[string]$Session = 'jobjakt-board'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
if ($BatchSize -lt 1 -or $MaxBatches -lt 0) { throw 'Invalid batch limits' }
|
|
if ($Column -and -not $Number) { throw 'Specify the issue number for an explicit move' }
|
|
$book = Get-Content -Raw -LiteralPath "$PSScriptRoot/../docs/gitea-backlog/checkpoints.json" | ConvertFrom-Json
|
|
$rows = @($book.issues.PSObject.Properties.Value | Sort-Object number)
|
|
if ($Number) {
|
|
$rows = @($rows | Where-Object number -eq $Number)
|
|
if ($rows.Count -ne 1) { throw 'Issue absent from the reviewed manifest' }
|
|
if ($Column) { $rows[0].column = $Column }
|
|
}
|
|
$source = Get-Content -Raw -LiteralPath "$PSScriptRoot/gitea-board.js"
|
|
$temp = Join-Path ([IO.Path]::GetTempPath()) ("jobjakt-board-" + [guid]::NewGuid() + ".js")
|
|
try {
|
|
for ($start = 0; $start -lt $rows.Count; $start += $BatchSize) {
|
|
$end = [Math]::Min($rows.Count, $start + $BatchSize) - 1
|
|
$data = @{ rows = @($rows[$start..$end]); apply = [bool]$Apply; explicit = [bool]$Column }
|
|
$scriptText = $source.Replace('/*MANIFEST*/null', ($data | ConvertTo-Json -Depth 5 -Compress))
|
|
[IO.File]::WriteAllText($temp, $scriptText)
|
|
$result = & playwright-cli.cmd "-s=$Session" run-code "--filename=$temp" 2>&1
|
|
$status = $LASTEXITCODE
|
|
$result | Select-String '^\{"alreadyOrVerified"|^### Error|^(locator|page|Error):?' | ForEach-Object Line
|
|
if ($status -ne 0 -or ($result -match '^### Error')) { throw "Board batch failed at offset $start. Reload and resume." }
|
|
if ($MaxBatches -and ($start / $BatchSize + 1) -ge $MaxBatches) { break }
|
|
}
|
|
} finally {
|
|
if (Test-Path -LiteralPath $temp) { Remove-Item -LiteralPath $temp }
|
|
}
|