Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add dev.sh to control developer port config (#2163)
Leendert de Borst080846e28327
diff --git a/.vscode/tasks.json b/.vscode/tasks.jsonindex c189f18bd..d33d7519c 100644--- a/.vscode/tasks.json+++ b/.vscode/tasks.json@@ -4,71 +4,85 @@{"label": "Build and watch API","type": "shell",- "command": "dotnet watch",- "args": [],+ "command": "./scripts/dev.sh",+ "args": ["api"],"problemMatcher": [],"group": {"kind": "build","isDefault": true},"options": {- "cwd": "${workspaceFolder}/apps/server/AliasVault.Api"+ "cwd": "${workspaceFolder}"}},{"label": "Build and watch Client","type": "shell",- "command": "dotnet watch",- "args": [],+ "command": "./scripts/dev.sh",+ "args": ["client"],"problemMatcher": [],"group": {"kind": "build","isDefault": true},"options": {- "cwd": "${workspaceFolder}/apps/server/AliasVault.Client"+ "cwd": "${workspaceFolder}"}},{"label": "Build and watch Admin","type": "shell",- "command": "dotnet watch",- "args": [],+ "command": "./scripts/dev.sh",+ "args": ["admin"],"problemMatcher": [],"group": {"kind": "build","isDefault": true},"options": {- "cwd": "${workspaceFolder}/apps/server/AliasVault.Admin"+ "cwd": "${workspaceFolder}"}},{"label": "Build and watch SMTP Service","type": "shell",- "command": "dotnet watch",- "args": [],+ "command": "./scripts/dev.sh",+ "args": ["smtp"],"problemMatcher": [],"group": {"kind": "build","isDefault": true},"options": {- "cwd": "${workspaceFolder}/apps/server/Services/AliasVault.SmtpService"+ "cwd": "${workspaceFolder}"}},{"label": "Build and watch TaskRunner","type": "shell",- "command": "dotnet watch",- "args": [],+ "command": "./scripts/dev.sh",+ "args": ["taskrunner"],+ "problemMatcher": [],+ "group": {+ "kind": "build",+ "isDefault": true+ },+ "options": {+ "cwd": "${workspaceFolder}"+ }+ },+ {+ "label": "Start dev database",+ "type": "shell",+ "command": "./scripts/dev.sh",+ "args": ["db"],"problemMatcher": [],"group": {"kind": "build","isDefault": true},"options": {- "cwd": "${workspaceFolder}/apps/server/Services/AliasVault.TaskRunner"+ "cwd": "${workspaceFolder}"}},{@@ -129,15 +143,15 @@{"label": "Run Browser Extension (Chrome Dev)","type": "shell",- "command": "npm",- "args": ["run", "dev:chrome"],+ "command": "./scripts/dev.sh",+ "args": ["ext"],"problemMatcher": [],- "options": {- "cwd": "${workspaceFolder}/apps/browser-extension"- },"group": {"kind": "build","isDefault": true+ },+ "options": {+ "cwd": "${workspaceFolder}"}},{@@ -223,6 +237,6 @@"isDefault": true},"dependsOn": []- },+ }]-}\ No newline at end of file+}diff --git a/docs/misc/dev/database-operations.md b/docs/misc/dev/database-operations.mdindex 3cb2fb288..7f955579d 100644--- a/docs/misc/dev/database-operations.md+++ b/docs/misc/dev/database-operations.md@@ -15,20 +15,12 @@ The `install.sh` script contains helper methods that makes it easy to export and### Export database```bash-# Export from normal database container (port 5432, production)./install.sh db-export > aliasvault-db-export.sql.gz--# Export from dev database container (port 5433, development)-./install.sh db-export --dev > aliasvault-db-export.sql.gz```### Import database```bash-# Import to normal database container (port 5432, production)./install.sh db-import < aliasvault-db-export.sql.gz--# Import to dev database container (port 5433, development)-./install.sh db-import --dev < aliasvault-db-export.sql.gz```> Tip: you can also use the optional parameters `--yes` (to skip confirmation prompt) and `--verbose` (to get more output on what the operation is doing).diff --git a/docs/misc/dev/linux-macos-development.md b/docs/misc/dev/linux-macos-development.mdindex 2a3270be7..263843474 100644--- a/docs/misc/dev/linux-macos-development.md+++ b/docs/misc/dev/linux-macos-development.md@@ -46,9 +46,14 @@ This guide will help you set up AliasVault for development on Linux or MacOS sysdotnet ef```-3. **Install dev database**+3. **Start the dev database**++ `./scripts/dev.sh` is the single entry point for local development: it starts+ the dev database and runs the apps from source on a consistent, preconfigured+ set of ports (so the apps always find each other). Run it without arguments+ for an interactive menu, or use a subcommand directly:```bash- ./install.sh configure-dev-db+ ./scripts/dev.sh db-start # start the dev database (db-stop to stop it)```4. **Run Tailwind CSS compiler**@@ -72,10 +77,14 @@ This guide will help you set up AliasVault for development on Linux or MacOS sys```6. **Configure Development Settings**- Create `wwwroot/appsettings.Development.json` in the Client project:++ When you start the client via `./scripts/dev.sh client`, this file is generated+ automatically with the correct `ApiUrl` for your ports — you can skip this step.+ Only create `wwwroot/appsettings.Development.json` in the Client project manually+ if you run the client some other way:```json{- "ApiUrl": "http://localhost:5092",+ "ApiUrl": "http://localhost:5100","PrivateEmailDomains": ["example.tld"],"SupportEmail": "[email protected]","UseDebugEncryptionKey": "true",@@ -102,19 +111,21 @@ This guide will help you set up AliasVault for development on Linux or MacOS sys## Running the Application-1. **Start the Development Database**- ```bash- ./install.sh configure-dev-db- ```+Use `./scripts/dev.sh` for everything — it starts the dev database and runs each+app from source on its preconfigured port. Each invocation starts one app, so open+a terminal per app (or use the VS Code tasks, which fan out one call per app):-2. **Run the Application**- ```bash- # Using dotnet CLI- cd apps/server/AliasVault.Api- dotnet run+```bash+./scripts/dev.sh db-start # start the dev database first+./scripts/dev.sh api # then the API+./scripts/dev.sh client # the Blazor client (writes its dev appsettings for you)+./scripts/dev.sh admin # the admin web app+./scripts/dev.sh # no argument → interactive menu+./scripts/dev.sh ports # print the resolved port map+```- # Or using your preferred IDE (VS Code, Rider, etc.)- ```+You can still run an individual project directly from your IDE (VS Code, Rider, etc.)+if you prefer; `./scripts/dev.sh ports` shows which ports it expects.## Troubleshooting@@ -133,7 +144,8 @@ If you encounter database connection issues:3. **Restart Database**```bash- ./install.sh configure-dev-db+ ./scripts/dev.sh db-stop+ ./scripts/dev.sh db-start```### Common Issues@@ -145,13 +157,13 @@ If you encounter database connection issues:```2. **Port Conflicts**- - Check if port 5433 is available for the development database- - Check if port 5092 is available for the API+ - Run `./scripts/dev.sh ports` to see the ports in use (defaults: API `5100`, database `5109`)+ - If those ports are taken, bump `AV_INSTANCE` in `dev.env.local` to shift the whole block## Additional Notes- Keep your .NET SDK and Docker up to date-- The development database runs on port 5433 to avoid conflicts+- The development database runs on port 5109 by default (configurable via `dev.env.local`)- Use the debug encryption key in development for easier testing- Store sensitive data in environment variables or user secretsdiff --git a/docs/misc/dev/mobile-apps/ios/e2e-testing.md b/docs/misc/dev/mobile-apps/ios/e2e-testing.mdindex 03c04f3bf..43149839d 100644--- a/docs/misc/dev/mobile-apps/ios/e2e-testing.md+++ b/docs/misc/dev/mobile-apps/ios/e2e-testing.md@@ -23,7 +23,7 @@ The iOS app has two test targets:- iOS Simulator configured- Node.js 20+- CocoaPods dependencies installed (`cd apps/mobile-app && npx pod-install`)-- For UI tests: Local API server running at `http://localhost:5092`+- For UI tests: connect to your local API dev instance (by default `http://localhost:5100` when started via `./scripts/dev.sh api`, or `http://localhost:5092` when running the API project directly)## Running Tests@@ -97,6 +97,9 @@ xcodebuild test \#### With Custom API URL (for UI tests)+Point `API_URL` at your API dev instance (by default `5100` when started via+`./scripts/dev.sh api`, or `5092` when running the API project directly):+```bashAPI_URL="http://your-server:5092" xcodebuild test \-workspace AliasVault.xcworkspace \diff --git a/docs/misc/dev/windows-development.md b/docs/misc/dev/windows-development.mdindex 3bc16f717..b0ae4629a 100644--- a/docs/misc/dev/windows-development.md+++ b/docs/misc/dev/windows-development.md@@ -63,11 +63,12 @@ This guide will help you set up AliasVault for development on Windows using WSL3. **Setup Development Database**- Open a new WSL terminal in the AliasVault directory- - Run the development database setup:+ - `./scripts/dev.sh` is the single entry point for local development: it starts+ the dev database and runs the apps from source on a consistent, preconfigured+ set of ports. Start the database with:```bash- ./install.sh configure-dev-db+ ./scripts/dev.sh db-start```- - Select option 1 to start the development database- Verify the database is running:```bashdocker ps | grep postgres-dev@@ -77,6 +78,9 @@ This guide will help you set up AliasVault for development on Windows using WSL- Open the solution in Visual Studio 2022- Set WebApi as the startup project- Press F5 to run in debug mode+ - Alternatively, run the apps from WSL with `./scripts/dev.sh` (one app per+ terminal, e.g. `./scripts/dev.sh api`); `./scripts/dev.sh ports` shows the+ ports each app uses## Troubleshooting@@ -103,8 +107,8 @@ If the WebApi fails to start due to database connection issues:4. **Restart Development Database**```bash- ./install.sh configure-dev-db- # Select option 2 to stop, then option 1 to start again+ ./scripts/dev.sh db-stop+ ./scripts/dev.sh db-start```### WSL Issuesdiff --git a/scripts/dev.sh b/scripts/dev.shnew file mode 100755index 000000000..324a94d3f--- /dev/null+++ b/scripts/dev.sh@@ -0,0 +1,327 @@+#!/usr/bin/env bash+# ----------------------------------------------------------------------------+# AliasVault dev app starter.+#+# Use this to start AliasVault apps in dev mode with a preconfigured port+# setup: every service runs from source on a single, consistent set of ports,+# so the apps always know where to find each other.+#+# Each invocation starts exactly one app/service. To run several at once,+# launch multiple instances (e.g. the VS Code tasks fan out one call per app).+#+# Config defaults live in this script; per-machine overrides go in the+# (gitignored) ./dev.env.local, which is created from a template on first run.+#+# Usage:+# ./scripts/dev.sh # interactive menu (pick an app)+# ./scripts/dev.sh <app> # start one app: api | client | admin | smtp | taskrunner | ext | mobile+# ./scripts/dev.sh db # toggle the dev database (start if stopped, else stop)+# ./scripts/dev.sh db-start # start (only) the dev database+# ./scripts/dev.sh db-stop # stop & remove this instance's dev database+# ./scripts/dev.sh ports # print the resolved port map and exit+# ----------------------------------------------------------------------------+set -euo pipefail++# --- Resolve repo paths --------------------------------------------------------+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"+cd "$ROOT_DIR"++# --- Colors (no-op if not a TTY) ----------------------------------------------+if [ -t 1 ]; then+ BOLD=$'\033[1m'; DIM=$'\033[2m'; GREEN=$'\033[32m'; CYAN=$'\033[36m'+ YELLOW=$'\033[33m'; RED=$'\033[31m'; NC=$'\033[0m'+else+ BOLD=""; DIM=""; GREEN=""; CYAN=""; YELLOW=""; RED=""; NC=""+fi+info() { printf "%s==>%s %s\n" "$CYAN" "$NC" "$1"; }+warn() { printf "%s! %s%s\n" "$YELLOW" "$1" "$NC"; }+die() { printf "%sError:%s %s\n" "$RED" "$NC" "$1" >&2; exit 1; }++LOCAL_ENV="$ROOT_DIR/dev.env.local"++# --- Config defaults -----------------------------------------------------------+DEFAULT_BASE_PORT=5100 # first port of the block; every service counts up from here+DEFAULT_PORT_STRIDE=10 # how far apart consecutive instances are spaced++# Write the dev.env.local template, with AV_INSTANCE pinned to the given value.+seed_local_env() {+ cat > "$LOCAL_ENV" <<ENV+# ----------------------------------------------------------------------------+# AliasVault dev instance config — generated by scripts/dev.sh, gitignored.+#+# AV_INSTANCE picks which block of ports this machine uses. Bump it if the+# default ports are already taken on your machine (another stack, another dev,+# something else on those ports). Each step moves every port up by ${DEFAULT_PORT_STRIDE}:+#+# AV_INSTANCE=0 -> ${DEFAULT_BASE_PORT}..$((DEFAULT_BASE_PORT + 8)) (default)+# AV_INSTANCE=1 -> $((DEFAULT_BASE_PORT + DEFAULT_PORT_STRIDE))..$((DEFAULT_BASE_PORT + DEFAULT_PORT_STRIDE + 8))+# AV_INSTANCE=2 -> $((DEFAULT_BASE_PORT + 2 * DEFAULT_PORT_STRIDE))..$((DEFAULT_BASE_PORT + 2 * DEFAULT_PORT_STRIDE + 8))+# ...+# ----------------------------------------------------------------------------+AV_INSTANCE=$1++AV_BASE_PORT=$DEFAULT_BASE_PORT+AV_PORT_STRIDE=$DEFAULT_PORT_STRIDE++# UseDebugEncryptionKey for the Blazor client. 'true' uses a fixed debug+# encryption key so local logins skip the slow key derivation, speeds up dev.+# Note: this can conflict with some things like password verification steps.+# Switch to 'false' to use the actual user unlock flow compatible with production.+AV_USE_DEBUG_ENCRYPTION_KEY=true+ENV+}++# --- Load port config ----------------------------------------------------------+# First run: create a dev.env.local set to instance 0.+if [ ! -f "$LOCAL_ENV" ]; then+ seed_local_env 0+ info "Created dev.env.local (instance 0). Bump AV_INSTANCE there if the default ports are in use."+fi++# shellcheck disable=SC1091+set -a+. "$LOCAL_ENV"+set +a++# Precedence: dev.env.local > built-in defaults.+AV_INSTANCE="${AV_INSTANCE:-0}"+AV_BASE_PORT="${AV_BASE_PORT:-$DEFAULT_BASE_PORT}"+AV_PORT_STRIDE="${AV_PORT_STRIDE:-$DEFAULT_PORT_STRIDE}"+# Default true for pre-existing dev.env.local files that predate this setting.+AV_USE_DEBUG_ENCRYPTION_KEY="${AV_USE_DEBUG_ENCRYPTION_KEY:-true}"+case "$AV_INSTANCE" in (*[!0-9]*|"") die "AV_INSTANCE must be a non-negative integer (got '$AV_INSTANCE').";; esac+case "$AV_USE_DEBUG_ENCRYPTION_KEY" in true|false) ;; (*) die "AV_USE_DEBUG_ENCRYPTION_KEY must be 'true' or 'false' (got '$AV_USE_DEBUG_ENCRYPTION_KEY').";; esac++# --- Resolve effective ports ---------------------------------------------------+SERVICE_COUNT=10 # block width (offsets 0..9); DB sits last so it ends in 9+case "$AV_PORT_STRIDE" in (*[!0-9]*|"") die "AV_PORT_STRIDE must be a positive integer (got '$AV_PORT_STRIDE').";; esac+[ "$AV_PORT_STRIDE" -ge "$SERVICE_COUNT" ] || die "AV_PORT_STRIDE ($AV_PORT_STRIDE) must be >= $SERVICE_COUNT so instances don't overlap."+case "$AV_BASE_PORT" in (*[!0-9]*|"") die "AV_BASE_PORT must be a positive integer (got '$AV_BASE_PORT').";; esac++BLOCK_BASE=$(( AV_BASE_PORT + AV_INSTANCE * AV_PORT_STRIDE ))+# Dev only serves HTTP, so each web app reserves a single port.+API_HTTP=$(( BLOCK_BASE + 0 ))+CLIENT_HTTP=$(( BLOCK_BASE + 1 ))+ADMIN_HTTP=$(( BLOCK_BASE + 2 ))+EXT_PORT=$(( BLOCK_BASE + 3 ))+EXPO_PORT=$(( BLOCK_BASE + 4 ))+# DB sits at the last offset so its port always ends in 9 (e.g. 5109) — easy to+# remember. Offsets 5..8 are left free as spare slots inside the block.+DB_PORT=$(( BLOCK_BASE + 9 ))++if [ "$AV_INSTANCE" = "0" ]; then+ DB_PROJECT="aliasvault-dev"+else+ DB_PROJECT="aliasvault-dev-$AV_INSTANCE"+fi+DB_COMPOSE="$ROOT_DIR/dockerfiles/docker-compose.dev.yml"+CONN_STR="Host=localhost;Port=$DB_PORT;Database=aliasvault;Username=aliasvault;Password=password;Maximum Pool Size=20;Minimum Pool Size=1"++# --- Helpers -------------------------------------------------------------------+RULE="────────────────────────────────────────────────────────────"++print_ports() {+ printf "%sAliasVault dev — instance %s%s (base %s, stride %s → block %s..%s)\n" \+ "$BOLD" "$AV_INSTANCE" "$NC" "$AV_BASE_PORT" "$AV_PORT_STRIDE" "$BLOCK_BASE" "$((BLOCK_BASE + SERVICE_COUNT - 1))"+ printf " %-14s http://localhost:%s\n" "API" "$API_HTTP"+ printf " %-14s http://localhost:%s\n" "Client" "$CLIENT_HTTP"+ printf " %-14s http://localhost:%s\n" "Admin" "$ADMIN_HTTP"+ printf " %-14s localhost:%s\n" "Postgres DB" "$DB_PORT"+ printf " %-14s :%s\n" "Browser ext" "$EXT_PORT"+ printf " %-14s :%s\n" "Mobile" "$EXPO_PORT"+}++# Print a clear, scannable header before a service takes over the terminal, so+# it's obvious at a glance which service it is and which ports it's on.+banner() {+ local title="$1"; shift+ printf "\n%s%s%s\n" "$CYAN" "$RULE" "$NC"+ printf "%s ▶ %s%s %sinstance %s%s\n" "$BOLD" "$title" "$NC" "$DIM" "$AV_INSTANCE" "$NC"+ local line+ for line in "$@"; do+ printf " %s\n" "$line"+ done+ printf "%s%s%s\n\n" "$CYAN" "$RULE" "$NC"+}++require() { command -v "$1" >/dev/null 2>&1 || die "'$1' is required but not installed."; }++# Generate the Blazor client's dev config.+write_client_dev_settings() {+ local target="$ROOT_DIR/apps/server/AliasVault.Client/wwwroot/appsettings.Development.json"+ cat > "$target" <<JSON+{+ "ApiUrl": "http://localhost:$API_HTTP",+ "PrivateEmailDomains": ["example.tld", "example2.tld", "disabled.tld"],+ "HiddenPrivateEmailDomains": ["disabled.tld"],+ "SupportEmail": "[email protected]",+ "PublicRegistrationEnabled": "true",+ "UseDebugEncryptionKey": "$AV_USE_DEBUG_ENCRYPTION_KEY",+ "CryptographyOverrideType": "Argon2Id",+ "CryptographyOverrideSettings": "{\"DegreeOfParallelism\":1,\"MemorySize\":1024,\"Iterations\":1}"+}+JSON+ info "Wrote client dev config → ApiUrl http://localhost:$API_HTTP (UseDebugEncryptionKey=$AV_USE_DEBUG_ENCRYPTION_KEY)"+}++db_running() {+ [ -n "$(AV_DB_PORT="$DB_PORT" docker compose -f "$DB_COMPOSE" -p "$DB_PROJECT" ps --status running -q 2>/dev/null)" ]+}++start_db() {+ require docker+ banner "Database — $DB_PROJECT" "Postgres localhost:$DB_PORT"+ # --wait blocks until the container is healthy, so callers (and CI) can assume+ # the database is ready to accept connections once this returns.+ AV_DB_PORT="$DB_PORT" \+ docker compose -f "$DB_COMPOSE" -p "$DB_PROJECT" up -d --build --wait --wait-timeout 60+ info "Database ready: $CONN_STR"+}++stop_db() {+ require docker+ info "Stopping dev database '$DB_PROJECT' ..."+ AV_DB_PORT="$DB_PORT" \+ docker compose -f "$DB_COMPOSE" -p "$DB_PROJECT" down+}++# Toggle: stop the dev database if it's running, otherwise start it.+toggle_db() {+ require docker+ if db_running; then+ stop_db+ else+ start_db+ fi+}++# Run a .NET app with ports + DB driven by env/CLI flags.+run_dotnet() {+ local proj="$1" http="$2"+ require dotnet+ banner "$proj" \+ "HTTP http://localhost:$http" \+ "Database localhost:$DB_PORT"+ ASPNETCORE_ENVIRONMENT="Development" \+ ConnectionStrings__AliasServerDbContext="$CONN_STR" \+ dotnet watch --project "$ROOT_DIR/apps/server/$proj" --no-launch-profile \+ --urls "http://localhost:$http"+}++# Dev-only secrets. These are static fake values that are used only in dev.+DEV_JWT_KEY="${JWT_KEY:-12345678901234567890123456789012}"+DEV_DATA_PROTECTION_CERT_PASS="${DATA_PROTECTION_CERT_PASS:-Development}"+DEV_ADMIN_PASSWORD_HASH="${ADMIN_PASSWORD_HASH:-AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag==}"+DEV_ADMIN_PASSWORD_GENERATED="${ADMIN_PASSWORD_GENERATED:-2030-01-01T00:00:00Z}"+DEV_PRIVATE_EMAIL_DOMAINS="${PRIVATE_EMAIL_DOMAINS:-example.tld,example2.tld,aliasvault.net,disabled.tld}"+DEV_HIDDEN_PRIVATE_EMAIL_DOMAINS="${HIDDEN_PRIVATE_EMAIL_DOMAINS:-disabled.tld}"++start_api() {+ JWT_KEY="$DEV_JWT_KEY" \+ DATA_PROTECTION_CERT_PASS="$DEV_DATA_PROTECTION_CERT_PASS" \+ PUBLIC_REGISTRATION_ENABLED="true" \+ PRIVATE_EMAIL_DOMAINS="$DEV_PRIVATE_EMAIL_DOMAINS" \+ HIDDEN_PRIVATE_EMAIL_DOMAINS="$DEV_HIDDEN_PRIVATE_EMAIL_DOMAINS" \+ IP_LOGGING_ENABLED="true" \+ MAX_UPLOAD_SIZE_MB="100" \+ run_dotnet "AliasVault.Api" "$API_HTTP"+}+start_admin() {+ ADMIN_PASSWORD_HASH="$DEV_ADMIN_PASSWORD_HASH" \+ ADMIN_PASSWORD_GENERATED="$DEV_ADMIN_PASSWORD_GENERATED" \+ DATA_PROTECTION_CERT_PASS="$DEV_DATA_PROTECTION_CERT_PASS" \+ IP_LOGGING_ENABLED="true" \+ run_dotnet "AliasVault.Admin" "$ADMIN_HTTP"+}+start_client() {+ write_client_dev_settings+ run_dotnet "AliasVault.Client" "$CLIENT_HTTP"+}++# Background workers (no HTTP port).+run_worker() {+ local proj="$1"+ require dotnet+ banner "$proj (worker)" "Database localhost:$DB_PORT"+ ConnectionStrings__AliasServerDbContext="$CONN_STR" \+ dotnet watch --project "$ROOT_DIR/apps/server/$proj"+}+start_smtp() { run_worker "Services/AliasVault.SmtpService"; }+start_taskrunner() { run_worker "Services/AliasVault.TaskRunner"; }++start_ext() {+ require npm+ banner "Browser extension (Chrome dev)" \+ "Dev server http://localhost:$EXT_PORT" \+ "API http://localhost:$API_HTTP"+ cd "$ROOT_DIR/apps/browser-extension"+ VITE_DEFAULT_API_URL="http://localhost:$API_HTTP" \+ npm run dev:chrome -- --port "$EXT_PORT"+}++start_mobile() {+ require npx+ banner "Mobile app (Expo)" \+ "Metro http://localhost:$EXPO_PORT" \+ "API http://localhost:$API_HTTP"+ cd "$ROOT_DIR/apps/mobile-app"+ EXPO_PUBLIC_API_URL="http://localhost:$API_HTTP" \+ npx expo start --port "$EXPO_PORT"+}++# --- Interactive menu ----------------------------------------------------------+menu() {+ print_ports+ printf "\n%sWhich app do you want to start?%s\n" "$BOLD" "$NC"+ # Quick live check so the DB entry shows the action it'll take + current state.+ local db_label+ if db_running; then+ db_label="Stop dev DB ${GREEN}(running)${NC}"+ else+ db_label="Start dev DB ${DIM}(stopped)${NC}"+ fi+ local options=(+ "api:API"+ "client:Client"+ "admin:Admin"+ "ext:Browser extension"+ "mobile:Mobile (Expo)"+ "db:$db_label"+ )+ local i=1+ for o in "${options[@]}"; do+ printf " %s%2d%s) %s\n" "$CYAN" "$i" "$NC" "${o#*:}"; i=$((i+1))+ done+ printf "%sSelect [1-%d]:%s " "$BOLD" "${#options[@]}" "$NC"+ local choice; read -r choice+ case "$choice" in (*[!0-9]*|"") die "Invalid selection.";; esac+ [ "$choice" -ge 1 ] && [ "$choice" -le "${#options[@]}" ] || die "Selection out of range."+ local picked="${options[$((choice-1))]}"+ dispatch "${picked%%:*}"+}++# --- Dispatch ------------------------------------------------------------------+dispatch() {+ case "${1:-}" in+ api) start_api ;;+ client) start_client ;;+ admin) start_admin ;;+ smtp) start_smtp ;;+ taskrunner) start_taskrunner ;;+ ext) start_ext ;;+ mobile) start_mobile ;;+ db) toggle_db ;;+ db-start) start_db ;;+ db-stop) stop_db ;;+ ports) print_ports ;;+ quit|q) exit 0 ;;+ "") menu ;;+ -h|--help|help) sed -n '2,25p' "$0" | sed 's/^# \{0,1\}//' ;;+ *) die "Unknown command '$1'.+ start: api/client/admin/smtp/taskrunner/ext/mobile+ db: db (toggle) / db-start / db-stop" ;;+ esac+}++dispatch "${1:-}"