jamescliffordspratt_macros/release.ps1

212 lines
8.4 KiB
PowerShell
Raw Permalink Normal View History

feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
<#
.SYNOPSIS
Interactive release script for the Macros Obsidian plugin.
Stages changes, commits, bumps version, and pushes triggering
an automated GitHub Actions release.
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
.EXAMPLE
.\release.ps1
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
# ── Helpers ─────────────────────────────────────────────────────────────────
function Header([string]$msg) {
Write-Host ""
Write-Host " $msg" -ForegroundColor White
Write-Host (" " + ("" * $msg.Length)) -ForegroundColor DarkGray
}
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
function Step([string]$msg) {
Write-Host "`n$msg" -ForegroundColor Cyan
}
function Ok([string]$msg) {
Write-Host "$msg" -ForegroundColor Green
}
function Warn([string]$msg) {
Write-Host " ! $msg" -ForegroundColor Yellow
}
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
function Fail([string]$msg) {
Write-Host "`n$msg" -ForegroundColor Red
Write-Host ""
Read-Host " Press Enter to exit"
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
exit 1
}
function Prompt([string]$msg) {
Write-Host " $msg" -ForegroundColor Gray -NoNewline
return (Read-Host " ")
}
function Menu([string]$title, [string[]]$options, [string[]]$descriptions, [int]$default = 0) {
Write-Host ""
Write-Host " $title" -ForegroundColor White
for ($i = 0; $i -lt $options.Length; $i++) {
$marker = if ($i -eq $default) { "" } else { " " }
$num = $i + 1
Write-Host " $marker [$num] $($options[$i])" -ForegroundColor $(if ($i -eq $default) { "Cyan" } else { "Gray" })
Write-Host " $($descriptions[$i])" -ForegroundColor DarkGray
}
Write-Host ""
$choice = Prompt "Choose (1-$($options.Length)) [default: $($default+1)]"
if ([string]::IsNullOrWhiteSpace($choice)) { return $default }
$idx = [int]$choice - 1
if ($idx -lt 0 -or $idx -ge $options.Length) { return $default }
return $idx
}
# ── Banner ───────────────────────────────────────────────────────────────────
Clear-Host
Write-Host ""
Write-Host " ╔══════════════════════════════════════╗" -ForegroundColor DarkCyan
Write-Host " ║ Macros Plugin Release Script ║" -ForegroundColor Cyan
Write-Host " ╚══════════════════════════════════════╝" -ForegroundColor DarkCyan
# ── Check git status ─────────────────────────────────────────────────────────
Header "Changed files"
$status = git status --short
if ([string]::IsNullOrWhiteSpace($status)) {
Warn "No changes detected. Nothing to commit."
Write-Host ""
Read-Host " Press Enter to exit"
exit 0
}
$status -split "`n" | ForEach-Object {
if ($_.Trim()) { Write-Host " $_" -ForegroundColor DarkGray }
}
# ── Commit type ──────────────────────────────────────────────────────────────
$typeIdx = Menu "Commit type" `
@("feat", "fix", "chore", "docs", "refactor", "perf", "test") `
@(
"New feature or capability → bumps MINOR version",
"Bug fix or correction → bumps PATCH version",
"Maintenance, deps, tooling → bumps PATCH version",
"Documentation only → bumps PATCH version",
"Code restructure, no behaviour change → bumps PATCH version",
"Performance improvement → bumps PATCH version",
"Adding or fixing tests → bumps PATCH version"
)
$types = @("feat", "fix", "chore", "docs", "refactor", "perf", "test")
$commitType = $types[$typeIdx]
# ── Commit description ───────────────────────────────────────────────────────
Header "Commit message"
$subject = ""
while ([string]::IsNullOrWhiteSpace($subject)) {
$subject = Prompt "Short description (e.g. 'add weekly summary view')"
}
Write-Host ""
Write-Host " Optional: add a longer body (press Enter to skip)" -ForegroundColor Gray
Write-Host " You can paste multiple lines. Enter a blank line when done." -ForegroundColor DarkGray
Write-Host ""
$bodyLines = @()
while ($true) {
$line = Prompt " >"
if ([string]::IsNullOrWhiteSpace($line)) { break }
$bodyLines += $line
}
$commitMsg = "${commitType}: ${subject}"
if ($bodyLines.Count -gt 0) {
$commitMsg += "`n`n" + ($bodyLines -join "`n")
}
# ── Breaking change? ─────────────────────────────────────────────────────────
$breaking = Prompt "Breaking change? (y/N)"
if ($breaking -match "^[Yy]") {
$breakingDesc = Prompt "Describe the breaking change"
$commitMsg += "`n`nBREAKING CHANGE: $breakingDesc"
}
# ── Version bump ─────────────────────────────────────────────────────────────
$defaultBump = if ($commitType -eq "feat" -or $breaking -match "^[Yy]") { 1 } else { 0 }
if ($breaking -match "^[Yy]") { $defaultBump = 2 }
$bumpIdx = Menu "Version bump" `
@("patch", "minor", "major") `
@(
"x.x.X Bug fixes, maintenance, small improvements",
"x.X.0 New features (backward compatible)",
"X.0.0 Breaking changes"
) `
$defaultBump
$bumps = @("patch", "minor", "major")
$bump = $bumps[$bumpIdx]
# ── Confirm ───────────────────────────────────────────────────────────────────
$currentVersion = node -p "require('./package.json').version"
Header "Ready to release"
Write-Host " Commit : $commitMsg" -ForegroundColor White
Write-Host " Bump : $bump ($currentVersion → next $bump)" -ForegroundColor White
Write-Host ""
$confirm = Prompt "Proceed? (Y/n)"
if ($confirm -match "^[Nn]") {
Write-Host "`n Aborted." -ForegroundColor Yellow
exit 0
}
# ── Execute ───────────────────────────────────────────────────────────────────
Step "Staging all changes..."
git add .
Ok "Staged"
Step "Committing..."
git commit -m $commitMsg
if ($LASTEXITCODE -ne 0) { Fail "Commit failed." }
Ok "Committed"
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
Step "Type checking..."
npm run typecheck
if ($LASTEXITCODE -ne 0) { Fail "Type check failed. Fix errors before releasing." }
Ok "Types OK"
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
Step "Bumping version ($bump) and updating CHANGELOG..."
npx standard-version --release-as $bump
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
if ($LASTEXITCODE -ne 0) { Fail "Version bump failed." }
Step "Syncing version to manifest.json..."
node sync-version.js
if ($LASTEXITCODE -ne 0) { Fail "Version sync failed." }
git add manifest.json
$syncResult = git commit -m "chore: sync version to manifest" --no-verify 2>&1
if ($LASTEXITCODE -ne 0 -and $syncResult -notmatch "nothing to commit") {
Warn "manifest sync commit skipped (already in sync)"
} else {
Ok "manifest.json synced"
feat: add micronutrient tracking foundation Add a micronutrient tracking system covering vitamins, minerals and other commonly tracked nutrients, with targets derived from age/sex/life-stage DRIs. - Add micronutrient catalogue (32 nutrients) with an RDA/AI database keyed by standard life-stage groups, including pregnancy/lactation, plus profile resolution, target/override helpers and frontmatter extraction/scaling - Add a "Micronutrients" settings tab with a master enable toggle, a personal profile (sex/age/life stage), and per-nutrient editable targets that default to the recommended value and can be overridden or reset - Add an optional, collapsible micronutrient section to the manual food entry modal: pick nutrients from a category-grouped dropdown and save them to the food's frontmatter and body - Append a micronutrient summary table beneath the macros processor output (consumed vs target with progress bars), shown only when tracking is enabled and the foods carry micronutrient data - Register a no-op handler for the deprecated macrosmicro block so any leftover blocks render nothing instead of their raw source - Add styles for the new UI and fix the obscured manual-entry dropdown by restoring native select rendering - Add Spanish and Chinese translations for all new strings - Add GitHub Actions release workflow Persisted settings: micronutrientTrackingEnabled, micronutrientProfile, micronutrientTargets (with load-time migration guards). API fetching of micronutrient data is intentionally deferred; the frontmatter key scheme is the shared contract future fetchers will write into.
2026-06-12 14:44:11 +00:00
}
Step "Pushing to GitHub..."
git push --follow-tags origin main
if ($LASTEXITCODE -ne 0) { Fail "Push failed." }
$newVersion = node -p "require('./package.json').version"
Write-Host ""
Write-Host " ╔══════════════════════════════════════╗" -ForegroundColor DarkGreen
Write-Host " ║ Release v$newVersion complete!$(if($newVersion.Length -lt 6){' '}elseif($newVersion.Length -lt 7){' '}else{' '})" -ForegroundColor Green
Write-Host " ╚══════════════════════════════════════╝" -ForegroundColor DarkGreen
Write-Host ""
Write-Host " GitHub Actions is now building and publishing the release." -ForegroundColor Gray
Write-Host " Track: https://github.com/JamesCliffordSpratt/macros/actions" -ForegroundColor DarkGray
Write-Host ""
Read-Host " Press Enter to close"