haixunMaster/scripts/init.sh

49 lines
1.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# First-time project setup: deps, .env, directories, database schema.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
echo "==> 巡樓 Haixun 初始化"
if ! command -v node >/dev/null 2>&1; then
echo "錯誤:找不到 node請先安裝 Node.js 20+" >&2
exit 1
fi
if ! command -v npm >/dev/null 2>&1; then
echo "錯誤:找不到 npm" >&2
exit 1
fi
echo "==> Node $(node -v)"
echo "==> 安裝依賴"
npm install
if [[ ! -f .env ]]; then
cp .env.example .env
echo "==> 已建立 .env請編輯填入 API Key 與 DATABASE_URL"
else
echo "==> 沿用既有 .env"
fi
echo "==> 建立資料目錄"
mkdir -p \
data/draft-images \
data/search-cache \
data/search-quota \
data/threads-browser-profile \
prisma
echo "==> 初始化資料庫"
npm run db:generate
npm run db:push
echo ""
echo "初始化完成。"
echo " 1. 編輯 .env 填入必要設定"
echo " 2. 生產環境make build && make up"
echo " 3. 開發模式make dev"
echo " 4. 查看狀態make status"