forked from baron/baron-sso
52 lines
1.9 KiB
Bash
52 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
fail() {
|
|
echo "ERROR: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
assert_contains() {
|
|
local file="$1"
|
|
local pattern="$2"
|
|
grep -Fq -- "$pattern" "$file" || fail "$file must contain: $pattern"
|
|
}
|
|
|
|
assert_not_contains() {
|
|
local file="$1"
|
|
local pattern="$2"
|
|
if grep -Fq -- "$pattern" "$file"; then
|
|
fail "$file must not contain: $pattern"
|
|
fi
|
|
}
|
|
|
|
admin_config="$ROOT_DIR/adminfront/playwright.config.ts"
|
|
dev_config="$ROOT_DIR/devfront/playwright.config.ts"
|
|
org_config="$ROOT_DIR/orgfront/playwright.config.ts"
|
|
|
|
for file in "$admin_config" "$dev_config" "$org_config"; do
|
|
assert_contains "$file" 'process.env.CI === "true" || process.env.PLAYWRIGHT_USE_PREVIEW === "true"'
|
|
assert_contains "$file" "usePreviewServer"
|
|
done
|
|
|
|
assert_contains "$admin_config" 'process.env.PORT ?? "5173"'
|
|
assert_contains "$admin_config" 'pnpm exec vite --host 127.0.0.1 --port ${port} --strictPort'
|
|
assert_contains "$admin_config" 'pnpm exec vite preview --host 127.0.0.1 --port ${port} --strictPort'
|
|
|
|
assert_contains "$dev_config" 'process.env.PORT ?? "5174"'
|
|
assert_contains "$dev_config" 'process.env.PLAYWRIGHT_BASE_URL || process.env.BASE_URL'
|
|
assert_contains "$dev_config" '|| defaultBaseUrl'
|
|
assert_contains "$dev_config" './node_modules/.bin/vite --host 127.0.0.1 --strictPort --port ${port}'
|
|
assert_contains "$dev_config" './node_modules/.bin/vite preview --host 127.0.0.1 --strictPort --port ${port}'
|
|
assert_not_contains "$dev_config" "http://127.0.0.1:4174"
|
|
assert_not_contains "$dev_config" "--port 4174"
|
|
|
|
assert_contains "$org_config" 'process.env.PORT ?? "5175"'
|
|
assert_contains "$org_config" 'npm run dev -- --host 127.0.0.1 --port ${port}'
|
|
assert_contains "$org_config" 'npm run preview -- --host 127.0.0.1 --port ${port}'
|
|
assert_not_contains "$org_config" 'process.env.PORT ?? "4175"'
|
|
|
|
echo "OK: local Playwright uses Vite dev servers and CI/preview mode uses dist preview"
|