forked from Crockan/MercuryToolbox
chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet('Debug', 'Release', 'ReleaseFast', 'ReleaseSize')]
|
||||
[string]$Configuration = 'ReleaseFast',
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$generatorScriptName = 'generate-ai-prompt.ps1'
|
||||
$assetLabel = 'AI prompt'
|
||||
|
||||
function Invoke-GeneratorCheck {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ScriptPath,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[hashtable]$InvokeArgs
|
||||
)
|
||||
|
||||
try {
|
||||
& $ScriptPath @InvokeArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "$generatorScriptName exited with $LASTEXITCODE"
|
||||
}
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Host "$assetLabel check found drift: $($_.Exception.Message)"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-GeneratorWrite {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ScriptPath,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[hashtable]$InvokeArgs
|
||||
)
|
||||
|
||||
$writeArgs = @{}
|
||||
foreach ($key in $InvokeArgs.Keys) {
|
||||
if ($key -ne 'Check') {
|
||||
$writeArgs[$key] = $InvokeArgs[$key]
|
||||
}
|
||||
}
|
||||
|
||||
& $ScriptPath @writeArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "$generatorScriptName exited with $LASTEXITCODE while regenerating $assetLabel"
|
||||
}
|
||||
}
|
||||
|
||||
$scriptPath = Join-Path $PSScriptRoot $generatorScriptName
|
||||
$invokeArgs = @{
|
||||
Configuration = $Configuration
|
||||
Check = $true
|
||||
}
|
||||
if ($SkipBuild) {
|
||||
$invokeArgs.SkipBuild = $true
|
||||
}
|
||||
|
||||
if (Invoke-GeneratorCheck -ScriptPath $scriptPath -InvokeArgs $invokeArgs) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Regenerating $assetLabel before rechecking."
|
||||
Invoke-GeneratorWrite -ScriptPath $scriptPath -InvokeArgs $invokeArgs
|
||||
|
||||
if (-not (Invoke-GeneratorCheck -ScriptPath $scriptPath -InvokeArgs $invokeArgs)) {
|
||||
throw "Generated $assetLabel is still out of date after regeneration; manual intervention is required."
|
||||
}
|
||||
Reference in New Issue
Block a user