Bring in pipeline, auth, deploy and docs from the boilerplate
roledesk is built on the boilerplate from here on: pipeline 2.0 (queue and scheduler), auth (one password, sessions, passkeys), the deploy kit and its docs, plus the coupling and packaging tests. Downstream copies, unedited. Refreshed from boilerplate/d56949f7d0f6c0bfe5745478e09007bfad67ae87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1f436104f3
commit
9d666d0937
76 files changed
+15235
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Shared plumbing for the release scripts. Dot-source it; do not run it.
|
||||
|
||||
.DESCRIPTION
|
||||
Dot-sourcing runs in the caller's scope, so everything defined here --
|
||||
$root, $settings, Setting, Assert-Ok, Write-Step, Remove-ReleaseTemp -- is
|
||||
the caller's afterwards. One copy of the release.env reader, because three
|
||||
copies is three places for it to drift.
|
||||
#>
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
#: The repository root, worked out from this file rather than from the working
|
||||
#: directory, so the scripts can be run from anywhere.
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
function Assert-Ok([string] $What) {
|
||||
if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
function Write-Step([string] $Text) {
|
||||
Write-Host ''
|
||||
Write-Host "== $Text" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$envFile = Join-Path $PSScriptRoot 'release.env'
|
||||
if (-not (Test-Path $envFile)) {
|
||||
throw "no deploy\release.env - copy deploy\release.env.example and fill it in"
|
||||
}
|
||||
$settings = @{}
|
||||
foreach ($line in Get-Content $envFile) {
|
||||
if ($line -match '^\s*(#|$)') { continue }
|
||||
# A line with no `=` is a typo, not a setting. Say so here rather than
|
||||
# letting it surface later as a null reference three functions away.
|
||||
if ($line -notmatch '=') { throw "release.env: not a KEY=VALUE line: $line" }
|
||||
$key, $value = $line -split '=', 2
|
||||
$settings[$key.Trim()] = $value.Trim().Trim('"')
|
||||
}
|
||||
|
||||
function Setting([string] $Name, [string] $Default, [switch] $Required) {
|
||||
if ($settings.ContainsKey($Name) -and $settings[$Name]) { return $settings[$Name] }
|
||||
if ($Required) { throw "set $Name in deploy\release.env" }
|
||||
return $Default
|
||||
}
|
||||
|
||||
#: What temporary directories this release is allowed to delete. Everything
|
||||
#: below is created by these scripts and named for it.
|
||||
$Name = Setting NAME -Required
|
||||
|
||||
# Only ever deletes a <name>-* entry directly under the temp directory. A
|
||||
# guard, not a convenience: these paths are built by string concatenation and
|
||||
# handed to `Remove-Item -Recurse -Force`, and one empty variable in that
|
||||
# sentence is a very bad afternoon.
|
||||
function Remove-ReleaseTemp([string[]] $Paths) {
|
||||
$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('\') + '\'
|
||||
foreach ($path in $Paths) {
|
||||
$resolved = [IO.Path]::GetFullPath($path)
|
||||
if (-not $resolved.StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase) -or
|
||||
-not ([IO.Path]::GetFileName($resolved)).StartsWith("$Name-")) {
|
||||
throw "Unsafe release temporary path: $resolved"
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolved) { Remove-Item -LiteralPath $resolved -Recurse -Force }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user