-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
235 lines (200 loc) · 8.09 KB
/
justfile
File metadata and controls
235 lines (200 loc) · 8.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Scroll Press development commands
# Install dependencies
install:
uv sync
# Run development server (HTTPS-only, detached by default, add 'attach' to run in foreground)
dev MODE="detached": build
#!/usr/bin/env bash
set -a && source .env && set +a
PORT=${PORT:-7999}
# Auto-generate certificates if they don't exist
if [[ ! -f "certs/cert.pem" || ! -f "certs/key.pem" ]]; then
echo "SSL certificates not found. Generating..."
just gen-certs > /dev/null 2>&1
fi
# Check mode parameter
if [[ "{{MODE}}" == "attach" ]]; then
ATTACH_MODE=true
else
ATTACH_MODE=false
fi
if lsof -i :$PORT > /dev/null 2>&1; then
echo "Server already running on port $PORT"
else
if [[ "$ATTACH_MODE" == "true" ]]; then
echo "Starting HTTPS server on port $PORT (attached mode)"
uv run uvicorn main:app --reload --port $PORT --ssl-keyfile certs/key.pem --ssl-certfile certs/cert.pem
else
nohup uv run uvicorn main:app --reload --port $PORT --ssl-keyfile certs/key.pem --ssl-certfile certs/cert.pem > server.log 2>&1 &
sleep 2
echo "HTTPS server started on port $PORT (detached mode - use 'just dev attach' for attached mode)"
echo "Visit: https://localhost:$PORT"
fi
fi
# Stop the development server
stop:
#!/usr/bin/env bash
set -a && source .env && set +a
PORT=${PORT:-7999}
if lsof -i :$PORT > /dev/null 2>&1; then
echo "Stopping server on port $PORT..."
lsof -ti:$PORT | xargs kill -9
echo "Server stopped"
else
echo "No server running on port $PORT"
fi
# Run tests (adapts to local vs CI environment)
test:
#!/usr/bin/env bash
set -e
# Run unit tests
uv run pytest -m "not e2e"
# Run E2E tests based on environment
if [ -n "$CI" ]; then
# CI: Run all test types separately for cross-browser testing
echo "CI detected - running full cross-browser test suite"
uv run pytest -m "e2e and not desktop and not mobile" -v
uv run pytest -m "e2e and desktop" -v
uv run pytest -m "e2e and mobile" -v
else
# Local: Run universal tests only (faster)
echo "Local environment - running universal E2E tests"
uv run pytest -m "e2e and not desktop and not mobile" -v
fi
# Build documentation templates from markdown
build:
#!/usr/bin/env bash
cd docs && ./build.sh
# Format and lint code
lint:
uv run ruff check --fix .
uv run ruff format .
# Database migrations
migrate:
uv run alembic upgrade head
# Create new migration
migration message:
uv run alembic revision --autogenerate -m "{{message}}"
# Seed database with sample data
seed:
#!/usr/bin/env bash
set -e
# Check if examples-press submodule exists
if [[ ! -f "examples-press/scrolls.json" ]]; then
echo "examples-press submodule not found. Initializing..."
git submodule update --init examples-press
fi
PYTHONPATH=. uv run python scripts/seed.py
# Reset database (migrate + seed)
reset-db: migrate seed
# Run all checks
check: lint test
# Generate self-signed SSL certificates for HTTPS development
gen-certs:
#!/usr/bin/env bash
mkdir -p certs
if [[ -f "certs/cert.pem" && -f "certs/key.pem" ]]; then
echo "SSL certificates already exist in certs/"
else
echo "Generating self-signed SSL certificates..."
openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem -days 365 -nodes -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
echo "SSL certificates generated in certs/"
echo "Use 'just dev-https' to start HTTPS server"
fi
# Install git hooks
install-hooks:
#!/usr/bin/env bash
bash scripts/install-hooks.sh
# Connect to production database with psql (read-only: SELECT queries only)
db-prod *ARGS:
#!/usr/bin/env bash
set -a && source .env && set +a
if [ -z "$DATABASE_URL_PROD" ]; then
echo "Error: DATABASE_URL_PROD not found in .env"
exit 1
fi
if [ -z "{{ARGS}}" ]; then
echo "Error: No SQL query provided"
echo "Usage: just db-prod \"SELECT ...\""
echo "Note: Only SELECT queries are allowed for safety"
exit 1
else
# Check if query starts with SELECT (case-insensitive)
QUERY="{{ARGS}}"
QUERY_UPPER=$(echo "$QUERY" | tr '[:lower:]' '[:upper:]' | xargs)
if [[ ! "$QUERY_UPPER" =~ ^SELECT.* ]]; then
echo "Error: Only SELECT queries are allowed on production database"
echo "For write operations, use the Supabase dashboard or fly ssh console"
exit 1
fi
# Execute read-only SQL command
psql "$DATABASE_URL_PROD" -c "{{ARGS}}"
fi
# Test email service configuration (sends one test email)
email-health-check:
#!/usr/bin/env bash
set -a && source .env && set +a
echo "Testing email service configuration..."
uv run python scripts/email_health_check.py
# Deploy to production and run email health check
deploy: build
#!/usr/bin/env bash
set -e
echo "🚀 Deploying to production..."
fly deploy
echo ""
echo "✅ Deployment complete!"
echo "📧 Running email health check..."
echo ""
fly ssh console -C "uv run --frozen --no-dev python scripts/email_health_check.py"
echo ""
echo "🎉 Deployment and health check complete!"
echo "📬 Check your admin email for the test message"
# Generate changelog entry from commits since last tag
changelog version="Unreleased":
#!/usr/bin/env bash
set -euo pipefail
VERSION="{{version}}"
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then COMMITS=$(git log --oneline --no-merges); else COMMITS=$(git log --oneline --no-merges "${LAST_TAG}..HEAD"); fi
DATE=$(date +%Y-%m-%d)
PROMPT="Generate a CHANGELOG entry for version $VERSION (date: $DATE). Commits since last tag: $COMMITS. Rules: Skip ci/test/chore/docs commits and submodule updates. Group into Keep-a-Changelog sections: Added (feat:), Fixed (fix:), Changed (other). Rewrite as user-friendly prose. Omit empty sections. If no user-visible changes output: _No user-visible changes._ Output only raw markdown (no preamble, no code fences): ## [$VERSION] - $DATE, then ### Added, ### Fixed, ### Changed sections as needed."
entry=$(claude --print "$PROMPT")
if [ -f CHANGELOG.md ]; then { head -1 CHANGELOG.md; printf "\n%s\n" "$entry"; tail -n +2 CHANGELOG.md; } > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md; else printf "# Changelog\n\n%s\n" "$entry" > CHANGELOG.md; fi
echo "==> CHANGELOG.md updated for $VERSION"
# Release: bump version, generate changelog, update roadmap, tag, push
release level:
#!/usr/bin/env bash
set -euo pipefail
LEVEL="{{level}}"
if [[ "$LEVEL" != "major" && "$LEVEL" != "minor" && "$LEVEL" != "patch" ]]; then
echo "Error: level must be 'major', 'minor', or 'patch', got '$LEVEL'"
exit 1
fi
CURRENT=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
IFS='.' read -r major minor patch <<< "$CURRENT"
case "$LEVEL" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
NEXT="${major}.${minor}.${patch}"
echo "==> Bumping $CURRENT -> $NEXT"
sed -i '' "s/^version = \"$CURRENT\"/version = \"$NEXT\"/" pyproject.toml
echo "==> Generating changelog"
just changelog "$NEXT"
echo "==> Updating roadmap page"
just _update-roadmap "$NEXT"
git add pyproject.toml CHANGELOG.md app/templates/roadmap.html
git commit -m "Release v${NEXT}"
git tag "v${NEXT}"
git push origin main --tags
echo "==> Released v${NEXT}"
echo "==> Deploying to production"
just deploy
# Internal: inject latest changelog entry into roadmap.html
_update-roadmap version:
uv run python scripts/update_roadmap.py "{{version}}"
# Setup project from scratch
init: install build migrate seed install-hooks
@echo "Project setup complete! Run 'just dev' to start the server."