#!/bin/sh
set -eu

project=/workspace/zhct/zhctproject/store
harness=/workspace/zhct/zhctprompt/work/2026-09-28-smart-canteen-dm8-poc/http-harness
target=$(mktemp -d /tmp/zhct-http-store-mysql.XXXXXX)

tar -C "$project" --exclude='._*' -cf - application | tar -C "$target" -xf -
ln -s "$project/thinkphp" "$target/thinkphp"
ln -s "$project/vendor" "$target/vendor"
ln -s "$project/extend" "$target/extend"
mkdir -p "$target/public" "$target/application/config/poc"
cp "$harness/store/env.php" "$target/env.php"
cp "$project/version.json" "$target/version.json"
cp "$harness/store/external_stubs.php" "$target/external_stubs.php"
cp "$harness/store/public/index.php" "$target/public/index.php"
cp "$harness/store/public/router.php" "$target/public/router.php"
cp "$harness/store/application/config/poc/config.php" "$target/application/config/poc/config.php"
mkdir -p "$target/application/config/local"
if [ -f "$target/application/config/local/config.php" ]; then
    mv "$target/application/config/local/config.php" "$target/application/config/local/config.php.poc-backup"
fi
cp "$harness/store/application/config/local/config.php" "$target/application/config/local/config.php"
cp "$harness/store-mysql/application/database.php" "$target/application/database.php"
cp "$harness/store/application/cores/database/FaultMysql.php" "$target/application/cores/database/FaultMysql.php"
printf '%s\n' "$target"
