-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
109 lines (92 loc) · 3.53 KB
/
build.sh
File metadata and controls
109 lines (92 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# ============================================================
# build.sh — Build & deploy FS25_SeasonalCropStress
# Usage:
# bash build.sh — builds zip only
# bash build.sh --deploy — builds zip AND copies to mods folder
# ============================================================
set -e
MOD_NAME="FS25_TaxMod"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT_DIR="$SCRIPT_DIR/.."
ZIP_PATH="$OUTPUT_DIR/${MOD_NAME}.zip"
# Windows path for mods folder (adjust if needed)
MODS_DIR="$USERPROFILE/Documents/My Games/FarmingSimulator2025/mods"
echo "============================================"
echo " Building $MOD_NAME"
echo "============================================"
# Remove old zip
if [ -f "$ZIP_PATH" ]; then
rm "$ZIP_PATH"
echo " Removed old zip"
fi
# Build new zip — must use forward slashes inside (FS25 requirement)
# PowerShell Compress-Archive creates backslash paths — use 'zip' or this python fallback
cd "$SCRIPT_DIR"
if command -v zip &>/dev/null; then
# Paths inside zip are relative to CWD (already cd'd to SCRIPT_DIR).
# Exclude patterns must use the same relative form.
zip -r "$ZIP_PATH" . \
--exclude "./*.sh" \
--exclude "./.claude/*" \
--exclude "./.git/*" \
--exclude "./*.md" \
--exclude "./.gitignore" \
--exclude "./__MACOSX/*" \
--exclude "./*.DS_Store" \
--exclude "./*.zip"
echo " Built via zip"
else
# Python fallback — try python3 first, then Windows launcher (py)
PYTHON_CMD=""
if command -v python3 &>/dev/null; then PYTHON_CMD="python3"
elif command -v py &>/dev/null; then PYTHON_CMD="py"
else echo "ERROR: no Python found (need python3 or py)"; exit 1
fi
$PYTHON_CMD - <<'PYEOF'
import zipfile, os, sys
MOD_DIR = os.getcwd()
ZIP_PATH = os.path.join(os.path.dirname(MOD_DIR), os.path.basename(MOD_DIR) + ".zip")
EXCLUDE_DIRS = {".git", ".claude", "__MACOSX"}
EXCLUDE_EXTS = {".sh", ".md", ".DS_Store", ".zip"}
EXCLUDE_FILES = {".gitignore"}
with zipfile.ZipFile(ZIP_PATH, "w", zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk(MOD_DIR):
# Prune excluded dirs in-place
dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
for fname in files:
if fname in EXCLUDE_FILES:
continue
if any(fname.endswith(ext) for ext in EXCLUDE_EXTS):
continue
full_path = os.path.join(root, fname)
# Paths relative to MOD_DIR → files land at ZIP root (not in a subfolder)
arc_name = os.path.relpath(full_path, MOD_DIR)
# Enforce forward slashes (FS25 requirement)
arc_name = arc_name.replace("\\", "/")
zf.write(full_path, arc_name)
print(f" + {arc_name}")
print(f"\n ZIP created: {ZIP_PATH}")
PYEOF
fi
echo ""
echo " Output: $ZIP_PATH"
# --deploy flag: copy zip to mods folder
if [[ "$1" == "--deploy" ]]; then
echo ""
echo " Deploying to mods folder..."
if [ ! -d "$MODS_DIR" ]; then
echo " WARNING: Mods folder not found at: $MODS_DIR"
echo " Edit MODS_DIR in build.sh if your path differs."
exit 1
fi
# Remove old deployed version
if [ -f "$MODS_DIR/${MOD_NAME}.zip" ]; then
rm "$MODS_DIR/${MOD_NAME}.zip"
fi
cp "$ZIP_PATH" "$MODS_DIR/${MOD_NAME}.zip"
echo " Deployed: $MODS_DIR/${MOD_NAME}.zip"
fi
echo ""
echo " Done. Check log.txt for [TaxMod] entries after launching."
echo "============================================"