1
0
forked from baron/baron-sso
Files
baron-sso/test/frontend_dev_bind_mount_policy_test.sh

48 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="$ROOT_DIR/docker-compose.yaml"
fail() {
echo "ERROR: $*" >&2
exit 1
}
assert_contains() {
local pattern="$1"
grep -Fq -- "$pattern" "$COMPOSE_FILE" || fail "docker-compose.yaml must contain: $pattern"
}
assert_not_contains() {
local pattern="$1"
if grep -Fq -- "$pattern" "$COMPOSE_FILE"; then
fail "docker-compose.yaml must not contain stale frontend mount: $pattern"
fi
}
for app in adminfront devfront orgfront; do
assert_contains "./$app:/workspace/$app"
assert_contains "/workspace/$app/node_modules"
assert_not_contains "./$app:/app"
done
assert_contains "./common:/workspace/common"
assert_contains "/workspace/common/node_modules"
assert_contains "./locales:/workspace/locales"
for runtime in \
"$ROOT_DIR/adminfront/scripts/runtime-mode.sh" \
"$ROOT_DIR/devfront/scripts/runtime-mode.sh" \
"$ROOT_DIR/orgfront/scripts/runtime-mode.sh"
do
grep -Fq -- "/workspace/common" "$runtime" || fail "$runtime must install dependencies from /workspace/common"
grep -Fq -- "pnpm install --filter" "$runtime" || fail "$runtime must install only its workspace slice"
grep -Fq -- "--frozen-lockfile --ignore-scripts" "$runtime" || fail "$runtime must preserve the workspace lockfile with pnpm"
if grep -Fq -- "npm install --no-workspaces" "$runtime"; then
fail "$runtime must not install common dependencies outside the workspace graph"
fi
done
echo "OK: frontend dev containers bind-mount source into Dockerfile WORKDIR paths"