eight-hourr/Makefile

119 lines
4.2 KiB
Makefile
Raw Permalink Normal View History

2026-07-17 06:55:36 +00:00
PYTHON := .venv/bin/python
PIP := .venv/bin/pip
TODAY := $(shell date +%Y-%m-%d)
.PHONY: help setup init status preview preview-dates dry-run dry-run-dates fill fill-range fill-dates teams-test start stop restart server-status start-fg docker-build docker-up docker-down docker-logs docker-restart docker-start
help:
@echo "吉八小 · 集滿八小時"
@echo ""
@echo " make setup 建立 venv + 安裝依賴 + 建立 .env"
@echo " make status 檢查設定 / Session / 任務數"
@echo " make preview 用 Grok 預覽今天的填寫計畫"
@echo " make dry-run 試跑今天(不送出 PTS"
@echo " make fill 一鍵填寫今天"
@echo " make fill-range START=... END=... 補寫日期區間"
@echo " make fill-dates 依 dates.txt 補寫指定日期"
@echo " make preview-dates 預覽 dates.txt 的分配"
@echo " make teams-test [START=] [END=] 只測 Teams 抓會議(不寫 PTS"
@echo " make start 背景啟動 Web UI + API"
@echo " make stop 關閉伺服器"
@echo " make restart 重啟伺服器"
@echo " make server-status 查看伺服器是否在跑"
@echo " make start-fg 前景啟動開發用Ctrl+C 結束)"
@echo " make docker-start 一鍵:關本地 + 建置 + 啟動 Docker"
@echo " make docker-build 建置 Docker 映像"
@echo " make docker-up 啟動 Docker無主機掛載/data 為 tmpfs關容器即消失"
@echo " make docker-down 停止 Docker"
@echo " make docker-logs 查看 Docker log"
@echo ""
@echo "第一次請先:"
@echo " 1) 編輯 .env 填入 GITLAB_TOKEN / XAI_API_KEY"
@echo " 2) make start → 網頁輸入 PTS與選用 Teams帳密登入"
@echo " 3) make fill"
setup: init
python3 -m venv .venv
$(PIP) install -r backend/requirements.txt
$(PYTHON) -m playwright install chromium
@echo "Setup done. Edit .env then open http://localhost:8765 to login with PTS / Teams accounts."
init:
@test -f .env || cp .env.example .env
status:
cd backend && ../$(PYTHON) cli.py status
preview:
cd backend && ../$(PYTHON) cli.py preview --start $(TODAY) --end $(TODAY)
dry-run:
cd backend && ../$(PYTHON) cli.py fill-today --dry-run
fill:
cd backend && ../$(PYTHON) cli.py fill-today
fill-range:
@test -n "$(START)" && test -n "$(END)" || (echo "Usage: make fill-range START=YYYY-MM-DD END=YYYY-MM-DD" && exit 1)
cd backend && ../$(PYTHON) cli.py fill-range --start $(START) --end $(END)
preview-dates:
cd backend && ../$(PYTHON) cli.py preview-dates --file ../dates.txt
dry-run-dates:
cd backend && ../$(PYTHON) cli.py fill-dates --file ../dates.txt --dry-run
fill-dates:
cd backend && ../$(PYTHON) cli.py fill-dates --file ../dates.txt
teams-test:
cd backend && ../$(PYTHON) cli.py teams-test $(if $(START),--start $(START),) $(if $(END),--end $(END),) $(if $(INCLUDE_HOLIDAYS),--include-holidays,)
start:
@chmod +x scripts/server.sh
@./scripts/server.sh start
stop:
@chmod +x scripts/server.sh
@./scripts/server.sh stop
restart:
@chmod +x scripts/server.sh
@./scripts/server.sh restart
server-status:
@chmod +x scripts/server.sh
@./scripts/server.sh status
start-fg:
cd backend && ../$(PYTHON) main.py
docker-start:
@chmod +x scripts/docker-start.sh
@./scripts/docker-start.sh
docker-build:
docker compose build --pull
docker-up:
@echo "Ephemeral mode: no host data mount (tmpfs /data only)"
docker compose up -d --build --force-recreate --remove-orphans
@echo "Web UI: http://localhost:$${BACKEND_PORT:-8765}"
@echo "資料僅在容器內docker compose down 後即消失"
docker-down:
docker compose down --remove-orphans
docker-logs:
docker compose logs -f
docker-restart:
docker compose up -d --force-recreate --build --remove-orphans
# Stop local Python server + Docker container
stop-all:
@chmod +x scripts/server.sh
@./scripts/server.sh stop 2>/dev/null || true
@docker compose down --remove-orphans 2>/dev/null || true
@echo "All local + Docker services stopped"