ai-story-teller / Makefile
ruslanmv's picture
Version 5 Gradio
021b323
# Makefile for ai-story-teller (local dev & endpoint checks)
# Default Node version (override with: make NODE=20)
NODE ?= 18
PORT ?= 3000
# Path to .env (create from .env.example or manually)
ENV ?= .env
# Test prompts (override with: make test STORY_PROMPT="..." VOICE="..." IMG_PROMPT="...")
STORY_PROMPT ?= A short wholesome bedtime story about a friendly dragon.
VOICE ?= Cloée
IMG_PROMPT ?= a cute cat sticker
.PHONY: help setup env dev build start check-endpoints test clean verify-scripts
help:
@echo "Targets:"
@echo " setup Install Node deps (npm ci if lockfile exists)"
@echo " env Create .env from .env.example if missing and show key vars"
@echo " dev Run Next.js dev server"
@echo " build Build Next.js app"
@echo " start Start built Next.js app"
@echo " check-endpoints Run Node endpoint check (tests/test_connections/test_endpoints.mjs)"
@echo " test Run bash endpoint checks (story + image)"
@echo " clean Remove .next"
@echo ""
@echo "Vars: NODE=$(NODE) PORT=$(PORT) ENV=$(ENV)"
@echo "Test Vars: STORY_PROMPT='$(STORY_PROMPT)' VOICE='$(VOICE)' IMG_PROMPT='$(IMG_PROMPT)'"
setup:
@echo ">>> Installing dependencies…"
@if [ -f package-lock.json ]; then npm ci; else npm install; fi
env:
@if [ ! -f $(ENV) ] && [ -f .env.example ]; then cp .env.example $(ENV); fi
@if [ ! -f $(ENV) ]; then \
printf "AI_STORY_API_GRADIO_URL=\"\"\nAI_STORY_API_SECRET_TOKEN=\"secret\"\nAI_FAST_IMAGE_SERVER_API_GRADIO_URL=\"\"\nAI_FAST_IMAGE_SERVER_API_SECRET_TOKEN=\"default_secret\"\nNEXT_PUBLIC_ENABLE_COMMUNITY_SHARING=\"false\"\n" > $(ENV); \
fi
@echo ">>> Using $(ENV)"
@grep -E 'AI_.*|NEXT_PUBLIC_' $(ENV) || true
dev: env
@echo ">>> Starting Next dev on :$(PORT)"
npm run dev -- -p $(PORT)
build: env
npm run build
start: env
npm run start -- -p $(PORT)
# Ensure the bash test script exists & is executable (used by `make test`)
verify-scripts:
@test -f tests/test_connections/test_endpoints.sh || { \
echo "tests/test_connections/test_endpoints.sh not found."; \
echo "Please create it and make it executable:"; \
echo " chmod +x tests/test_connections/test_endpoints.sh"; \
exit 1; \
}
@chmod +x tests/test_connections/test_endpoints.sh
# NEW: Node-based check (mjs only)
check-endpoints: env
@echo ">>> Running Node endpoint check (mjs)…"
node tests/test_connections/test_endpoints.mjs
# Keep `make test` EXACTLY as-is (bash script)
test: env verify-scripts
@echo ">>> Running endpoint checks (story + image)…"
@./tests/test_connections/test_endpoints.sh "$(STORY_PROMPT)" "$(VOICE)" "$(IMG_PROMPT)"
clean:
rm -rf .next