35 lines
914 B
TypeScript
35 lines
914 B
TypeScript
import type { BearMetalStore } from "@bearmetal/store";
|
|
|
|
export function getPackVersion(store: BearMetalStore) {
|
|
const packMeta = Deno.readTextFileSync(
|
|
store.get("packlocation") + "/pack.mcmeta",
|
|
);
|
|
const packMetaJson = JSON.parse(packMeta);
|
|
return packMetaJson.pack.pack_format as number;
|
|
}
|
|
|
|
export async function getDirName(version: number, path: string) {
|
|
const { default: versionData } = await import(
|
|
"../../pack_versions/" + version + ".json",
|
|
{
|
|
with: { type: "json" },
|
|
}
|
|
);
|
|
|
|
const singular = makeSingular(path);
|
|
const plural = makePlural(path);
|
|
|
|
console.log("versionData", versionData);
|
|
|
|
return versionData && versionData.schema.data["<namespace>"][singular] ||
|
|
versionData.schema.data["<namespace>"][plural];
|
|
}
|
|
|
|
function makeSingular(word: string) {
|
|
return word.replace(/s$/, "");
|
|
}
|
|
|
|
function makePlural(word: string) {
|
|
return makeSingular(word) + "s";
|
|
}
|