Skip to content

Commit

Permalink
Updated packager
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractMelon committed May 2, 2024
1 parent 8c0e90c commit a51a07e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
16 changes: 16 additions & 0 deletions thunderstore-packager/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ <h2>Edit README.md</h2>

<br><br><br>

<div class="form-group">
<label for="dependencies">Dependencies:</label>
<input type="text" id="dependencies" name="dependencies" placeholder="Enter dependencies separated by commas">
</div>

<br>

<form id="uploadForm" enctype="multipart/form-data">
<div class="form-group">
<label for="dllFile">Upload .dll file:</label>
Expand All @@ -45,6 +52,15 @@ <h2>Edit README.md</h2>
</div>
</form>



<br>

<input type="file" id="importFile" accept=".zip">
<button id="importBtn">Import .zip</button>

<br><br><br>

<button id="packageBtn">Package Your File</button>
</div>

Expand Down
38 changes: 35 additions & 3 deletions thunderstore-packager/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ 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 = {
"name": name,
"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
Expand Down Expand Up @@ -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 || "";
});
});
});

0 comments on commit a51a07e

Please sign in to comment.