From e5840012bae4aed77efcf0b17784b45d48baaf81 Mon Sep 17 00:00:00 2001 From: ChiaraBm Date: Tue, 15 Apr 2025 12:20:54 +0200 Subject: [PATCH] Added build script for creating installable versions --- .gitignore | 5 ++++- build.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ plugin.json | 11 ++++++++-- 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 5ad737b..4f55ca1 100644 --- a/.gitignore +++ b/.gitignore @@ -431,4 +431,7 @@ finalPackages/ nupkgs/ # Local daemon tests -**/data/volumes/** \ No newline at end of file +**/data/volumes/** + +# Local plugin build +tmp/ \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..d3ddb84 --- /dev/null +++ b/build.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Define paths +PLUGIN_FILE="plugin.json" +TMP_DIR="./tmp" +WWWROOT_DIR="$TMP_DIR/wwwroot" +ASSEMBLY_BASE_DIR="./MoonlightServers.ApiServer/bin/Debug/net8.0" +STATIC_BASE_DIR="./MoonlightServers.Frontend/wwwroot" + +# Create tmp and wwwroot directories +mkdir -p "$TMP_DIR" +mkdir -p "$WWWROOT_DIR" + +# Function to copy files with preserved structure +copy_files_with_structure() { + local base_dir=$1 + local jq_query=$2 + local dest_root=$3 + local file_type=$4 + + echo "Copying $file_type..." + jq -r "$jq_query[]" "$PLUGIN_FILE" | while read -r rel_path; do + src_path="$base_dir/$rel_path" + dest_path="$dest_root/$rel_path" + + if [ -f "$src_path" ]; then + mkdir -p "$(dirname "$dest_path")" + cp "$src_path" "$dest_path" + echo "Copied $src_path -> $dest_path" + else + echo "Warning: $src_path not found" + fi + done +} + +# Copy assemblies to tmp root +copy_files_with_structure "$ASSEMBLY_BASE_DIR" ".assemblies.apiServer" "$TMP_DIR" "apiServer assemblies" +copy_files_with_structure "$ASSEMBLY_BASE_DIR" ".assemblies.client" "$TMP_DIR" "client assemblies" + +# Copy static files to tmp/wwwroot +copy_files_with_structure "$STATIC_BASE_DIR" ".bundledStyles" "$WWWROOT_DIR" "bundled styles" +copy_files_with_structure "$STATIC_BASE_DIR" ".scripts" "$WWWROOT_DIR" "scripts" + +# Copy the plugin.json into tmp +cp "$PLUGIN_FILE" "$TMP_DIR/plugin.json" +echo "Copied $PLUGIN_FILE to $TMP_DIR/plugin.json" + +# Extract name from plugin.json for the zip file +PLUGIN_NAME=$(jq -r '.name' "$PLUGIN_FILE") +ZIP_NAME="${PLUGIN_NAME}.zip" + +# Create zip file (placed next to plugin.json) +echo "Creating zip file: $ZIP_NAME" +(cd "$TMP_DIR" && zip -r "../$ZIP_NAME" .) + +# Cleanup +rm -rf "$TMP_DIR" +echo "Cleaned up tmp directory." + +echo "Done! Created $ZIP_NAME" \ No newline at end of file diff --git a/plugin.json b/plugin.json index 8e63bf6..d450b19 100644 --- a/plugin.json +++ b/plugin.json @@ -3,8 +3,15 @@ "name": "Servers", "author": "Moonlight-Panel/Servers contributors", "assemblies": { - "apiServer": ["MoonlightServers.ApiServer.dll"], - "client": ["MoonlightServers.Client.dll"] + "apiServer": [ + "MoonlightServers.ApiServer.dll", + "MoonlightServers.DaemonShared.dll", + "MoonlightServers.Shared.dll" + ], + "client": [ + "MoonlightServers.Frontend.dll", + "MoonlightServers.Shared.dll" + ] }, "bundledStyles": [ "css/MoonlightServers.min.css",