Ship unsigned MCPB packages built from the ArtCraft Launcher CLIs, with install docs and skill 0.2.0 updates.
91 lines
2.9 KiB
PowerShell
91 lines
2.9 KiB
PowerShell
# Copies the ArtCraft-Launcher CLI into skills\<name>\extension\server\
|
|
# and writes upstream.json plus LICENSES from the matching upstream tag.
|
|
# No GitHub binary download. Requires WordCraft/GridCraft installed via ArtCraft Launcher.
|
|
# Usage: scripts\fetch-cli.ps1 -Name <skill-name> [-CliPath <path>]
|
|
param(
|
|
[Parameter(Mandatory = $true)][string]$Name,
|
|
[string]$CliPath
|
|
)
|
|
. (Join-Path $PSScriptRoot 'lib.ps1')
|
|
|
|
$dir = Join-Path $SkillsDir $Name
|
|
$ext = Join-Path $dir 'extension'
|
|
if (-not (Test-Path (Join-Path $ext 'manifest.json'))) {
|
|
Write-Host "skills/$Name/extension/manifest.json fehlt."
|
|
exit 1
|
|
}
|
|
|
|
$defaults = @{
|
|
'wordcraft-mcp' = @{
|
|
ExeName = 'wordcraft-cli.exe'
|
|
Default = 'C:\Program Files\WordCraft\wordcraft-cli.exe'
|
|
Repo = 'https://github.com/storytold/wordcraft'
|
|
RepoSlug = 'storytold/wordcraft'
|
|
}
|
|
'gridcraft-mcp' = @{
|
|
ExeName = 'gridcraft-cli.exe'
|
|
Default = 'C:\Program Files\GridCraft\gridcraft-cli.exe'
|
|
Repo = 'https://github.com/storytold/gridcraft'
|
|
RepoSlug = 'storytold/gridcraft'
|
|
}
|
|
}
|
|
|
|
if (-not $defaults.ContainsKey($Name)) {
|
|
Write-Host "Kein CLI-Mapping fuer Skill '$Name'."
|
|
exit 1
|
|
}
|
|
$meta = $defaults[$Name]
|
|
$src = if ($CliPath) { $CliPath } else { $meta.Default }
|
|
if (-not (Test-Path -LiteralPath $src)) {
|
|
Write-Host "CLI fehlt: $src"
|
|
Write-Host "Bitte WordCraft/GridCraft ueber den ArtCraft-Launcher installieren, oder -CliPath angeben."
|
|
exit 1
|
|
}
|
|
|
|
$serverDir = Join-Path $ext 'server'
|
|
New-Item -ItemType Directory -Force -Path $serverDir | Out-Null
|
|
$dest = Join-Path $serverDir $meta.ExeName
|
|
Copy-Item -LiteralPath $src -Destination $dest -Force
|
|
|
|
$verOut = & $dest --version 2>&1 | Out-String
|
|
if ($LASTEXITCODE -ne 0 -and $Name -eq 'gridcraft-mcp') {
|
|
$verOut = & $dest version 2>&1 | Out-String
|
|
}
|
|
$ver = ''
|
|
if ($verOut -match '(\d+\.\d+\.\d+)') { $ver = $Matches[1] }
|
|
if (-not $ver) {
|
|
Write-Host "Version der CLI nicht lesbar: $verOut"
|
|
exit 1
|
|
}
|
|
|
|
$hash = (Get-FileHash -LiteralPath $dest -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
$upstream = @{
|
|
source = 'ArtCraft-Launcher'
|
|
path = $src
|
|
exe = $meta.ExeName
|
|
version = $ver
|
|
sha256 = $hash
|
|
repository = $meta.Repo
|
|
tag = "v$ver"
|
|
} | ConvertTo-Json -Compress
|
|
Write-Text (Join-Path $ext 'upstream.json') ($upstream + "`n")
|
|
|
|
$licDir = Join-Path $ext 'LICENSES'
|
|
New-Item -ItemType Directory -Force -Path $licDir | Out-Null
|
|
$tag = "v$ver"
|
|
foreach ($f in @('LICENSE-MIT', 'LICENSE-APACHE', 'NOTICE')) {
|
|
$url = "https://raw.githubusercontent.com/$($meta.RepoSlug)/$tag/$f"
|
|
$out = Join-Path $licDir $f
|
|
try {
|
|
Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing
|
|
}
|
|
catch {
|
|
Write-Host "Lizenzdatei fehlgeschlagen: $url"
|
|
Write-Host $_
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Write-Host "OK $Name $ver $hash"
|
|
Write-Host " $dest"
|