Files
cocos/tools/deploy-local.sh
刘宇飞 d393302388 Complete Cocos Creator port with level bundles, themes, and tooling.
Adds level prefabs, theme assets, audio, extensions, and deployment scripts for the Unity WebGL migration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 15:30:58 +08:00

73 lines
2.1 KiB
Bash
Executable File
Raw Permalink 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
# 本地部署:与 CDN 相同包结构 → 同步到 scratch-gui/static/unity
#
# bash tools/deploy-local.sh
# bash tools/deploy-local.sh --skip-verify
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
BUILD_DIR="$PROJECT_DIR/build/web-desktop"
PACK_DIR="$PROJECT_DIR/build/mstest5"
CODE_HTML="${CODE_HTML:-$HOME/tfrh/001code/001code-html}"
UNITY_REF="${UNITY_REF:-$HOME/tfrh/竞赛/mstest5}"
SKIP_VERIFY=0
usage() {
cat <<'EOF'
本地部署usecdn:false / npm start
与 CDN 使用同一打包逻辑package-for-cdn目录结构一致
Build/mstest5.loader.js
StreamingAssets/aa/WebGL/*.bundle
levels-database.json(.br)
区别仅在于加载方式:本地从 /unity/ 读取CDN 从 unitycdndir 读取。
前置: Cocos Creator 已重新构建 Web Desktop含 level-prefabs 分包)
选项:
--build DIR
--code-html DIR
--unity-ref DIR Unity 参考包(默认 ~/tfrh/竞赛/mstest5
--skip-verify
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--build) BUILD_DIR="$2"; shift 2 ;;
--code-html) CODE_HTML="$2"; shift 2 ;;
--unity-ref) UNITY_REF="$2"; shift 2 ;;
--skip-verify) SKIP_VERIFY=1; shift ;;
-h|--help) usage; exit 0 ;;
*) echo "未知参数: $1" >&2; usage; exit 1 ;;
esac
done
if [[ "$SKIP_VERIFY" -eq 0 ]]; then
bash "$SCRIPT_DIR/verify-split-build.sh" "$BUILD_DIR"
fi
BUILD_DIR="$(cd "$BUILD_DIR" && pwd)"
UNITY_REF="$(cd "$UNITY_REF" && pwd)"
UNITY_STATIC="$CODE_HTML/scratch-gui/static/unity"
if [[ ! -f "$UNITY_REF/index.html" || ! -f "$UNITY_REF/StreamingAssets/aa/catalog.json" ]]; then
echo "错误: Unity 参考包无效: $UNITY_REF" >&2
exit 1
fi
echo "==> [1/2] 打包(与 CDN 相同结构)"
node "$SCRIPT_DIR/package-for-cdn.js" "$BUILD_DIR" "$PACK_DIR" "$UNITY_REF"
echo "==> [2/2] 导入 static/unity"
bash "$SCRIPT_DIR/sync-unity-package-to-static.sh" "$PACK_DIR" "$UNITY_STATIC"
echo ""
echo "==> 完成"
echo " cd \"$CODE_HTML/scratch-gui\" && npm start"
echo " http://localhost:8601/editor.html 或 cocos-smoke.htmlCmd+Shift+R"
echo ""
echo "config.js: usecdn: false"