All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m17s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 4s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
- Split `verifyAddinTicket` into two functions: `verifyAddinTicketHmac` (ignores expiration) and `verifyAddinTicket` (checks expiration). - Add `hasVersionByUser` function to check if a document has been previously worked on by a user, allowing expired tickets to be accepted if the user has a history with the document. - Update OpenAPI specification to reflect changes in ticket expiration handling. - Introduce new scripts for installing and uninstalling the Word add-in on Windows and macOS, providing a streamlined process for sideloading the add-in. - Enhance tests for ticket verification to cover new functionality regarding expired tickets and user history.
95 lines
4 KiB
Bash
Executable file
95 lines
4 KiB
Bash
Executable file
#!/bin/bash
|
|
# ติดตั้ง (sideload) / ถอด Word add-in "e-Court Documents Versioning" บน macOS
|
|
# เวอร์ชัน shell แบบส่งให้เครื่องทดสอบที่ไม่มี Node/repo — คู่หูของ
|
|
# scripts/install-wordaddin.mjs (รันใน repo) และ scripts/install-wordaddin.ps1 (Windows)
|
|
# กลไกเดียวกันทั้งสามไฟล์: โหลด manifest จาก server แล้ววางเป็น <GUID>.manifest.xml
|
|
# ใน ~/Library/Containers/com.microsoft.Word/Data/Documents/wef/ ของ Word
|
|
#
|
|
# ใช้: ./install-wordaddin.sh [--url <manifest-url>] [--remove]
|
|
# --url default https://ecourt-note.chamomind.com/docedit/wordaddin/manifest.xml
|
|
# --remove ถอดการติดตั้ง
|
|
# --help | -h
|
|
#
|
|
# หลังลง/ถอดต้อง restart Word ทุกครั้ง · รายละเอียดเต็ม: docs/WORDADDIN-DEV.md
|
|
|
|
set -euo pipefail
|
|
|
|
PREFIX="[install-addin]"
|
|
DEFAULT_URL="https://ecourt-note.chamomind.com/docedit/wordaddin/manifest.xml"
|
|
WEF_DIR="$HOME/Library/Containers/com.microsoft.Word/Data/Documents/wef"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
ใช้: ./install-wordaddin.sh [options]
|
|
--url <manifest-url> default ${DEFAULT_URL}
|
|
--remove ถอดการติดตั้ง
|
|
--help | -h
|
|
EOF
|
|
exit "${1:-1}"
|
|
}
|
|
|
|
fail() {
|
|
echo "${PREFIX} ✗ $1" >&2
|
|
exit 1
|
|
}
|
|
|
|
URL="$DEFAULT_URL"
|
|
REMOVE=0
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--url) [ $# -ge 2 ] || usage; URL="$2"; shift 2 ;;
|
|
--remove) REMOVE=1; shift ;;
|
|
--help | -h) usage 0 ;;
|
|
*) usage 1 ;;
|
|
esac
|
|
done
|
|
|
|
[ "$(uname)" = "Darwin" ] || fail "สคริปต์นี้สำหรับ macOS — Windows ใช้ install-wordaddin.ps1"
|
|
|
|
next_steps() {
|
|
cat <<EOF
|
|
|
|
ขั้นต่อไป:
|
|
1. restart Word ให้ครบทุกหน้าต่าง (จำเป็นทุกครั้งหลังลง/ถอด)
|
|
2. Insert > My Add-ins > เปิด "e-Court Documents Versioning"
|
|
3. เปิดไฟล์ .docx ที่มี ticket ของ e-Court (ขอจากทีม) เพื่อเริ่มทดสอบ
|
|
EOF
|
|
}
|
|
|
|
if [ "$REMOVE" = "1" ]; then
|
|
echo "${PREFIX} platform: $(uname) · โหมดถอดการติดตั้ง"
|
|
found=0
|
|
# บน Mac ไม่มี manifest เก็บแยกที่อื่น — หาทุก *.xml ใน wef ที่เป็นของ add-in
|
|
# นี้จากชื่อในไฟล์เอง จึงไม่ต้อง hardcode GUID
|
|
for file in "$WEF_DIR"/*.xml; do
|
|
[ -f "$file" ] || continue
|
|
if grep -q "e-Court Documents Versioning" "$file" && grep -q "<OfficeApp" "$file"; then
|
|
rm -f "$file"
|
|
echo "${PREFIX} ✓ ลบ $file"
|
|
found=1
|
|
fi
|
|
done
|
|
if [ "$found" = "0" ]; then
|
|
echo "${PREFIX} ไม่พบไฟล์ sideload ของ add-in นี้ใน $WEF_DIR — ถือว่าถอดแล้ว"
|
|
fi
|
|
echo "${PREFIX} ✓ เสร็จ"
|
|
next_steps
|
|
exit 0
|
|
fi
|
|
|
|
echo "${PREFIX} platform: $(uname)"
|
|
|
|
TMP="$(mktemp)"
|
|
trap 'rm -f "$TMP"' EXIT
|
|
curl -fsSL --max-time 30 "$URL" -o "$TMP" || fail "โหลด manifest จาก $URL ไม่ได้ — เช็คเน็ต และว่า environment นั้นรันอยู่"
|
|
grep -q "<OfficeApp" "$TMP" || fail "response จาก $URL ไม่ใช่ manifest ของ Office add-in"
|
|
GUID="$(sed -nE 's/.*<Id>([0-9a-fA-F-]{36})<\/Id>.*/\1/p' "$TMP" | head -n 1 | tr '[:upper:]' '[:lower:]')"
|
|
[ -n "$GUID" ] || fail "หา <Id> (GUID) ใน manifest ไม่เจอจาก $URL"
|
|
|
|
mkdir -p "$WEF_DIR"
|
|
rm -f "$WEF_DIR/$GUID".* # ลบของรอบก่อน — idempotent ไม่มีไฟล์ GUID เดียวค้างสองชื่อ
|
|
DEST="$WEF_DIR/$GUID.manifest.xml"
|
|
cp "$TMP" "$DEST"
|
|
echo "${PREFIX} ✓ วาง manifest ไว้ที่ $DEST"
|
|
echo "${PREFIX} ✓ เสร็จ"
|
|
next_steps
|