This commit is contained in:
iwrs
2026-03-25 11:04:49 +08:00
parent d9c5c9f846
commit 4d928479f6
79 changed files with 9424 additions and 1 deletions

14
scripts/build.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -Eeuo pipefail
WORKSPACE_PATH="/workspace"
cd $WORKSPACE_PATH
echo "Installing dependencies..."
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
echo "Building the project..."
pnpm build
echo "Build completed successfully!"

12
scripts/commit.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
cd /workspace || exit 1
if [ -z "$1" ]; then
echo "Usage: $0 \"commit message\""
exit 1
fi
git add .
git commit -m "$1"
git push

11
scripts/prepare.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
WORKSPACE_PATH="/workspace"
cd $WORKSPACE_PATH
echo "Installing dependencies..."
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
echo "Dependencies install successfully!"

64
scripts/start.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
set -Eeuo pipefail
PORT=5173
WORKSPACE_PATH="/workspace"
cd $WORKSPACE_PATH
kill_port_if_listening() {
local port="$PORT"
local hex_port
local inodes=""
local pids=""
# 转16进制端口大端
hex_port=$(printf '%04X\n' "$port")
# 找 TCP (IPv4)
inodes+=$(awk -v port=":$hex_port" '$2 ~ port && $4 == "0A" {print $10}' /proc/net/tcp 2>/dev/null || true)
# 找 TCP (IPv6)
inodes+=" "
inodes+=$(awk -v port=":$hex_port" '$2 ~ port && $4 == "0A" {print $10}' /proc/net/tcp6 2>/dev/null || true)
inodes=$(echo "$inodes" | tr ' ' '\n' | sort -u | tr '\n' ' ')
if [[ -z "$inodes" ]]; then
return 0
fi
# 通过 inode 找 PID
for inode in $inodes; do
for pid in $(ls /proc | grep -E '^[0-9]+$'); do
if ls -l /proc/$pid/fd 2>/dev/null | grep -q "socket:\[$inode\]"; then
pids="$pids $pid"
fi
done
done
# 去重
pids=$(echo "$pids" | tr ' ' '\n' | sort -u | tr '\n' ' ')
pids="${pids#" "}"
if [[ -z "$pids" ]]; then
echo "Port ${port} has socket but no PID found."
return 1
fi
kill -9 $pids 2>/dev/null || true
sleep 1
local check
check=$(awk -v port=":$hex_port" '$2 ~ port && $4 == "0A"' /proc/net/tcp /proc/net/tcp6 2>/dev/null || true)
if [[ -n "$check" ]]; then
echo "Warning: port ${port} still busy after SIGKILL"
fi
}
kill_port_if_listening
echo "Starting HTTP service on port ${PORT} for dev..."
pnpm dev -- --host 0.0.0.0 --port $PORT