entity/build.sh

30 lines
1.0 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
# entity 模块构建脚本:① 生成 DDL② xls2ui 生成 CRUD 前端;③ 链接 wwwroot 到宿主应用
# 用法build.sh <宿主应用 wwwroot 路径(可选)>
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# ① 表定义 -> DDL
if command -v json2ddl >/dev/null 2>&1; then
json2ddl mysql . > models/mysql.ddl.sql
echo "[entity] DDL generated: models/mysql.ddl.sql"
else
echo "[entity] json2ddl not found, skip DDL generation"
fi
# ② CRUD 定义 -> wwwroot生成 wwwroot/entity/ wwwroot/entity_import/ 等 CRUD 目录)
if command -v xls2ui >/dev/null 2>&1; then
xls2ui -m ../models -o ../wwwroot entity json/*.json
echo "[entity] CRUD UI generated"
else
echo "[entity] xls2ui not found, skip CRUD UI generation"
fi
# ③ 链接 wwwroot 到宿主应用
APP_WWWROOT="${1:-}"
if [ -n "$APP_WWWROOT" ] && [ -d "$APP_WWWROOT" ]; then
ln -sfn "$SCRIPT_DIR/wwwroot" "$APP_WWWROOT/entity"
echo "[entity] wwwroot linked -> $APP_WWWROOT/entity"
fi