feat: add deploy scripts for Windows and Linux installation, remove copy-deploy-cli script

This commit is contained in:
Soulter
2026-04-28 15:05:35 +08:00
parent 9016a3b2c4
commit 4d9340c216
5 changed files with 1 additions and 27 deletions

4
docs/.gitignore vendored
View File

@@ -4,7 +4,3 @@ venv/
node_modules/
.vitepress/cache
*dist
scripts/deploy-cli.sh
scripts/deploy-cli.ps1
public/scripts/deploy-cli.sh
public/scripts/deploy-cli.ps1

View File

@@ -1,7 +1,7 @@
{
"scripts": {
"docs:dev": "vitepress dev --host",
"docs:build": "node scripts/copy-deploy-cli.mjs && vitepress build",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
},
"devDependencies": {

86
docs/public/install.ps1 Normal file
View File

@@ -0,0 +1,86 @@
# deploy-cli.ps1 - Install astrbot with uv on Windows PowerShell.
#Requires -Version 7.0
$ErrorActionPreference = 'Stop'
$UseColor = [string]::IsNullOrEmpty($env:NO_COLOR) -and [Console]::IsOutputRedirected -eq $false
function Write-Status {
param(
[string]$Prefix,
[string]$Message,
[string]$Color
)
if ($UseColor) {
Write-Host "$Prefix $Message" -ForegroundColor $Color
} else {
Write-Host "$Prefix $Message"
}
}
function Info { Write-Status "[INFO]" "$args" "Cyan" }
function Warn { Write-Status "[WARN]" "$args" "Yellow" }
function Ok { Write-Status "[OK]" "$args" "Green" }
function Err { Write-Status "[ERROR]" "$args" "Red" }
function Test-Command {
param([string]$Name)
$null = Get-Command $Name -ErrorAction SilentlyContinue
return $?
}
function Update-UvPath {
$candidateDirs = @()
if ($HOME) {
$candidateDirs += Join-Path $HOME ".local\bin"
}
if ($env:USERPROFILE) {
$candidateDirs += Join-Path $env:USERPROFILE ".local\bin"
}
if ($env:LOCALAPPDATA) {
$candidateDirs += Join-Path $env:LOCALAPPDATA "uv"
}
foreach ($dir in $candidateDirs) {
if ((Test-Path $dir) -and (($env:PATH -split ';') -notcontains $dir)) {
$env:PATH = "$dir;$env:PATH"
}
}
}
function Install-Uv {
Info "uv was not found. Installing uv..."
$tempScript = [System.IO.Path]::GetTempFileName() + ".ps1"
try {
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1" -OutFile $tempScript -UseBasicParsing
& $tempScript
Update-UvPath
} catch {
Err "Failed to install uv."
Err "Please install uv manually: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
} finally {
Remove-Item $tempScript -ErrorAction SilentlyContinue
}
}
if (-not (Test-Command "uv")) {
Install-Uv
}
Update-UvPath
if (-not (Test-Command "uv")) {
Err "uv was not found after installation."
Err "Please install uv manually: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
}
Ok (& uv --version)
Info "Installing AstrBot with Python 3.12..."
uv tool install --python 3.12 astrbot
Ok "AstrBot has been installed."

68
docs/public/install.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# deploy-cli.sh - Install astrbot with uv on Linux / macOS / WSL.
set -euo pipefail
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
else
RED=''
GREEN=''
YELLOW=''
CYAN=''
NC=''
fi
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
has() {
command -v "$1" >/dev/null 2>&1
}
refresh_uv_path() {
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
}
install_uv() {
info "uv was not found. Installing uv..."
if has curl; then
curl -fsSL https://astral.sh/uv/install.sh | sh
refresh_uv_path
return
fi
if has wget; then
wget -qO- https://astral.sh/uv/install.sh | sh
refresh_uv_path
return
fi
err "curl or wget is required to install uv."
exit 1
}
if has uv; then
UV_BIN="uv"
else
install_uv
UV_BIN="uv"
fi
if ! has "$UV_BIN"; then
err "uv was not found after installation."
err "Please install uv manually: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
fi
ok "$("$UV_BIN" --version)"
info "Installing AstrBot with Python 3.12..."
"$UV_BIN" tool install --python 3.12 astrbot
ok "AstrBot has been installed."

View File

@@ -1,22 +0,0 @@
import { chmod, copyFile, mkdir } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const scriptDir = dirname(fileURLToPath(import.meta.url));
const repoRoot = resolve(scriptDir, "../..");
const publicScriptsDir = resolve(repoRoot, "docs/public/scripts");
const files = [
{ name: "deploy-cli.sh", mode: 0o755 },
{ name: "deploy-cli.ps1", mode: 0o644 },
];
await mkdir(publicScriptsDir, { recursive: true });
for (const file of files) {
const source = resolve(repoRoot, "scripts", file.name);
const target = resolve(publicScriptsDir, file.name);
await copyFile(source, target);
await chmod(target, file.mode);
console.log(`Copied ${file.name} to docs/public/scripts/`);
}