deploy-to-phone.sh 1.2 KB
#!/bin/bash
# deploy-to-phone.sh — 把 wechat 服务代码推送到 Pixel 手机
#
# 用法:
#   ./deploy-to-phone.sh [手机目标目录]
#   默认目标: /data/data/com.termux/files/home/hermes-wechat/

set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PHONE_DIR="${1:-/data/data/com.termux/files/home/hermes-wechat}"

echo "=== Deploying wechat services to phone ==="
echo "Source: $SCRIPT_DIR"
echo "Target: $PHONE_DIR"
echo ""

# 确保手机目录存在
adb shell "su -c 'mkdir -p $PHONE_DIR'"

# 推送所有 js 文件和 SKILL.md
for f in \
  android-wechat-sender.js \
  android-wechat-tracker.js \
  wechat-sender.js \
  wechat-tracker.js \
  wechat-reader.js \
  wechat-importer.js \
  index.js \
  test-phone.js \
  SKILL.md
do
  if [ -f "$SCRIPT_DIR/$f" ]; then
    echo "Pushing $f ..."
    adb push "$SCRIPT_DIR/$f" "$PHONE_DIR/$f" >/dev/null
  fi
done

echo ""
echo "=== Deploy complete ==="
echo "Files in $PHONE_DIR:"
adb shell "su -c 'ls -la $PHONE_DIR'"
echo ""
echo "Quick test:"
echo "  adb shell \"su -c 'cd $PHONE_DIR && node -e \\\\\"
const {sendTextMessageBroadcast} = require('./android-wechat-sender');
sendTextMessageBroadcast('filehelper', 'hermes phone test').then(r=>console.log(r));
\\\\\"'\""