mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-06 20:03:05 +08:00
* 🎨 style(DataGrid): 清理冗余代码与静态分析告警 - 类型重构:通过修正 React Context 的函数签名解决了 void 类型的链式调用错误 - 代码精简:利用 Nullish Coalescing (??) 优化组件配置项降级逻辑,剥离无意义的隐式 undefined 赋值 - 工具链适配:适配 IDE 拼写检查与 Promise strict rules,确保全文件零警 * 🔧 fix(db/kingbase_impl): 修复标识符无条件加双引号导致SQL语法报错 - quoteKingbaseIdent 改为条件引用,仅对大写字母、保留字、特殊字符的标识符添加双引号 - 新增 kingbaseIdentNeedsQuote 判断标识符是否需要引用 - 新增 isKingbaseReservedWord 检测常见SQL保留字 - 补充 TestQuoteKingbaseIdent、TestKingbaseIdentNeedsQuote 单测覆盖各场景 - refs #176 * 🔧 fix(release,db/kingbase_impl): 修复金仓默认 schema 并静默生成 DMG - Kingbase:在 current_schema() 为 public 时探测候选 schema,并通过 DSN search_path 重连,兼容未限定 schema 的查询 - 候选优先级:数据库名/用户名同名 schema(存在性校验),否则仅在“唯一用户 schema 有表”场景兜底 - 避免连接污染:每次 Connect 重置探测结果,重连成功后替换连接并关闭旧连接 - 打包脚本:create-dmg 增加 --sandbox-safe,避免构建时自动弹出/打开挂载窗口 - 产物格式:强制 --format UDZO,并将 rw.*.dmg/UDRW 中间产物转换为可分发 DMG - 校验门禁:增加 hdiutil verify,失败时保留 .app 便于排查,同时修正卷图标探测并补 ad-hoc 签名 * 🐛 fix(connection/redis): 修复 Redis URI 用户名处理导致认证失败 - Redis URI 解析回填 user 字段,兼容 redis://user:pass@... 与 redis://:pass@... - 生成 URI 时按需输出 user/password,避免丢失用户名信息 - Redis 类型默认用户名置空,并在构建配置时清理历史默认 root - 避免 go-redis 触发 ACL AUTH(user, pass) 导致 WRONGPASS - refs #212 * 🔧 fix(release,ssh): 修复 SSH 误判连接成功并纠正 DMG 打包结构 - SSH 缓存 key 纳入认证指纹(password/keyPath),避免改错凭证仍复用旧连接/端口转发 - MySQL/MariaDB/Doris:SSH 隧道建立失败直接返回错误,不再回退直连导致测试误判成功 - 新增最小单测覆盖 SSH cache key 与 UseSSH 异常路径 - build-release.sh:create-dmg 使用 staging 目录作为 source,避免 DMG 根目录变成 Contents - refs #213 * fix: KingBase 连接后自动设置 search_path,修复自定义 schema 下表查询报 relation does not exist 的问题 (#215) * 🔧 fix(driver/kingbase,mongodb): 修复外置驱动事务引用与连接测试链路问题 - 金仓外置驱动链路增加表名与变更字段归一化,修复 ApplyChanges 场景下双引号转义异常导致的 SQL 语法错误 - 新增金仓公共标识符工具并复用到 kingbase_impl 与 optional_driver_agent_impl,统一处理多重转义、schema.table 拆分与引用规范 - 金仓代理连接后自动探测并设置 search_path,降低查询时必须手写 schema 前缀的概率 - MongoDB 连接参数改为显式 host/hosts 优先,避免被 URI 中 localhost 覆盖;代理链路保留目标地址不再改写为本地地址 - 连接测试增加前后端超时收敛与日志增强,避免长时间转圈;连接错误文案在未启用 TLS 时移除误导性的“SSL”前缀 - 统一日志级别为 INFO/WARN/ERROR,默认日志目录收敛到 ~/.GoNavi/Logs,并补充驱动构建脚本 build-driver-agents.sh * 🔧 fix(release/sidebar): 统一跨平台UPX压缩并修复PG函数列表查询兼容性 - 构建脚本新增通用 UPX 压缩函数,覆盖 macOS、Linux、Windows 产物 - 本地打包改为强制压缩策略:未安装 upx、压缩失败或校验失败直接终止 - macOS 打包在签名前压缩 .app 主程序并执行 upx -t 校验 - Linux 打包在生成 tar.gz 前压缩可执行文件并执行 upx -t 校验 - GitHub Release 与测试构建流程补齐 macOS/Linux/Windows 的 upx 安装与压缩步骤 - PostgreSQL/PG-like 函数元数据查询增加多路兼容 SQL,修复函数列表不显示问题 - refs #221 - refs #222 --------- Co-authored-by: Syngnat <yangguofeng919@gmail.com> Co-authored-by: 凌封 <49424247+fengin@users.noreply.github.com>
229 lines
5.6 KiB
Bash
Executable File
229 lines
5.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
cd "$SCRIPT_DIR"
|
||
|
||
DEFAULT_DRIVERS=(mariadb doris sphinx sqlserver sqlite duckdb dameng kingbase highgo vastbase mongodb tdengine clickhouse)
|
||
|
||
usage() {
|
||
cat <<'EOF'
|
||
用法:
|
||
./build-driver-agents.sh [选项]
|
||
|
||
选项:
|
||
--drivers <列表> 指定驱动列表(逗号分隔),例如:kingbase,mongodb
|
||
--platform <GOOS/GOARCH>
|
||
目标平台,默认使用当前 Go 环境(go env GOOS/GOARCH)
|
||
--out-dir <目录> 输出目录根路径,默认:dist/driver-agents
|
||
--bundle-name <文件名> 驱动总包 zip 名称,默认:GoNavi-DriverAgents.zip
|
||
--strict 任一驱动构建失败即中断(默认失败后继续,最后汇总)
|
||
-h, --help 显示帮助
|
||
|
||
示例:
|
||
./build-driver-agents.sh
|
||
./build-driver-agents.sh --drivers kingbase
|
||
./build-driver-agents.sh --platform windows/amd64 --drivers kingbase,mongodb
|
||
EOF
|
||
}
|
||
|
||
normalize_driver() {
|
||
local name
|
||
name="$(echo "${1:-}" | tr '[:upper:]' '[:lower:]' | xargs)"
|
||
case "$name" in
|
||
doris|diros) echo "doris" ;;
|
||
mariadb|sphinx|sqlserver|sqlite|duckdb|dameng|kingbase|highgo|vastbase|mongodb|tdengine|clickhouse)
|
||
echo "$name"
|
||
;;
|
||
*)
|
||
return 1
|
||
;;
|
||
esac
|
||
}
|
||
|
||
build_driver_name() {
|
||
case "$1" in
|
||
doris) echo "diros" ;;
|
||
*) echo "$1" ;;
|
||
esac
|
||
}
|
||
|
||
platform_dir_name() {
|
||
case "$1" in
|
||
windows) echo "Windows" ;;
|
||
darwin) echo "MacOS" ;;
|
||
linux) echo "Linux" ;;
|
||
*) echo "Unknown" ;;
|
||
esac
|
||
}
|
||
|
||
driver_csv=""
|
||
target_platform=""
|
||
out_root="dist/driver-agents"
|
||
bundle_name="GoNavi-DriverAgents.zip"
|
||
strict_mode="false"
|
||
|
||
while [[ $# -gt 0 ]]; do
|
||
case "$1" in
|
||
--drivers)
|
||
driver_csv="${2:-}"
|
||
shift 2
|
||
;;
|
||
--platform)
|
||
target_platform="${2:-}"
|
||
shift 2
|
||
;;
|
||
--out-dir)
|
||
out_root="${2:-}"
|
||
shift 2
|
||
;;
|
||
--bundle-name)
|
||
bundle_name="${2:-}"
|
||
shift 2
|
||
;;
|
||
--strict)
|
||
strict_mode="true"
|
||
shift
|
||
;;
|
||
-h|--help)
|
||
usage
|
||
exit 0
|
||
;;
|
||
*)
|
||
echo "❌ 未知参数:$1"
|
||
usage
|
||
exit 1
|
||
;;
|
||
esac
|
||
done
|
||
|
||
if ! command -v go >/dev/null 2>&1; then
|
||
echo "❌ 未找到 Go,请先安装 Go 并确保 go 在 PATH 中。"
|
||
exit 1
|
||
fi
|
||
|
||
if [[ -z "$target_platform" ]]; then
|
||
target_platform="$(go env GOOS)/$(go env GOARCH)"
|
||
fi
|
||
|
||
if [[ "$target_platform" != */* ]]; then
|
||
echo "❌ --platform 参数格式错误,应为 GOOS/GOARCH,例如 darwin/arm64"
|
||
exit 1
|
||
fi
|
||
|
||
goos="${target_platform%%/*}"
|
||
goarch="${target_platform##*/}"
|
||
platform_key="${goos}-${goarch}"
|
||
platform_dir="$(platform_dir_name "$goos")"
|
||
|
||
declare -a drivers=()
|
||
if [[ -n "$driver_csv" ]]; then
|
||
IFS=',' read -r -a raw_drivers <<<"$driver_csv"
|
||
for item in "${raw_drivers[@]}"; do
|
||
normalized="$(normalize_driver "$item")" || {
|
||
echo "❌ 不支持的驱动:$item"
|
||
exit 1
|
||
}
|
||
drivers+=("$normalized")
|
||
done
|
||
else
|
||
drivers=("${DEFAULT_DRIVERS[@]}")
|
||
fi
|
||
|
||
output_dir="${out_root%/}/${platform_key}"
|
||
bundle_stage_dir="$(mktemp -d "${TMPDIR:-/tmp}/gonavi-driver-bundle.XXXXXX")"
|
||
bundle_platform_dir="$bundle_stage_dir/$platform_dir"
|
||
|
||
cleanup() {
|
||
rm -rf "$bundle_stage_dir"
|
||
}
|
||
trap cleanup EXIT
|
||
|
||
mkdir -p "$output_dir" "$bundle_platform_dir"
|
||
output_dir_abs="$(cd "$output_dir" && pwd)"
|
||
bundle_zip_path="$output_dir_abs/$bundle_name"
|
||
|
||
declare -a built_assets=()
|
||
declare -a failed_drivers=()
|
||
declare -a skipped_drivers=()
|
||
|
||
echo "🚀 开始构建 optional-driver-agent"
|
||
echo " 平台:$goos/$goarch"
|
||
echo " 输出目录:$output_dir_abs"
|
||
echo " 驱动列表:${drivers[*]}"
|
||
|
||
for driver in "${drivers[@]}"; do
|
||
if [[ "$driver" == "duckdb" && "$goos" == "windows" && "$goarch" != "amd64" ]]; then
|
||
echo "⚠️ 跳过 duckdb(仅支持 windows/amd64)"
|
||
skipped_drivers+=("$driver")
|
||
continue
|
||
fi
|
||
|
||
build_driver="$(build_driver_name "$driver")"
|
||
tag="gonavi_${build_driver}_driver"
|
||
asset_name="${driver}-driver-agent-${goos}-${goarch}"
|
||
if [[ "$goos" == "windows" ]]; then
|
||
asset_name="${asset_name}.exe"
|
||
fi
|
||
output_path="$output_dir_abs/$asset_name"
|
||
|
||
cgo_enabled=0
|
||
if [[ "$driver" == "duckdb" ]]; then
|
||
cgo_enabled=1
|
||
fi
|
||
|
||
echo "🔧 构建 $driver -> $asset_name (tag=$tag, CGO_ENABLED=$cgo_enabled)"
|
||
set +e
|
||
CGO_ENABLED="$cgo_enabled" GOOS="$goos" GOARCH="$goarch" GOTOOLCHAIN=auto \
|
||
go build -tags "$tag" -trimpath -ldflags "-s -w" -o "$output_path" ./cmd/optional-driver-agent
|
||
build_exit=$?
|
||
set -e
|
||
|
||
if [[ $build_exit -ne 0 ]]; then
|
||
echo "❌ 构建失败:$driver"
|
||
failed_drivers+=("$driver")
|
||
if [[ "$strict_mode" == "true" ]]; then
|
||
exit $build_exit
|
||
fi
|
||
continue
|
||
fi
|
||
|
||
cp "$output_path" "$bundle_platform_dir/$asset_name"
|
||
built_assets+=("$asset_name")
|
||
done
|
||
|
||
if [[ ${#built_assets[@]} -eq 0 ]]; then
|
||
echo "❌ 未成功构建任何驱动代理。"
|
||
exit 1
|
||
fi
|
||
|
||
rm -f "$bundle_zip_path"
|
||
if command -v zip >/dev/null 2>&1; then
|
||
(
|
||
cd "$bundle_stage_dir"
|
||
zip -qry "$bundle_zip_path" "$platform_dir"
|
||
)
|
||
elif command -v ditto >/dev/null 2>&1; then
|
||
(
|
||
cd "$bundle_stage_dir"
|
||
ditto -c -k --sequesterRsrc --keepParent "$platform_dir" "$bundle_zip_path"
|
||
)
|
||
else
|
||
echo "❌ 未找到 zip/ditto,无法生成驱动总包 zip。"
|
||
exit 1
|
||
fi
|
||
|
||
echo ""
|
||
echo "✅ 构建完成"
|
||
echo " 单文件输出目录:$output_dir_abs"
|
||
echo " 驱动总包:$bundle_zip_path"
|
||
echo " 已构建:${built_assets[*]}"
|
||
if [[ ${#skipped_drivers[@]} -gt 0 ]]; then
|
||
echo " 已跳过:${skipped_drivers[*]}"
|
||
fi
|
||
if [[ ${#failed_drivers[@]} -gt 0 ]]; then
|
||
echo "⚠️ 构建失败驱动:${failed_drivers[*]}"
|
||
exit 2
|
||
fi
|