script_engine/build.sh

42 lines
1.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# script_engine 模块构建脚本(由宿主应用 build.sh 集成调用)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -d "$SCRIPT_DIR/models" ]; then
if command -v json2ddl >/dev/null 2>&1; then
json2ddl mysql "$SCRIPT_DIR/models" > "$SCRIPT_DIR/models/mysql.ddl.sql"
else
echo "[script_engine] json2ddl 不可用,跳过 DDL 生成"
fi
fi
if [ -d "$SCRIPT_DIR/json" ]; then
if command -v xls2ui >/dev/null 2>&1; then
(cd "$SCRIPT_DIR" && xls2ui -m models -o wwwroot script_engine json/*.json)
else
echo "[script_engine] xls2ui 不可用,跳过 CRUD UI 生成"
fi
fi
SAGE_ROOT=""
for candidate in "$SCRIPT_DIR/../.." "$HOME/repos/sage" "$HOME/sage"; do
if [ -d "$candidate/wwwroot" ] && [ -d "$candidate/py3/bin" ]; then
SAGE_ROOT="$(cd "$candidate" && pwd)"
break
fi
done
if [ -n "$SAGE_ROOT" ]; then
mkdir -p "$SAGE_ROOT/wwwroot/script_engine"
ln -sfn "$SCRIPT_DIR/wwwroot/index.ui" "$SAGE_ROOT/wwwroot/script_engine/index.ui"
mkdir -p "$SAGE_ROOT/wwwroot/script_engine/api"
for f in "$SCRIPT_DIR"/wwwroot/api/*.dspy; do
ln -sfn "$f" "$SAGE_ROOT/wwwroot/script_engine/api/$(basename "$f")"
done
echo "[script_engine] wwwroot 已链接到 $SAGE_ROOT/wwwroot/script_engine"
else
echo "[script_engine] 未找到宿主 wwwroot跳过链接"
fi
echo "[script_engine] build.sh 完成"