105 lines
2.5 KiB
Bash
Executable file
105 lines
2.5 KiB
Bash
Executable file
version=$(grep "version=" module/module.prop | cut -d "=" -f 2)
|
|
|
|
echo "BeeSrv ZIP Builder"
|
|
echo "=================="
|
|
echo ""
|
|
|
|
# Check if zip is installed
|
|
if ! command -v zip &> /dev/null; then
|
|
echo "[!] zip is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if bun is installed
|
|
if ! command -v bun &> /dev/null; then
|
|
echo "[!] bun is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if filename to be created already exists
|
|
if [ -f "BeeSrv-$version.zip" ] || [ -f "BeeSrv-$version-debug.zip" ]; then
|
|
echo "[i] BeeSrv zip files already exist, would you like to overwrite them? (y/n)"
|
|
read overwrite
|
|
if [ "$overwrite" != "y" ]; then
|
|
echo "[!] Aborting..."
|
|
exit 1
|
|
else
|
|
rm -rf BeeSrv-$version.zip BeeSrv-$version-debug.zip
|
|
echo "[✔] Overwriting existing zip files..."
|
|
fi
|
|
fi
|
|
|
|
# Check for leftover tmp dir
|
|
if [ -d "tmp" ]; then
|
|
echo "[i] tmp directory already exists, would you like to overwrite it? (y/n)"
|
|
read overwrite
|
|
if [ "$overwrite" != "y" ]; then
|
|
echo "[!] Aborting..."
|
|
exit 1
|
|
else
|
|
rm -rf tmp
|
|
fi
|
|
fi
|
|
|
|
# Copy module to tmp
|
|
cp -r module tmp
|
|
echo "[✔] Created working directory"
|
|
|
|
# Clean any unnecessary files
|
|
rm -rf tmp/webroot/dist
|
|
rm -rf tmp/webroot/.gitignore
|
|
rm -rf tmp/webroot/package-lock.json
|
|
echo "[✔] Completed cleanup"
|
|
|
|
# Build webroot
|
|
echo "[i] Building webroot..."
|
|
cd tmp/webroot
|
|
echo "[i] Installing dependencies..."
|
|
bun install
|
|
echo ""
|
|
echo "[✔] Installed dependencies"
|
|
echo ""
|
|
echo "[i] Building with parcel..."
|
|
echo ""
|
|
bunx parcel build src/index.html
|
|
echo ""
|
|
echo "[✔] Built webroot"
|
|
|
|
# Clean up for zip
|
|
rm -rf .parcel-cache
|
|
rm -rf src
|
|
rm -rf node_modules
|
|
rm bun.lock*
|
|
rm package*
|
|
rm .gitignore
|
|
echo "[✔] Completed cleanup"
|
|
|
|
# Move built files to webroot
|
|
cd ..
|
|
cp -r webroot/dist/* webroot
|
|
echo "[✔] Moved built files to webroot"
|
|
|
|
# Remove build dir
|
|
rm -rf webroot/dist
|
|
echo "[✔] Completed cleanup"
|
|
|
|
echo "[i] Creating debug zip..."
|
|
zip -r ../BeeSrv-$version-debug.zip *
|
|
echo "[✔] Created debug zip"
|
|
|
|
echo "[i] Removing eruda scripts for production version..."
|
|
sed -i '/<script src="https:\/\/cdn\.jsdelivr\.net\/npm\/eruda"><\/script>/d' webroot/index.html
|
|
sed -i '/<script>eruda\.init();<\/script>/d' webroot/index.html
|
|
echo "[✔] Removed eruda scripts"
|
|
|
|
echo "[i] Creating production zip..."
|
|
zip -r ../BeeSrv-$version.zip *
|
|
cd ..
|
|
echo "[✔] Created production zip"
|
|
|
|
# Clean up
|
|
rm -rf tmp
|
|
echo "[✔] Completed cleanup"
|
|
|
|
echo ""
|
|
echo "BeeSrv-$version.zip and BeeSrv-$version-debug.zip created successfully!"
|