Created
October 29, 2025 22:33
-
-
Save Be1zebub/826816f8393b73b8c8a705a202db4bca to your computer and use it in GitHub Desktop.
npm run release to generate .zip for your release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { readdir, readFile, stat, writeFile } from "fs/promises" | |
| import JSZip from "jszip" | |
| import { join } from "path" | |
| const addonName = "one-chat" | |
| const contents = [ | |
| "lua", | |
| "materials", | |
| "resource", | |
| "localization.csv", | |
| "readme.txt", | |
| "version.txt", | |
| ] | |
| async function addFolderToZip(zip, folderPath, zipPath = "") { | |
| const entries = await readdir(folderPath, { withFileTypes: true }) | |
| for (const entry of entries) { | |
| const fullPath = join(folderPath, entry.name) | |
| const zipEntryPath = zipPath ? `${zipPath}/${entry.name}` : entry.name | |
| if (entry.isDirectory()) { | |
| const subfolder = zip.folder(entry.name) | |
| await addFolderToZip(subfolder, fullPath, zipEntryPath) | |
| } else { | |
| const data = await readFile(fullPath) | |
| zip.file(entry.name, data) | |
| } | |
| } | |
| } | |
| async function main() { | |
| const version = await readFile("version.txt", "utf8") | |
| const versionName = version.trim().split(" - ")[0] | |
| const zip = new JSZip() | |
| const dir = zip.folder(`one-chat-${versionName}`) | |
| for (const name of contents) { | |
| const dirStat = await stat(name) | |
| if (dirStat.isDirectory()) { | |
| const subdir = dir.folder(name) | |
| await addFolderToZip(subdir, name) | |
| } else { | |
| const data = await readFile(name) | |
| dir.file(name, data) | |
| } | |
| } | |
| const zipBuffer = await zip.generateAsync({ type: "nodebuffer" }) | |
| await writeFile(`${addonName}-${versionName}.zip`, zipBuffer) | |
| } | |
| main().catch(console.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment