-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmanage.sh
More file actions
executable file
·49 lines (42 loc) · 1.44 KB
/
manage.sh
File metadata and controls
executable file
·49 lines (42 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# 🛠️ SAGE 管理脚本入口
# 简化后的入口,主要用于 Git hooks 设置和项目维护
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MAINTENANCE_SCRIPT="$SCRIPT_DIR/tools/maintenance/sage-maintenance.sh"
if [ ! -f "$MAINTENANCE_SCRIPT" ]; then
echo "Maintenance script not found at $MAINTENANCE_SCRIPT" >&2
exit 1
fi
if [[ "$1" = "-h" || "$1" = "--help" ]]; then
echo "Usage: ./manage.sh [maintenance-command]"
echo ""
echo "Examples:"
echo " ./manage.sh # Setup Git hooks"
echo " ./manage.sh clean # Clean build artifacts"
echo " ./manage.sh doctor # Run health check"
echo ""
echo "This script forwards all arguments to tools/maintenance/sage-maintenance.sh."
exit 0
fi
# 无参数时默认设置 Git hooks
if [ $# -eq 0 ]; then
echo "Configuring Git hooks..."
if ! bash "$MAINTENANCE_SCRIPT" --force setup-hooks; then
echo "Git hooks setup failed" >&2
exit 1
fi
exit 0
fi
# Additional maintenance helpers
if [ "$1" = "clean-env" ] || [ "$1" = "uninstall" ]; then
# Provide a straightforward alias to the uninstall/cleanup helper
CLEAN_SCRIPT="$SCRIPT_DIR/tools/install/cleanup/uninstall_sage.sh"
if [ -f "$CLEAN_SCRIPT" ]; then
exec bash "$CLEAN_SCRIPT" "${@:2}"
else
echo "Cleanup script not found at $CLEAN_SCRIPT" >&2
exit 1
fi
fi
exec bash "$MAINTENANCE_SCRIPT" "$@"