fetch tags
This commit is contained in:
34
server/util/packVersion.ts
Normal file
34
server/util/packVersion.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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";
|
||||
}
|
Reference in New Issue
Block a user