Rename bmod to just mod
This commit is contained in:
@@ -9,13 +9,13 @@ import { sha256 } from "./common/utils.ts";
|
||||
import { createCanvas, loadImage } from "@gfx/canvas-wasm";
|
||||
import { ENGINE_TEXTURE_DIR, load_and_check, load_order, LoadedMod } from "./tools/check_mods.ts";
|
||||
import { pack_mod } from "./tools/pack_mod.ts";
|
||||
import { BMOD_EXTENSION } from "./common/bmod.ts";
|
||||
import { MOD_EXTENSION } from "./common/mod.ts";
|
||||
import { ENGINE_TEXTURES_INDEX } from "./server/host.ts";
|
||||
|
||||
// all overridable so tests can build somewhere else
|
||||
const BUILD_FOLDER = Deno.env.get("BUILD_DIR") ?? "build";
|
||||
const MODS_FOLDER = Deno.env.get("MODS_DIR") ?? "mods";
|
||||
// where the server loads .bmod files from. the build puts every mod in mods/ there, next to any others
|
||||
// where the server loads .cubi files from. the build puts every mod in mods/ there, next to any others
|
||||
const SERVER_MODS_FOLDER = Deno.env.get("SERVER_MODS_DIR") ?? "server_mods";
|
||||
|
||||
function clear_folder(folder: string) {
|
||||
@@ -104,17 +104,17 @@ function load_mods(): LoadedMod[] {
|
||||
return load_order(mods);
|
||||
}
|
||||
|
||||
// every mod in mods/ into server_mods/<id>.bmod. other .bmod files there are left alone, they're other people's mods
|
||||
// every mod in mods/ into server_mods/<id>.cubi. other .cubi files there are left alone, they're other people's mods
|
||||
async function build_mods(mods: LoadedMod[]) {
|
||||
Deno.mkdirSync(SERVER_MODS_FOLDER, { recursive: true });
|
||||
remove_old_format();
|
||||
for (const mod of mods) {
|
||||
Deno.writeFileSync(`${SERVER_MODS_FOLDER}/${mod.id}${BMOD_EXTENSION}`, await pack_mod(mod));
|
||||
Deno.writeFileSync(`${SERVER_MODS_FOLDER}/${mod.id}${MOD_EXTENSION}`, await pack_mod(mod));
|
||||
}
|
||||
console.log(`Mods: ${mods.map((m) => m.id).join(", ") || "none"}`);
|
||||
}
|
||||
|
||||
// builds before .bmod files put each mod's server script in a folder here with an index.json
|
||||
// builds before .cubi files put each mod's server script in a folder here with an index.json
|
||||
function remove_old_format() {
|
||||
for (const entry of Deno.readDirSync(SERVER_MODS_FOLDER)) {
|
||||
if (entry.isDirectory || entry.name === "index.json") {
|
||||
@@ -153,7 +153,7 @@ async function build() {
|
||||
try {
|
||||
const now = performance.now();
|
||||
clear_folder(BUILD_FOLDER);
|
||||
// checked first: a mod with errors stops the build before any .bmod is written
|
||||
// checked first: a mod with errors stops the build before any .cubi is written
|
||||
const mods = load_mods();
|
||||
await build_assets();
|
||||
await build_client();
|
||||
|
||||
Reference in New Issue
Block a user