feat(deploy): update 前檢查 jsc requires 相依版本

This commit is contained in:
2026-08-28 11:59:16 +08:00
parent a89484c9fa
commit 4aa691a9cb
4 changed files with 150 additions and 5 deletions
+28 -3
View File
@@ -11,6 +11,7 @@
# skip<TAB>{domain}<TAB>{原因} 本地 clone 是開發中的樹,略過 git pull
# note<TAB>{cli}<TAB>{原因} 非逐指令的說明(例:kiro 整批改走複製退路的理由)
# restart<TAB>{路徑} 這次寫下的重啟狀態檔
# requires<TAB>{domain}<TAB>{檢查結果} update 前的 jsc.requires 檢查
# result<TAB>{cli}<TAB>{mode}<TAB>{domain 清單}<TAB>{ok|fail}
# 結束碼:全部指令成功 0;任一指令失敗 1;參數錯誤 2。skip、note 不算失敗,但呼叫端要據實回報。
# marketplace 指令一輪只跑一次:install 與 update 先跑,uninstall 最後跑。
@@ -36,6 +37,8 @@
# JSC_DEPLOY_DRYRUN 設為 1 等同 -n
set -u
HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
# Gitea 站台一律讀 GITEA_HOST(技能準則指定的變數),未設定才用正本站台。
HOST="${GITEA_HOST:-https://gitea.jsc.idv.tw}"
case "$HOST" in http://*|https://*) ;; *) HOST="https://$HOST" ;; esac
@@ -89,6 +92,25 @@ restart_gate_sh() {
return 1
}
check_requires() { # $1=domain;0=可更新,1=略過這個 domain
[ "$MODE" = update ] || return 0
sync_local "$1"
manifest="$LOCAL_DIR/$1/plugin.json"
out=$(sh "$HERE/check-requires.sh" "$CLI" "$manifest" 2>&1)
code=$?
printf 'requires\t%s\t%s\n' "$1" "$out"
if [ "$code" -eq 0 ]; then
return 0
fi
if [ "$code" -eq 1 ]; then
printf 'skip\t%s\t%s\n' "$1" "相依版本不符,未更新:$out"
return 1
fi
FAILED=1
printf 'skip\t%s\t%s\n' "$1" "相依版本檢查失敗,未更新:$out"
return 1
}
# 掛上部署後的重啟閘門。狀態檔的路徑、格式與判讀全在 jsc-hooks 的 restart-gate.sh,
# 這裡只轉呼叫它的 require 子命令,比照 jsc-sdlc 轉呼叫 sdlc-gate.sh wp-lock 的慣例。
# 兩邊各拼一份格式就會對不上:2026-08-27 這裡曾自己寫四欄 TSV,而 hooks 那端讀的是
@@ -175,7 +197,7 @@ marketplace_cli() { # $1=執行檔
;;
update)
run "$1" plugin marketplace update jsc
for d in $DOMAINS; do run "$1" plugin update "jsc-$d@jsc"; done
for d in $DOMAINS; do check_requires "$d" && run "$1" plugin update "jsc-$d@jsc"; done
;;
uninstall)
for d in $DOMAINS; do run "$1" plugin uninstall "jsc-$d@jsc"; done
@@ -199,7 +221,7 @@ deploy_codex() {
;;
update)
run "$bin" plugin marketplace upgrade jsc
for d in $DOMAINS; do run "$bin" plugin add "jsc-$d@jsc"; done
for d in $DOMAINS; do check_requires "$d" && run "$bin" plugin add "jsc-$d@jsc"; done
;;
uninstall)
for d in $DOMAINS; do run "$bin" plugin remove "jsc-$d@jsc"; done
@@ -217,6 +239,7 @@ deploy_antigravity() {
run "$bin" plugin install "$LOCAL_DIR/$d"
;;
update)
check_requires "$d" || continue
sync_local "$d"
run "$bin" plugin uninstall "jsc-$d"
run "$bin" plugin install "$LOCAL_DIR/$d"
@@ -278,6 +301,7 @@ deploy_kiro() {
run_soft "$bin" plugin install "jsc-$d@jsc" || kiro_copy "$d"
;;
update)
check_requires "$d" || continue
run_soft "$bin" plugin update "jsc-$d@jsc" || kiro_copy "$d"
;;
uninstall)
@@ -291,7 +315,8 @@ deploy_kiro() {
printf 'note\tkiro\t%s\n' "此版本 kiro-cli 沒有 plugin 子指令,改走本地複製(git pull 或 clone 後,複製 skills、tools、references、templates、hooks 與 plugin.json)"
for d in $DOMAINS; do
case "$MODE" in
install|update) kiro_copy "$d" ;;
install) kiro_copy "$d" ;;
update) check_requires "$d" && kiro_copy "$d" ;;
uninstall) run rm -rf "$KIRO_SKILLS/jsc-$d" ;;
esac
done