64 行
2.6 KiB
Bash
可执行文件
64 行
2.6 KiB
Bash
可执行文件
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
cd "$ROOT"
|
|
usage() {
|
|
cat <<'HELP'
|
|
Usage: check.sh MODE [scope]
|
|
--backend MODULES [TEST] Maven tests; optional Surefire class/method pattern
|
|
--backend-build MODULES Maven package (including tests), no clean/install
|
|
--frontend [PATH...] Lint selected paths relative to aixun-ui, or all src
|
|
--frontend-build Frontend production build
|
|
--files PATH... Syntax and secret checks for explicit text files
|
|
--full Explicit Maven verify + frontend lint/build; no reinstall
|
|
--runtime [SERVICE] Target config check; omit service for bootstrap preflight
|
|
No default full scan. Include downstream consumers when a shared contract changes.
|
|
HELP
|
|
}
|
|
mode="${1:---help}"; [[ $# -eq 0 ]] || shift
|
|
case "$mode" in
|
|
--backend|--backend-build)
|
|
[[ $# -ge 1 && $# -le 2 && "$1" != -* ]] || { usage >&2; exit 2; }
|
|
modules="$1"; shift
|
|
goal=test; [[ "$mode" != --backend-build ]] || goal=package
|
|
extra=()
|
|
if [[ $# -eq 1 ]]; then
|
|
[[ "$mode" == --backend && -n "$1" && "$1" != -* ]] || { usage >&2; exit 2; }
|
|
extra=("-Dtest=$1" -Dsurefire.failIfNoSpecifiedTests=false)
|
|
# Dependency modules may have no matching test. Require a real positive
|
|
# Surefire count somewhere in this invocation, so typos cannot pass green.
|
|
./mvnw -B -pl "$modules" -am "$goal" "${extra[@]}" | awk '
|
|
/Tests run: [1-9][0-9]*/ { ran = 1 }
|
|
{ print }
|
|
END { if (!ran) { print "No executed tests observed for the selected pattern; not PASS." > "/dev/stderr"; exit 2 } }
|
|
'
|
|
exit
|
|
fi
|
|
exec ./mvnw -B -pl "$modules" -am "$goal" ${extra[@]+"${extra[@]}"}
|
|
;;
|
|
--frontend|--frontend-build)
|
|
[[ "$mode" == --frontend || $# -eq 0 ]] || { usage >&2; exit 2; }
|
|
source script/toolchain/bootstrap-node.sh
|
|
[[ -d aixun-ui/node_modules ]] || { echo 'Missing dependencies: run pnpm --dir aixun-ui install --frozen-lockfile once.' >&2; exit 2; }
|
|
if [[ "$mode" == --frontend ]]; then
|
|
if [[ $# -eq 0 ]]; then pnpm --dir aixun-ui lint; else pnpm --dir aixun-ui exec oxlint -- "$@"; fi
|
|
else
|
|
pnpm --dir aixun-ui build:prod
|
|
fi
|
|
;;
|
|
--files) exec python3 script/quality/check-files.py "$@" ;;
|
|
--full)
|
|
[[ $# -eq 0 ]] || { usage >&2; exit 2; }
|
|
./mvnw -B verify
|
|
"$0" --frontend
|
|
"$0" --frontend-build
|
|
;;
|
|
--runtime)
|
|
[[ $# -le 1 ]] || { usage >&2; exit 2; }
|
|
if [[ $# -eq 1 ]]; then exec ./script/datagov/deploy.sh --check-config "$1"; fi
|
|
exec ./script/datagov/preflight.sh
|
|
;;
|
|
--help|-h) usage ;;
|
|
*) usage >&2; exit 2 ;;
|
|
esac
|