build: add scripts/build-zip.sh to package plugin as a Decky-installable ZIP

The ZIP bundles plugin.json, main.py, package.json, dist/index.js (+ map) at
the archive root (no enclosing folder) — the format Decky's 'Install Plugin
from ZIP File' / 'Install Plugin from URL' expects.

Usage:
  bun run build:zip   # build + package → releases/plugin-v<version>.zip
  bun run zip         # package already-built dist only
This commit is contained in:
2026-06-28 22:42:13 +08:00
parent 3ed0ee3128
commit 383945ca14
3 changed files with 51 additions and 1 deletions
+3
View File
@@ -50,3 +50,6 @@ yarn-error.log*
# stray # stray
post.md post.md
plugins/decky-vault/dist/ plugins/decky-vault/dist/
# Decky plugin release zips
plugins/decky-vault/releases/
+3 -1
View File
@@ -5,7 +5,9 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
"watch": "rollup -c -w" "watch": "rollup -c -w",
"build:zip": "rollup -c && ./scripts/build-zip.sh --no-build",
"zip": "./scripts/build-zip.sh"
}, },
"dependencies": { "dependencies": {
"@decky/api": "^1.1.3", "@decky/api": "^1.1.3",
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# Build a Decky Loader plugin ZIP ready for "Install Plugin from ZIP File".
#
# The ZIP must contain the plugin files at the ROOT (no enclosing folder):
# plugin.json, main.py, package.json, dist/index.js [, dist/index.js.map]
#
# Usage:
# ./scripts/build-zip.sh # builds + packages, output in releases/
# ./scripts/build-zip.sh --no-build # package only (skip rollup build)
set -euo pipefail
cd "$(dirname "$0")/.."
VERSION=$(node -p "require('./package.json').version")
NAME=$(node -p "require('./package.json').name")
# Strip any @scope/ prefix for the zip filename
ZIP_NAME=$(echo "$NAME" | sed 's#.*/##')
OUT_DIR="releases"
ZIP_PATH="$OUT_DIR/${ZIP_NAME}-v${VERSION}.zip"
if [[ "${1:-}" != "--no-build" ]]; then
echo " Building plugin with rollup…"
bun run build
fi
echo " Packaging $ZIP_PATH"
rm -rf "$OUT_DIR"
mkdir -p "$OUT_DIR"
# Create the zip with files at the root. We cd into the plugin dir so paths
# are relative (no enclosing folder in the archive).
zip -r -X "$PWD/$ZIP_PATH" \
plugin.json \
main.py \
package.json \
dist/index.js \
dist/index.js.map \
>/dev/null
echo "✓ Built $ZIP_PATH ($(du -h "$ZIP_PATH" | cut -f1))"
echo
echo "Install options:"
echo " • Decky → Plugin Browser → ⋮ → Install Plugin from ZIP File → pick $ZIP_PATH"
echo " • Or host $ZIP_PATH anywhere and use 'Install Plugin from URL'"