AetheriaLore/scripts/quartz/quartz.ps1
Meta Vens 5f459932de Prefer real note slugs; update docs and PS1
Return a real note's slug when present (instead of a synthetic folder `index` slug) in FileTrie.slug and add a unit test to assert that behavior. Expand README with a repository map, local development quick start, build/test instructions, where-to-edit guidance, and troubleshooting notes. Update the Windows helper script (scripts/quartz/quartz.ps1) to prefer the bundled portable Node/npm runtime when available and pin npm's cache to .npm-cache inside the repo for reproducible local runs.
2026-04-20 00:24:22 +01:00

41 lines
1.2 KiB
PowerShell

param(
[ValidateSet("build", "dev")]
[string]$Command = "dev"
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
$quartzRoot = Join-Path $repoRoot "quartz-site"
$portableNodeRoot = Join-Path $repoRoot ".tools\node-v24.15.0-win-x64"
$portableNpm = Join-Path $portableNodeRoot "npm.cmd"
# Prefer the bundled Windows runtime so new contributors can run the site
# without installing Node first. If it is missing, fall back to the user's npm.
if (Test-Path $portableNpm) {
$npm = $portableNpm
$env:PATH = "$portableNodeRoot;$env:PATH"
} else {
$npmCommand = Get-Command npm -ErrorAction SilentlyContinue
if (-not $npmCommand) {
throw "npm was not found. Install Node.js or restore the portable runtime under .tools."
}
$npm = $npmCommand.Source
}
# Keep npm's cache inside the repo so local runs do not depend on a global cache
# and stay reproducible across machines and shells.
$env:npm_config_cache = Join-Path $repoRoot ".npm-cache"
$scriptArgs = switch ($Command) {
"build" { @("run", "build") }
"dev" { @("run", "dev") }
}
Push-Location $quartzRoot
try {
& $npm @scriptArgs
} finally {
Pop-Location
}