#!/usr/bin/env sh
|
set -eu
|
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
PLUGIN_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
DIST_DIR=${ONLYOFFICE_PLUGIN_DIST_DIR:-"$PLUGIN_DIR/dist"}
|
PACKAGE="$DIST_DIR/dms-qianpiye-annotator.plugin"
|
TEMP_PACKAGE="$DIST_DIR/.dms-qianpiye-annotator.$$.plugin"
|
|
cleanup() {
|
rm -f "$TEMP_PACKAGE"
|
}
|
trap cleanup EXIT HUP INT TERM
|
|
command -v node >/dev/null 2>&1 || { printf '%s\n' 'node is required to package the plugin' >&2; exit 1; }
|
command -v zip >/dev/null 2>&1 || { printf '%s\n' 'zip is required to package the plugin' >&2; exit 1; }
|
command -v unzip >/dev/null 2>&1 || { printf '%s\n' 'unzip is required to verify the plugin' >&2; exit 1; }
|
|
test -f "$DIST_DIR/config.json"
|
test -f "$DIST_DIR/index.html"
|
test -f "$DIST_DIR/resources/icon.png"
|
test -f "$DIST_DIR/resources/icon@2x.png"
|
node -e 'const c = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8")); if (c.version !== "0.1.0" || c.guid !== "asc.{C764F7D6-055D-4C7D-97FD-83D2C4440585}" || c.variations?.[0]?.url !== "index.html") process.exit(1)' "$DIST_DIR/config.json"
|
|
cd "$DIST_DIR"
|
zip -qr "$TEMP_PACKAGE" config.json index.html assets resources
|
unzip -tq "$TEMP_PACKAGE" >/dev/null
|
mv -f "$TEMP_PACKAGE" "$PACKAGE"
|
printf '%s\n' "$PACKAGE"
|