mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 05:01:05 -04:00
Help > OpenNest Help (F1) and context F1 in Auto Nest and the CAD Converter open the bundled opennest-help site in a single WebView2 window on its own UI thread. Both packaging scripts install the opennest-help release pinned in scripts/help.json, verified by SHA-256. The missing lead-in finding now says the contour is missing lead-in geometry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.8 KiB
PowerShell
42 lines
1.8 KiB
PowerShell
<#
|
|
Put the OpenNest help site into a package's Help folder.
|
|
|
|
By default this downloads the opennest-help release pinned in scripts/help.json and
|
|
refuses it unless its SHA-256 matches. Pass -HelpDirectory to use a locally built
|
|
site/ folder instead (e.g. while writing new help pages). Returns a short
|
|
description of the help version for build-info.json.
|
|
|
|
Example:
|
|
./scripts/Install-Help.ps1 -Destination artifacts/OpenNest/Help
|
|
./scripts/Install-Help.ps1 -Destination bin/publish/Help -HelpDirectory ../opennest-help/site
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory)] [string] $Destination,
|
|
[string] $HelpDirectory
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-StrictMode -Version Latest
|
|
|
|
if (Test-Path $Destination) { throw "Refusing to overwrite existing help folder: $Destination" }
|
|
|
|
if ($HelpDirectory) {
|
|
if (-not (Test-Path (Join-Path $HelpDirectory 'index.html'))) { throw "No help site in $HelpDirectory (index.html missing)." }
|
|
New-Item -ItemType Directory -Path $Destination | Out-Null
|
|
Copy-Item (Join-Path $HelpDirectory '*') $Destination -Recurse
|
|
return "local:$([IO.Path]::GetFullPath($HelpDirectory))"
|
|
}
|
|
|
|
$pin = Get-Content (Join-Path $PSScriptRoot 'help.json') -Raw | ConvertFrom-Json
|
|
$version = "$($pin.repository)@$($pin.tag)"
|
|
$zip = Join-Path ([IO.Path]::GetTempPath()) "opennest-help-$([guid]::NewGuid().ToString('N')).zip"
|
|
try {
|
|
Invoke-WebRequest "https://github.com/$($pin.repository)/releases/download/$($pin.tag)/opennest-help.zip" -OutFile $zip -UseBasicParsing
|
|
$hash = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
if ($hash -ne $pin.sha256) { throw "Help $version hash $hash does not match scripts/help.json." }
|
|
Expand-Archive -Path $zip -DestinationPath $Destination
|
|
}
|
|
finally { Remove-Item $zip -ErrorAction SilentlyContinue }
|
|
return $version
|