build-mac.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. cd "$(dirname "$0")/.."
  4. if [ "$(uname -s)" != "Darwin" ]; then
  5. echo "此脚本需要在 macOS 上运行(electron-builder 不支持从 Windows/Linux 构建 macOS 包)。"
  6. exit 1
  7. fi
  8. if ! command -v node >/dev/null 2>&1; then
  9. echo "未找到 node。请先安装 Node.js 20+:https://nodejs.org/"
  10. exit 1
  11. fi
  12. if ! command -v npm >/dev/null 2>&1; then
  13. echo "未找到 npm。请先安装 Node.js 20+。"
  14. exit 1
  15. fi
  16. echo "==> 安装依赖"
  17. if [ -f package-lock.json ]; then
  18. npm ci
  19. else
  20. npm install
  21. fi
  22. if [ -f resources/bin/luatos-cli ]; then
  23. echo "==> 使用已内置的 luatos-cli(macOS universal)"
  24. else
  25. echo "==> 下载 luatos-cli(macOS universal)"
  26. npm run fetch:cli
  27. fi
  28. echo "==> 构建 .app / .dmg(unsigned)"
  29. npm run dist:mac
  30. echo
  31. echo "完成。产物在 dist/ 目录:"
  32. ls -lh dist/*.dmg dist/*.zip 2>/dev/null || true
  33. echo
  34. echo "如果 macOS 提示“无法验证开发者”,可以右键 App -> 打开,或执行:"
  35. echo ' xattr -cr "/Applications/LuatOS Flasher.app"'