From a51a07eafe0a444805d43cc2b619ff10bb42825f Mon Sep 17 00:00:00 2001
From: AbstractMelon <129030233+AbstractMelon@users.noreply.github.com>
Date: Wed, 1 May 2024 18:02:15 -0600
Subject: [PATCH] Updated packager
---
thunderstore-packager/index.html | 16 ++++++++++++++
thunderstore-packager/script.js | 38 +++++++++++++++++++++++++++++---
2 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/thunderstore-packager/index.html b/thunderstore-packager/index.html
index 7a33c00..decc41d 100644
--- a/thunderstore-packager/index.html
+++ b/thunderstore-packager/index.html
@@ -34,6 +34,13 @@
Edit README.md
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/thunderstore-packager/script.js b/thunderstore-packager/script.js
index 8ddfe69..a6a9dd0 100644
--- a/thunderstore-packager/script.js
+++ b/thunderstore-packager/script.js
@@ -7,6 +7,7 @@ packageBtn.addEventListener("click", function () {
const version = document.getElementById("version").value;
const website = document.getElementById("website").value;
const description = document.getElementById("description").value;
+ const dependencies = document.getElementById("dependencies").value.split(",").map(dep => dep.trim());
// Construct manifest object
const manifest = {
@@ -14,9 +15,7 @@ packageBtn.addEventListener("click", function () {
"version_number": version,
"website_url": website,
"description": description,
- "dependencies": [
- "BepInEx-BepInExPack-5.4.2100"
- ]
+ "dependencies": "BepInEx-BepInExPack-5.4.2100", dependencies
};
// Convert manifest object to JSON string
@@ -72,3 +71,36 @@ packageBtn.addEventListener("click", function () {
});
}
});
+
+
+
+// Add event listener for import button click
+document.getElementById("importBtn").addEventListener("click", function () {
+ // Get the selected .zip file
+ const importFile = document.getElementById("importFile").files[0];
+
+ // Create a new JSZip instance
+ const zip = new JSZip();
+
+ // Read the imported .zip file
+ zip.loadAsync(importFile).then(function (zipContents) {
+ // Extract the manifest.json and README.md files
+ const manifestContent = zipContents.file("manifest.json").async("string");
+ const readmeContent = zipContents.file("README.md").async("string");
+
+ // Once both files are read, continue processing
+ Promise.all([manifestContent, readmeContent]).then(function (values) {
+ const [manifestContent, readmeContent] = values;
+
+ // Parse manifest.json content
+ const manifest = JSON.parse(manifestContent);
+
+ // Populate form fields with imported data
+ document.getElementById("name").value = manifest.name || "";
+ document.getElementById("version").value = manifest.version_number || "";
+ document.getElementById("website").value = manifest.website_url || "";
+ document.getElementById("description").value = manifest.description || "";
+ document.getElementById("readme").value = readmeContent || "";
+ });
+ });
+});