34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start server + frontend in dev mode using tmux.
|
|
# Run from workdir/ — this directory is the CW workspace.
|
|
# Usage: ./dev.sh [session-name]
|
|
# ./dev.sh → session "cw"
|
|
# ./dev.sh myapp → custom session name
|
|
|
|
set -e
|
|
|
|
SESSION="${1:-cw}"
|
|
WORKDIR="$(cd "$(dirname "$0")" && pwd)"
|
|
ROOT="$(cd "$WORKDIR/.." && pwd)"
|
|
|
|
if ! command -v tmux &>/dev/null; then
|
|
echo "tmux not found. Install with: brew install tmux" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if tmux has-session -t "$SESSION" 2>/dev/null; then
|
|
echo "Session '$SESSION' already running — attaching."
|
|
exec tmux attach-session -t "$SESSION"
|
|
fi
|
|
|
|
# Server: runs from workdir/ so cw finds .cwrc here
|
|
tmux new-session -d -s "$SESSION" -n server -c "$WORKDIR"
|
|
tmux send-keys -t "$SESSION:server" "npx tsx watch $ROOT/apps/server/bin/cw.ts --server" Enter
|
|
|
|
# Frontend: runs from project root via npm workspace
|
|
tmux new-window -t "$SESSION" -n web -c "$ROOT"
|
|
tmux send-keys -t "$SESSION:web" "npm run dev --workspace=apps/web" Enter
|
|
|
|
tmux select-window -t "$SESSION:server"
|
|
exec tmux attach-session -t "$SESSION"
|