pipeline-app/build.sh

89 lines
2.4 KiB
Bash

#!/usr/bin/env bash
set -e
cdir=$(cd "$(dirname "$0")" && pwd)
cd "$cdir"
echo "=== Pipeline App Build ==="
# 1. Create venv
if [ ! -d py3 ]; then
python3 -m venv py3
fi
source py3/bin/activate
# 2. Install foundation packages
mkdir -p pkgs
for m in apppublic sqlor ahserver bricks-for-python xls2ddl rbac appbase; do
echo "install $m ..."
cd "$cdir/pkgs"
if [ ! -d "$m" ]; then
git clone https://git.opencomputing.cn/yumoqing/$m || echo "SKIP: $m clone failed"
fi
if [ -d "$m" ]; then
cd "$m"
"$cdir/py3/bin/pip" install . 2>&1 | tail -1
fi
cd "$cdir"
done
# 3. Build bricks frontend
cd "$cdir/pkgs"
if [ ! -d bricks ]; then
git clone https://git.opencomputing.cn/yumoqing/bricks || true
fi
if [ -d bricks/bricks ]; then
cd bricks/bricks && bash build.sh 2>&1 | tail -3
ln -sf "$cdir/pkgs/bricks/dist" "$cdir/bricks"
fi
cd "$cdir"
# 4. Clone pipeline-sdlc and showcase
for m in pipeline-sdlc showcase; do
echo "clone $m ..."
cd "$cdir/pkgs"
if [ ! -d "$m" ]; then
git clone https://git.opencomputing.cn/yumoqing/$m || echo "SKIP: $m clone failed"
fi
# pipeline-sdlc goes to root (same as other business modules)
if [ "$m" = "pipeline-sdlc" ] && [ ! -d "$cdir/pipeline-sdlc" ]; then
ln -sf "$cdir/pkgs/pipeline-sdlc" "$cdir/pipeline-sdlc"
fi
cd "$cdir"
done
# 5. Install business modules
for mod in pipeline_core pipeline_ops pipeline_dist pipeline-sdlc; do
echo "install $mod ..."
cd "$cdir/$mod"
"$cdir/py3/bin/pip" install . 2>&1 | tail -1
# Generate DDL from models
if [ -d models ] && ls models/*.json >/dev/null 2>&1; then
"$cdir/py3/bin/json2ddl" mysql models/ > "$cdir/$mod/mysql.ddl.sql" 2>/dev/null || echo " DDL generation skipped (json2ddl not available)"
fi
# Generate CRUD UI from json definitions
if [ -d json ] && ls json/*.json >/dev/null 2>&1; then
cd json
for f in *.json; do
"$cdir/py3/bin/xls2ui" -m ../models -o ../wwwroot "$mod" "$f" 2>/dev/null || echo " CRUD generation skipped for $f"
done
cd ..
fi
cd "$cdir"
done
# 5b. Install showcase module
if [ -d "$cdir/pkgs/showcase" ]; then
echo "install showcase ..."
cd "$cdir/pkgs/showcase"
"$cdir/py3/bin/pip" install . 2>&1 | tail -1
cd "$cdir"
fi
# 6. Create runtime dirs
mkdir -p "$cdir/logs" "$cdir/files"
chmod +x "$cdir/start.sh" "$cdir/stop.sh"
echo "=== Build complete ==="