Files
shopdb-flask/scripts/get.ps1
benjamin.baker 68c33ee896 add channel-aware distributable installers and web launcher
Follows the config-driven-badge decision through to packaging: a single channel-parameterized builder emits two distinct installers (stable from main, edge from dev-be) rather than two drifting scripts. Each package ships the image bundle, the airgap+channel compose templates, a pre-filled .env, and a one-command site installer.

Secrets ship as CHANGE_ME_* sentinels and Install-ShopDB.ps1 refuses to start until every one is rotated, so a distributable can never come up on shipped credentials. docker-compose.airgap.yml now threads SHOPDB_ENV_LABEL through the shared app-env anchor, otherwise a distributed edge stack would run the badge-capable image but never light the badge.

get.ps1 is the web launcher that makes the iex one-liners work: dev-bootstrap.ps1 operates on a local clone, so get.ps1 clones/updates the channel branch and hands off. docs/DEV-BUILD-TEST.md is the short reviewer handout with the two one-liners for Cameron to try.
2026-09-02 05:41:25 -04:00

68 lines
2.8 KiB
PowerShell

<#
.SYNOPSIS
One-line web launcher for a ShopDB dev workstation.
.DESCRIPTION
The piece that makes `iex (irm .../get.ps1)` work. dev-bootstrap.ps1 operates
on a local clone, so it cannot be run straight from the web. This launcher
fills that gap: it clones (or updates) the repo at the channel branch into a
stable local path, then hands off to scripts/dev-bootstrap.ps1 for the real
dependency-check / build / up work.
Channel is chosen by an environment variable so a pure `iex` pipe (which
cannot pass parameters) still selects stable vs edge:
# Stable (main):
$env:SHOPDB_CHANNEL='stable'; iex (irm https://raw.githubusercontent.com/ge-aero/shopdb-flask/wilm/scripts/get.ps1)
# Bleeding edge (dev-be):
$env:SHOPDB_CHANNEL='edge'; iex (irm https://raw.githubusercontent.com/ge-aero/shopdb-flask/wilm/scripts/get.ps1)
SHOPDB_DIR overrides the clone location (default %USERPROFILE%\shopdb-dev).
.NOTES
ASCII only, no emoji or smart punctuation, per repo style. PowerShell 5.1+.
Runs git-checkout of the channel branch, so it needs Git; dev-bootstrap.ps1
offers to winget-install anything else that is missing.
#>
$ErrorActionPreference = 'Stop'
$repoUrl = 'https://github.com/ge-aero/shopdb-flask.git'
$channel = if ($env:SHOPDB_CHANNEL) { $env:SHOPDB_CHANNEL } else { 'stable' }
if ($channel -notin @('stable', 'edge')) {
throw "SHOPDB_CHANNEL must be 'stable' or 'edge' (got '$channel')."
}
$branch = if ($channel -eq 'edge') { 'dev-be' } else { 'main' }
$target = if ($env:SHOPDB_DIR) { $env:SHOPDB_DIR } else { Join-Path $env:USERPROFILE 'shopdb-dev' }
Write-Host "ShopDB web launcher" -ForegroundColor White
Write-Host " Channel : $channel ($branch)" -ForegroundColor White
Write-Host " Target : $target" -ForegroundColor White
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
throw 'git is required to clone the repo. Install Git (winget install Git.Git) and re-run.'
}
if (Test-Path (Join-Path $target '.git')) {
Write-Host "==> Updating existing clone" -ForegroundColor Cyan
git -C $target fetch origin $branch
if ($LASTEXITCODE -ne 0) { throw "git fetch failed ($LASTEXITCODE)." }
git -C $target checkout $branch
if ($LASTEXITCODE -ne 0) { throw "git checkout failed ($LASTEXITCODE)." }
git -C $target pull --ff-only origin $branch
if ($LASTEXITCODE -ne 0) { throw "git pull failed ($LASTEXITCODE)." }
} else {
Write-Host "==> Cloning $branch" -ForegroundColor Cyan
git clone --branch $branch $repoUrl $target
if ($LASTEXITCODE -ne 0) { throw "git clone failed ($LASTEXITCODE)." }
}
$bootstrap = Join-Path $target 'scripts\dev-bootstrap.ps1'
if (-not (Test-Path $bootstrap)) {
throw "dev-bootstrap.ps1 not found at $bootstrap. Is the branch correct?"
}
Write-Host "==> Handing off to dev-bootstrap.ps1" -ForegroundColor Cyan
& $bootstrap -Channel $channel