From 96562ac51007bf7fba772e5f4ba3dbafccf5fef1 Mon Sep 17 00:00:00 2001 From: discountry Date: Wed, 24 Sep 2025 22:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E9=94=AE=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A3=80=E6=B5=8B=E9=A1=B9=E7=9B=AE=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=B9=B6=E4=BB=8E=20Git=20=E6=88=96=20tarball=20=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=BA=90=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AE=89=E8=A3=85=E6=B5=81=E7=A8=8B=E3=80=82?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E6=9B=B4=E6=96=B0=20README.md=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E5=8A=A8=E5=AE=89=E8=A3=85=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++++----- setup.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8b8d4a9..b50de34 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,25 @@ 遇到Bug,返回问题,请到 [Telegram群组](https://t.me/+4fdo0quY87o4Mjhh) +### 一键脚本 + 一键安装并启动(macOS / Linux): ```bash -chmod +x ./setup.sh && ./setup.sh +curl -fsSL https://github.com/discountry/ritmex-bot/raw/refs/heads/main/setup.sh | bash ``` 脚本会自动安装 Bun、安装依赖、引导输入 API Key/Secret,生成 `.env` 并启动程序。 Windows 使用 WSL(推荐): 1. 先安装并启用 WSL,参考微软官方文档:[在 Windows 上安装 WSL](https://learn.microsoft.com/zh-cn/windows/wsl/install) -2. 在 Microsoft Store 安装 Ubuntu(或其他 Linux 发行版),打开 “Ubuntu” 终端。 +2. 在命令行或者 PowerShell 输入 `wsl` 并按下回车打开 WSL。 3. 在 WSL 中运行一键脚本: ```bash - git clone https://github.com/discountry/ritmex-bot.git - cd ritmex-bot - chmod +x ./setup.sh && ./setup.sh + curl -fsSL https://github.com/discountry/ritmex-bot/raw/refs/heads/main/setup.sh | bash ``` 按提示输入 ASTER_API_KEY / ASTER_API_SECRET,脚本将自动安装 Bun、依赖并启动程序。 +## 手动安装 + 1. **下载代码** - 如果会使用 Git:`git clone https://github.com/discountry/ritmex-bot.git` - 如果不会使用 Git:点击仓库页面的 `Code` → `Download ZIP`,将压缩包解压到如 `桌面/ritmex-bot` 的目录。 diff --git a/setup.sh b/setup.sh index 49bd73a..4fd6638 100644 --- a/setup.sh +++ b/setup.sh @@ -11,6 +11,8 @@ set -euo pipefail main() { require_unix + ensure_repo + cd "$PROJECT_DIR" ensure_bun install_deps prompt_env @@ -52,6 +54,37 @@ ensure_bun() { echo "✔ Bun installed: $(bun --version)" } +ensure_repo() { + # Detect if running inside project root already + if [ -f "package.json" ] && grep -q '"name"\s*:\s*"ritmex-bot"' package.json 2>/dev/null; then + PROJECT_DIR="$PWD" + echo "✔ Project detected in current directory: $PROJECT_DIR" + return + fi + + local REPO_URL="https://github.com/discountry/ritmex-bot.git" + local TAR_URL="https://github.com/discountry/ritmex-bot/archive/refs/heads/main.tar.gz" + local TARGET_DIR="${RITMEX_DIR:-ritmex-bot}" + + if [ -d "$TARGET_DIR" ] && [ -f "$TARGET_DIR/package.json" ]; then + PROJECT_DIR="$TARGET_DIR" + echo "✔ Project directory found: $PROJECT_DIR" + return + fi + + echo "Fetching ritmex-bot sources..." + if command -v git >/dev/null 2>&1; then + git clone --depth=1 "$REPO_URL" "$TARGET_DIR" + else + echo "ℹ git not found; downloading tarball..." + curl -fsSL "$TAR_URL" -o /tmp/ritmex-bot.tar.gz + mkdir -p "$TARGET_DIR" + tar -xzf /tmp/ritmex-bot.tar.gz --strip-components=1 -C "$TARGET_DIR" + rm -f /tmp/ritmex-bot.tar.gz + fi + PROJECT_DIR="$TARGET_DIR" +} + install_deps() { echo "Installing dependencies with Bun..." bun install