Ship unsigned MCPB packages built from the ArtCraft Launcher CLIs, with install docs and skill 0.2.0 updates.
99 lines
2.9 KiB
Bash
99 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
# 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 via ArtCraft Launcher.
|
|
# Usage: scripts/fetch-cli.sh <skill-name> [cli-path]
|
|
set -euo pipefail
|
|
source "$(dirname "$0")/lib.sh"
|
|
|
|
name="${1:-}"
|
|
cli_path="${2:-}"
|
|
if [[ -z "$name" ]]; then
|
|
echo "Aufruf: scripts/fetch-cli.sh <skill-name> [cli-path]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
ext="$SKILLS_DIR/$name/extension"
|
|
if [[ ! -f "$ext/manifest.json" ]]; then
|
|
echo "skills/$name/extension/manifest.json fehlt." >&2
|
|
exit 1
|
|
fi
|
|
|
|
case "$name" in
|
|
wordcraft-mcp)
|
|
exe_name=wordcraft-cli.exe
|
|
default='/mnt/c/Program Files/WordCraft/wordcraft-cli.exe'
|
|
[[ -f "$default" ]] || default='C:/Program Files/WordCraft/wordcraft-cli.exe'
|
|
repo='https://github.com/storytold/wordcraft'
|
|
repo_slug='storytold/wordcraft'
|
|
;;
|
|
gridcraft-mcp)
|
|
exe_name=gridcraft-cli.exe
|
|
default='/mnt/c/Program Files/GridCraft/gridcraft-cli.exe'
|
|
[[ -f "$default" ]] || default='C:/Program Files/GridCraft/gridcraft-cli.exe'
|
|
repo='https://github.com/storytold/gridcraft'
|
|
repo_slug='storytold/gridcraft'
|
|
;;
|
|
*)
|
|
echo "Kein CLI-Mapping fuer Skill '$name'." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
src="${cli_path:-$default}"
|
|
if [[ ! -f "$src" ]]; then
|
|
echo "CLI fehlt: $src" >&2
|
|
echo "Bitte WordCraft/GridCraft ueber den ArtCraft-Launcher installieren, oder Pfad als Argument angeben." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$ext/server"
|
|
dest="$ext/server/$exe_name"
|
|
cp -f "$src" "$dest"
|
|
chmod +x "$dest" 2>/dev/null || true
|
|
|
|
ver_out="$("$dest" --version 2>&1 || true)"
|
|
if [[ ! "$ver_out" =~ [0-9]+\.[0-9]+\.[0-9]+ ]] && [[ "$name" == gridcraft-mcp ]]; then
|
|
ver_out="$("$dest" version 2>&1 || true)"
|
|
fi
|
|
if [[ ! "$ver_out" =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
|
echo "Version der CLI nicht lesbar: $ver_out" >&2
|
|
exit 1
|
|
fi
|
|
ver="${BASH_REMATCH[1]}"
|
|
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
hash="$(sha256sum "$dest" | awk '{print $1}')"
|
|
elif command -v shasum >/dev/null 2>&1; then
|
|
hash="$(shasum -a 256 "$dest" | awk '{print $1}')"
|
|
else
|
|
hash="$(python3 -c "import hashlib,sys; print(hashlib.sha256(open(sys.argv[1],'rb').read()).hexdigest())" "$dest")"
|
|
fi
|
|
|
|
python3 -c "
|
|
import json, sys
|
|
print(json.dumps({
|
|
'source': 'ArtCraft-Launcher',
|
|
'path': sys.argv[1],
|
|
'exe': sys.argv[2],
|
|
'version': sys.argv[3],
|
|
'sha256': sys.argv[4],
|
|
'repository': sys.argv[5],
|
|
'tag': 'v' + sys.argv[3],
|
|
}, separators=(',', ':')))
|
|
" "$src" "$exe_name" "$ver" "$hash" "$repo" > "$ext/upstream.json"
|
|
printf '\n' >> "$ext/upstream.json" || true
|
|
|
|
mkdir -p "$ext/LICENSES"
|
|
tag="v$ver"
|
|
for f in LICENSE-MIT LICENSE-APACHE NOTICE; do
|
|
url="https://raw.githubusercontent.com/$repo_slug/$tag/$f"
|
|
if ! curl -fsSL "$url" -o "$ext/LICENSES/$f"; then
|
|
echo "Lizenzdatei fehlgeschlagen: $url" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo "OK $name $ver $hash"
|
|
echo " $dest"
|