Files
openwork/scripts/dev-web-local.sh
Omar McAdam 2b91b4d777 refactor: repo folder structure (#1038)
* refactor(repo): move OpenWork apps into apps and ee layout

Rebase the monorepo layout migration onto the latest dev changes so the moved app, desktop, share, and cloud surfaces keep working from their new paths. Carry the latest deeplink, token persistence, build, Vercel, and docs updates forward to avoid stale references and broken deploy tooling.

* chore(repo): drop generated desktop artifacts

Ignore the moved Tauri target and sidecar paths so local cargo checks do not pollute the branch. Remove the accidentally committed outputs from the repo while keeping the layout migration intact.

* fix(release): drop built server cli artifact

Stop tracking the locally built apps/server/cli binary so generated server outputs do not leak into commits. Also update the release workflow to check the published scoped package name for @openwork/server before deciding whether npm publish is needed.

* fix(workspace): add stable CLI bin wrappers

Point the server and router package bins at committed wrapper scripts so workspace installs can create shims before dist outputs exist. Keep the wrappers compatible with built binaries and source checkouts to avoid Vercel install warnings without changing runtime behavior.
2026-03-19 11:41:38 -07:00

70 lines
2.0 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="$ROOT_DIR/packaging/docker/docker-compose.web-local.yml"
PROJECT_NAME="openwork-web-local"
DEV_CMD=(pnpm --parallel --filter @openwork-ee/den-controller --filter @openwork-ee/den-web dev)
# Local-dev defaults — match the MySQL container in docker-compose.web-local.yml.
# These are only used when not already set in the environment or .env.
: "${DATABASE_URL:=mysql://root:password@127.0.0.1:3306/openwork_den}"
: "${BETTER_AUTH_SECRET:=local-dev-secret-not-for-production-use!!}"
: "${BETTER_AUTH_URL:=http://localhost:8788}"
export DATABASE_URL BETTER_AUTH_SECRET BETTER_AUTH_URL
detect_web_origins() {
node <<'EOF'
const os = require('os');
const origins = new Set([
'http://localhost:3005',
'http://127.0.0.1:3005',
]);
for (const entries of Object.values(os.networkInterfaces())) {
for (const entry of entries || []) {
if (!entry || entry.internal || entry.family !== 'IPv4') continue;
origins.add(`http://${entry.address}:3005`);
}
}
process.stdout.write(Array.from(origins).join(','));
EOF
}
cleanup() {
local exit_code=$?
trap - EXIT INT TERM
if [[ -n "${DEV_PID:-}" ]]; then
kill "$DEV_PID" >/dev/null 2>&1 || true
wait "$DEV_PID" 2>/dev/null || true
fi
docker compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" down -v >/dev/null 2>&1 || true
exit "$exit_code"
}
trap cleanup EXIT INT TERM
if ! command -v docker >/dev/null 2>&1; then
echo "docker is required for pnpm dev:web-local" >&2
exit 1
fi
echo "Starting local MySQL..."
docker compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" down -v >/dev/null 2>&1 || true
docker compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" up -d --wait mysql
echo "Running Den migrations..."
pnpm --filter @openwork-ee/den-controller db:migrate
WEB_CORS_ORIGINS="$(detect_web_origins)"
echo "Allowing Better Auth origins: $WEB_CORS_ORIGINS"
echo "Starting Den and web dev servers..."
env CORS_ORIGINS="$WEB_CORS_ORIGINS" "${DEV_CMD[@]}" &
DEV_PID=$!
wait "$DEV_PID"