You've already forked AstralRinth
forked from didirus/AstralRinth
Add TailwindCSS (#1252)
* Setup TailwindCSS * Fully setup configuration * Refactor some tailwind variables
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* @returns Whether any of the modifier keys is pressed.
|
||||
*/
|
||||
export function isModifierKeyDown(
|
||||
e: Pick<KeyboardEvent, 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey'>
|
||||
e: Pick<KeyboardEvent, "ctrlKey" | "altKey" | "metaKey" | "shiftKey">,
|
||||
) {
|
||||
return e.ctrlKey || e.altKey || e.metaKey || e.shiftKey
|
||||
return e.ctrlKey || e.altKey || e.metaKey || e.shiftKey;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
import { formatBytes } from '~/plugins/shorthands.js'
|
||||
import { formatBytes } from "~/plugins/shorthands.js";
|
||||
|
||||
export const fileIsValid = (file, validationOptions) => {
|
||||
const { maxSize, alertOnInvalid } = validationOptions
|
||||
const { maxSize, alertOnInvalid } = validationOptions;
|
||||
if (maxSize !== null && maxSize !== undefined && file.size > maxSize) {
|
||||
if (alertOnInvalid) {
|
||||
alert(`File ${file.name} is too big! Must be less than ${formatBytes(maxSize)}`)
|
||||
alert(`File ${file.name} is too big! Must be less than ${formatBytes(maxSize)}`);
|
||||
}
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
export const acceptFileFromProjectType = (projectType) => {
|
||||
switch (projectType) {
|
||||
case 'mod':
|
||||
return '.jar,.zip,.litemod,application/java-archive,application/x-java-archive,application/zip'
|
||||
case 'plugin':
|
||||
return '.jar,.zip,application/java-archive,application/x-java-archive,application/zip'
|
||||
case 'resourcepack':
|
||||
return '.zip,application/zip'
|
||||
case 'shader':
|
||||
return '.zip,application/zip'
|
||||
case 'datapack':
|
||||
return '.zip,application/zip'
|
||||
case 'modpack':
|
||||
return '.mrpack,application/x-modrinth-modpack+zip,application/zip'
|
||||
case "mod":
|
||||
return ".jar,.zip,.litemod,application/java-archive,application/x-java-archive,application/zip";
|
||||
case "plugin":
|
||||
return ".jar,.zip,application/java-archive,application/x-java-archive,application/zip";
|
||||
case "resourcepack":
|
||||
return ".zip,application/zip";
|
||||
case "shader":
|
||||
return ".zip,application/zip";
|
||||
case "datapack":
|
||||
return ".zip,application/zip";
|
||||
case "modpack":
|
||||
return ".mrpack,application/x-modrinth-modpack+zip,application/zip";
|
||||
default:
|
||||
return '*'
|
||||
return "*";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
import hljs from 'highlight.js/lib/core'
|
||||
import hljs from "highlight.js/lib/core";
|
||||
// Scripting
|
||||
import javascript from 'highlight.js/lib/languages/javascript'
|
||||
import python from 'highlight.js/lib/languages/python'
|
||||
import lua from 'highlight.js/lib/languages/lua'
|
||||
import javascript from "highlight.js/lib/languages/javascript";
|
||||
import python from "highlight.js/lib/languages/python";
|
||||
import lua from "highlight.js/lib/languages/lua";
|
||||
// Coding
|
||||
import java from 'highlight.js/lib/languages/java'
|
||||
import kotlin from 'highlight.js/lib/languages/kotlin'
|
||||
import scala from 'highlight.js/lib/languages/scala'
|
||||
import groovy from 'highlight.js/lib/languages/groovy'
|
||||
import java from "highlight.js/lib/languages/java";
|
||||
import kotlin from "highlight.js/lib/languages/kotlin";
|
||||
import scala from "highlight.js/lib/languages/scala";
|
||||
import groovy from "highlight.js/lib/languages/groovy";
|
||||
// Configs
|
||||
import gradle from 'highlight.js/lib/languages/gradle'
|
||||
import json from 'highlight.js/lib/languages/json'
|
||||
import ini from 'highlight.js/lib/languages/ini'
|
||||
import yaml from 'highlight.js/lib/languages/yaml'
|
||||
import xml from 'highlight.js/lib/languages/xml'
|
||||
import properties from 'highlight.js/lib/languages/properties'
|
||||
import { md, configuredXss } from '@modrinth/utils'
|
||||
import gradle from "highlight.js/lib/languages/gradle";
|
||||
import json from "highlight.js/lib/languages/json";
|
||||
import ini from "highlight.js/lib/languages/ini";
|
||||
import yaml from "highlight.js/lib/languages/yaml";
|
||||
import xml from "highlight.js/lib/languages/xml";
|
||||
import properties from "highlight.js/lib/languages/properties";
|
||||
import { md, configuredXss } from "@modrinth/utils";
|
||||
|
||||
/* REGISTRATION */
|
||||
// Scripting
|
||||
hljs.registerLanguage('javascript', javascript)
|
||||
hljs.registerLanguage('python', python)
|
||||
hljs.registerLanguage('lua', lua)
|
||||
hljs.registerLanguage("javascript", javascript);
|
||||
hljs.registerLanguage("python", python);
|
||||
hljs.registerLanguage("lua", lua);
|
||||
// Coding
|
||||
hljs.registerLanguage('java', java)
|
||||
hljs.registerLanguage('kotlin', kotlin)
|
||||
hljs.registerLanguage('scala', scala)
|
||||
hljs.registerLanguage('groovy', groovy)
|
||||
hljs.registerLanguage("java", java);
|
||||
hljs.registerLanguage("kotlin", kotlin);
|
||||
hljs.registerLanguage("scala", scala);
|
||||
hljs.registerLanguage("groovy", groovy);
|
||||
// Configs
|
||||
hljs.registerLanguage('gradle', gradle)
|
||||
hljs.registerLanguage('json', json)
|
||||
hljs.registerLanguage('ini', ini)
|
||||
hljs.registerLanguage('yaml', yaml)
|
||||
hljs.registerLanguage('xml', xml)
|
||||
hljs.registerLanguage('properties', properties)
|
||||
hljs.registerLanguage("gradle", gradle);
|
||||
hljs.registerLanguage("json", json);
|
||||
hljs.registerLanguage("ini", ini);
|
||||
hljs.registerLanguage("yaml", yaml);
|
||||
hljs.registerLanguage("xml", xml);
|
||||
hljs.registerLanguage("properties", properties);
|
||||
|
||||
/* ALIASES */
|
||||
// Scripting
|
||||
hljs.registerAliases(['js'], { languageName: 'javascript' })
|
||||
hljs.registerAliases(['py'], { languageName: 'python' })
|
||||
hljs.registerAliases(["js"], { languageName: "javascript" });
|
||||
hljs.registerAliases(["py"], { languageName: "python" });
|
||||
// Coding
|
||||
hljs.registerAliases(['kt'], { languageName: 'kotlin' })
|
||||
hljs.registerAliases(["kt"], { languageName: "kotlin" });
|
||||
// Configs
|
||||
hljs.registerAliases(['json5'], { languageName: 'json' })
|
||||
hljs.registerAliases(['toml'], { languageName: 'ini' })
|
||||
hljs.registerAliases(['yml'], { languageName: 'yaml' })
|
||||
hljs.registerAliases(['html', 'htm', 'xhtml', 'mcui', 'fxml'], { languageName: 'xml' })
|
||||
hljs.registerAliases(["json5"], { languageName: "json" });
|
||||
hljs.registerAliases(["toml"], { languageName: "ini" });
|
||||
hljs.registerAliases(["yml"], { languageName: "yaml" });
|
||||
hljs.registerAliases(["html", "htm", "xhtml", "mcui", "fxml"], { languageName: "xml" });
|
||||
|
||||
export const renderHighlightedString = (string) =>
|
||||
configuredXss.process(
|
||||
@@ -53,11 +53,13 @@ export const renderHighlightedString = (string) =>
|
||||
highlight: function (str, lang) {
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
try {
|
||||
return hljs.highlight(str, { language: lang }).value
|
||||
} catch (__) {}
|
||||
return hljs.highlight(str, { language: lang }).value;
|
||||
} catch (__) {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
return "";
|
||||
},
|
||||
}).render(string)
|
||||
)
|
||||
}).render(string),
|
||||
);
|
||||
|
||||
@@ -1,154 +1,154 @@
|
||||
import TOML from '@ltd/j-toml'
|
||||
import JSZip from 'jszip'
|
||||
import yaml from 'js-yaml'
|
||||
import { satisfies } from 'semver'
|
||||
import TOML from "@ltd/j-toml";
|
||||
import JSZip from "jszip";
|
||||
import yaml from "js-yaml";
|
||||
import { satisfies } from "semver";
|
||||
|
||||
export const inferVersionInfo = async function (rawFile, project, gameVersions) {
|
||||
function versionType(number) {
|
||||
if (number.includes('alpha')) {
|
||||
return 'alpha'
|
||||
if (number.includes("alpha")) {
|
||||
return "alpha";
|
||||
} else if (
|
||||
number.includes('beta') ||
|
||||
number.includes("beta") ||
|
||||
number.match(/[^A-z](rc)[^A-z]/) || // includes `rc`
|
||||
number.match(/[^A-z](pre)[^A-z]/) // includes `pre`
|
||||
) {
|
||||
return 'beta'
|
||||
return "beta";
|
||||
} else {
|
||||
return 'release'
|
||||
return "release";
|
||||
}
|
||||
}
|
||||
|
||||
function getGameVersionsMatchingSemverRange(range, gameVersions) {
|
||||
if (!range) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
const ranges = Array.isArray(range) ? range : [range]
|
||||
const ranges = Array.isArray(range) ? range : [range];
|
||||
return gameVersions.filter((version) => {
|
||||
const semverVersion = version.split('.').length === 2 ? `${version}.0` : version // add patch version if missing (e.g. 1.16 -> 1.16.0)
|
||||
return ranges.some((v) => satisfies(semverVersion, v))
|
||||
})
|
||||
const semverVersion = version.split(".").length === 2 ? `${version}.0` : version; // add patch version if missing (e.g. 1.16 -> 1.16.0)
|
||||
return ranges.some((v) => satisfies(semverVersion, v));
|
||||
});
|
||||
}
|
||||
|
||||
function getGameVersionsMatchingMavenRange(range, gameVersions) {
|
||||
if (!range) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
const ranges = []
|
||||
const ranges = [];
|
||||
|
||||
while (range.startsWith('[') || range.startsWith('(')) {
|
||||
let index = range.indexOf(')')
|
||||
const index2 = range.indexOf(']')
|
||||
while (range.startsWith("[") || range.startsWith("(")) {
|
||||
let index = range.indexOf(")");
|
||||
const index2 = range.indexOf("]");
|
||||
if (index === -1 || (index2 !== -1 && index2 < index)) {
|
||||
index = index2
|
||||
index = index2;
|
||||
}
|
||||
if (index === -1) break
|
||||
ranges.push(range.substring(0, index + 1))
|
||||
range = range.substring(index + 1).trim()
|
||||
if (range.startsWith(',')) {
|
||||
range = range.substring(1).trim()
|
||||
if (index === -1) break;
|
||||
ranges.push(range.substring(0, index + 1));
|
||||
range = range.substring(index + 1).trim();
|
||||
if (range.startsWith(",")) {
|
||||
range = range.substring(1).trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (range) {
|
||||
ranges.push(range)
|
||||
ranges.push(range);
|
||||
}
|
||||
|
||||
const LESS_THAN_EQUAL = /^\(,(.*)]$/
|
||||
const LESS_THAN = /^\(,(.*)\)$/
|
||||
const EQUAL = /^\[(.*)]$/
|
||||
const GREATER_THAN_EQUAL = /^\[(.*),\)$/
|
||||
const GREATER_THAN = /^\((.*),\)$/
|
||||
const BETWEEN = /^\((.*),(.*)\)$/
|
||||
const BETWEEN_EQUAL = /^\[(.*),(.*)]$/
|
||||
const BETWEEN_LESS_THAN_EQUAL = /^\((.*),(.*)]$/
|
||||
const BETWEEN_GREATER_THAN_EQUAL = /^\[(.*),(.*)\)$/
|
||||
const LESS_THAN_EQUAL = /^\(,(.*)]$/;
|
||||
const LESS_THAN = /^\(,(.*)\)$/;
|
||||
const EQUAL = /^\[(.*)]$/;
|
||||
const GREATER_THAN_EQUAL = /^\[(.*),\)$/;
|
||||
const GREATER_THAN = /^\((.*),\)$/;
|
||||
const BETWEEN = /^\((.*),(.*)\)$/;
|
||||
const BETWEEN_EQUAL = /^\[(.*),(.*)]$/;
|
||||
const BETWEEN_LESS_THAN_EQUAL = /^\((.*),(.*)]$/;
|
||||
const BETWEEN_GREATER_THAN_EQUAL = /^\[(.*),(.*)\)$/;
|
||||
|
||||
const semverRanges = []
|
||||
const semverRanges = [];
|
||||
|
||||
for (const range of ranges) {
|
||||
let result
|
||||
let result;
|
||||
if ((result = range.match(LESS_THAN_EQUAL))) {
|
||||
semverRanges.push(`<=${result[1]}`)
|
||||
semverRanges.push(`<=${result[1]}`);
|
||||
} else if ((result = range.match(LESS_THAN))) {
|
||||
semverRanges.push(`<${result[1]}`)
|
||||
semverRanges.push(`<${result[1]}`);
|
||||
} else if ((result = range.match(EQUAL))) {
|
||||
semverRanges.push(`${result[1]}`)
|
||||
semverRanges.push(`${result[1]}`);
|
||||
} else if ((result = range.match(GREATER_THAN_EQUAL))) {
|
||||
semverRanges.push(`>=${result[1]}`)
|
||||
semverRanges.push(`>=${result[1]}`);
|
||||
} else if ((result = range.match(GREATER_THAN))) {
|
||||
semverRanges.push(`>${result[1]}`)
|
||||
semverRanges.push(`>${result[1]}`);
|
||||
} else if ((result = range.match(BETWEEN))) {
|
||||
semverRanges.push(`>${result[1]} <${result[2]}`)
|
||||
semverRanges.push(`>${result[1]} <${result[2]}`);
|
||||
} else if ((result = range.match(BETWEEN_EQUAL))) {
|
||||
semverRanges.push(`>=${result[1]} <=${result[2]}`)
|
||||
semverRanges.push(`>=${result[1]} <=${result[2]}`);
|
||||
} else if ((result = range.match(BETWEEN_LESS_THAN_EQUAL))) {
|
||||
semverRanges.push(`>${result[1]} <=${result[2]}`)
|
||||
semverRanges.push(`>${result[1]} <=${result[2]}`);
|
||||
} else if ((result = range.match(BETWEEN_GREATER_THAN_EQUAL))) {
|
||||
semverRanges.push(`>=${result[1]} <${result[2]}`)
|
||||
semverRanges.push(`>=${result[1]} <${result[2]}`);
|
||||
}
|
||||
}
|
||||
return getGameVersionsMatchingSemverRange(semverRanges, gameVersions)
|
||||
return getGameVersionsMatchingSemverRange(semverRanges, gameVersions);
|
||||
}
|
||||
|
||||
const simplifiedGameVersions = gameVersions
|
||||
.filter((it) => it.version_type === 'release')
|
||||
.map((it) => it.version)
|
||||
.filter((it) => it.version_type === "release")
|
||||
.map((it) => it.version);
|
||||
|
||||
const inferFunctions = {
|
||||
// Forge 1.13+ and NeoForge
|
||||
'META-INF/mods.toml': async (file, zip) => {
|
||||
const metadata = TOML.parse(file, { joiner: '\n' })
|
||||
"META-INF/mods.toml": async (file, zip) => {
|
||||
const metadata = TOML.parse(file, { joiner: "\n" });
|
||||
|
||||
if (metadata.mods && metadata.mods.length > 0) {
|
||||
let versionNum = metadata.mods[0].version
|
||||
let versionNum = metadata.mods[0].version;
|
||||
|
||||
// ${file.jarVersion} -> Implementation-Version from manifest
|
||||
const manifestFile = zip.file('META-INF/MANIFEST.MF')
|
||||
const manifestFile = zip.file("META-INF/MANIFEST.MF");
|
||||
if (
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
metadata.mods[0].version.includes('${file.jarVersion}') &&
|
||||
metadata.mods[0].version.includes("${file.jarVersion}") &&
|
||||
manifestFile !== null
|
||||
) {
|
||||
const manifestText = await manifestFile.async('text')
|
||||
const regex = /Implementation-Version: (.*)$/m
|
||||
const match = manifestText.match(regex)
|
||||
const manifestText = await manifestFile.async("text");
|
||||
const regex = /Implementation-Version: (.*)$/m;
|
||||
const match = manifestText.match(regex);
|
||||
if (match) {
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
versionNum = versionNum.replace('${file.jarVersion}', match[1])
|
||||
versionNum = versionNum.replace("${file.jarVersion}", match[1]);
|
||||
}
|
||||
}
|
||||
|
||||
let gameVersions = []
|
||||
let gameVersions = [];
|
||||
const mcDependencies = Object.values(metadata.dependencies)
|
||||
.flat()
|
||||
.filter((dependency) => dependency.modId === 'minecraft')
|
||||
.filter((dependency) => dependency.modId === "minecraft");
|
||||
|
||||
if (mcDependencies.length > 0) {
|
||||
gameVersions = getGameVersionsMatchingMavenRange(
|
||||
mcDependencies[0].versionRange,
|
||||
simplifiedGameVersions
|
||||
)
|
||||
simplifiedGameVersions,
|
||||
);
|
||||
}
|
||||
|
||||
const hasNeoForge =
|
||||
Object.values(metadata.dependencies)
|
||||
.flat()
|
||||
.filter((dependency) => dependency.modId === 'neoforge').length > 0
|
||||
.filter((dependency) => dependency.modId === "neoforge").length > 0;
|
||||
|
||||
const hasForge =
|
||||
Object.values(metadata.dependencies)
|
||||
.flat()
|
||||
.filter((dependency) => dependency.modId === 'forge').length > 0
|
||||
.filter((dependency) => dependency.modId === "forge").length > 0;
|
||||
|
||||
// Checks if game version is below 1.20.2 as NeoForge full split and id change was in 1.20.2
|
||||
const below1202 = getGameVersionsMatchingSemverRange('<=1.20.1', simplifiedGameVersions)
|
||||
const below1202 = getGameVersionsMatchingSemverRange("<=1.20.1", simplifiedGameVersions);
|
||||
|
||||
const isOlderThan1202 = below1202.some((r) => gameVersions.includes(r))
|
||||
const isOlderThan1202 = below1202.some((r) => gameVersions.includes(r));
|
||||
|
||||
const loaders = []
|
||||
const loaders = [];
|
||||
|
||||
if (hasNeoForge) loaders.push('neoforge')
|
||||
if (hasForge || isOlderThan1202) loaders.push('forge')
|
||||
if (hasNeoForge) loaders.push("neoforge");
|
||||
if (hasForge || isOlderThan1202) loaders.push("forge");
|
||||
|
||||
return {
|
||||
name: `${project.title} ${versionNum}`,
|
||||
@@ -156,61 +156,61 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
|
||||
version_type: versionType(versionNum),
|
||||
loaders,
|
||||
game_versions: gameVersions,
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {}
|
||||
return {};
|
||||
}
|
||||
},
|
||||
// Old Forge
|
||||
'mcmod.info': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"mcmod.info": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
return {
|
||||
name: metadata.version ? `${project.title} ${metadata.version}` : '',
|
||||
name: metadata.version ? `${project.title} ${metadata.version}` : "",
|
||||
version_number: metadata.version,
|
||||
version_type: versionType(metadata.version),
|
||||
loaders: ['forge'],
|
||||
loaders: ["forge"],
|
||||
game_versions: simplifiedGameVersions.filter((version) =>
|
||||
version.startsWith(metadata.mcversion)
|
||||
version.startsWith(metadata.mcversion),
|
||||
),
|
||||
}
|
||||
};
|
||||
},
|
||||
// Fabric
|
||||
'fabric.mod.json': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"fabric.mod.json": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.version}`,
|
||||
version_number: metadata.version,
|
||||
loaders: ['fabric'],
|
||||
loaders: ["fabric"],
|
||||
version_type: versionType(metadata.version),
|
||||
game_versions: metadata.depends
|
||||
? getGameVersionsMatchingSemverRange(metadata.depends.minecraft, simplifiedGameVersions)
|
||||
: [],
|
||||
}
|
||||
};
|
||||
},
|
||||
// Quilt
|
||||
'quilt.mod.json': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"quilt.mod.json": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.quilt_loader.version}`,
|
||||
version_number: metadata.quilt_loader.version,
|
||||
loaders: ['quilt'],
|
||||
loaders: ["quilt"],
|
||||
version_type: versionType(metadata.quilt_loader.version),
|
||||
game_versions: metadata.quilt_loader.depends
|
||||
? getGameVersionsMatchingSemverRange(
|
||||
metadata.quilt_loader.depends.find((x) => x.id === 'minecraft')
|
||||
? metadata.quilt_loader.depends.find((x) => x.id === 'minecraft').versions
|
||||
metadata.quilt_loader.depends.find((x) => x.id === "minecraft")
|
||||
? metadata.quilt_loader.depends.find((x) => x.id === "minecraft").versions
|
||||
: [],
|
||||
simplifiedGameVersions
|
||||
simplifiedGameVersions,
|
||||
)
|
||||
: [],
|
||||
}
|
||||
};
|
||||
},
|
||||
// Bukkit + Other Forks
|
||||
'plugin.yml': (file) => {
|
||||
const metadata = yaml.load(file)
|
||||
"plugin.yml": (file) => {
|
||||
const metadata = yaml.load(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.version}`,
|
||||
@@ -220,65 +220,65 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
|
||||
loaders: [],
|
||||
game_versions: gameVersions
|
||||
.filter(
|
||||
(x) => x.version.startsWith(metadata['api-version']) && x.version_type === 'release'
|
||||
(x) => x.version.startsWith(metadata["api-version"]) && x.version_type === "release",
|
||||
)
|
||||
.map((x) => x.version),
|
||||
}
|
||||
};
|
||||
},
|
||||
// Paper 1.19.3+
|
||||
'paper-plugin.yml': (file) => {
|
||||
const metadata = yaml.load(file)
|
||||
"paper-plugin.yml": (file) => {
|
||||
const metadata = yaml.load(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.version}`,
|
||||
version_number: metadata.version,
|
||||
version_type: versionType(metadata.version),
|
||||
loaders: ['paper'],
|
||||
loaders: ["paper"],
|
||||
game_versions: gameVersions
|
||||
.filter(
|
||||
(x) => x.version.startsWith(metadata['api-version']) && x.version_type === 'release'
|
||||
(x) => x.version.startsWith(metadata["api-version"]) && x.version_type === "release",
|
||||
)
|
||||
.map((x) => x.version),
|
||||
}
|
||||
};
|
||||
},
|
||||
// Bungeecord + Waterfall
|
||||
'bungee.yml': (file) => {
|
||||
const metadata = yaml.load(file)
|
||||
"bungee.yml": (file) => {
|
||||
const metadata = yaml.load(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.version}`,
|
||||
version_number: metadata.version,
|
||||
version_type: versionType(metadata.version),
|
||||
loaders: ['bungeecord'],
|
||||
}
|
||||
loaders: ["bungeecord"],
|
||||
};
|
||||
},
|
||||
// Velocity
|
||||
'velocity-plugin.json': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"velocity-plugin.json": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
return {
|
||||
name: `${project.title} ${metadata.version}`,
|
||||
version_number: metadata.version,
|
||||
version_type: versionType(metadata.version),
|
||||
loaders: ['velocity'],
|
||||
}
|
||||
loaders: ["velocity"],
|
||||
};
|
||||
},
|
||||
// Modpacks
|
||||
'modrinth.index.json': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"modrinth.index.json": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
const loaders = []
|
||||
if ('forge' in metadata.dependencies) {
|
||||
loaders.push('forge')
|
||||
const loaders = [];
|
||||
if ("forge" in metadata.dependencies) {
|
||||
loaders.push("forge");
|
||||
}
|
||||
if ('neoforge' in metadata.dependencies) {
|
||||
loaders.push('neoforge')
|
||||
if ("neoforge" in metadata.dependencies) {
|
||||
loaders.push("neoforge");
|
||||
}
|
||||
if ('fabric-loader' in metadata.dependencies) {
|
||||
loaders.push('fabric')
|
||||
if ("fabric-loader" in metadata.dependencies) {
|
||||
loaders.push("fabric");
|
||||
}
|
||||
if ('quilt-loader' in metadata.dependencies) {
|
||||
loaders.push('quilt')
|
||||
if ("quilt-loader" in metadata.dependencies) {
|
||||
loaders.push("quilt");
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -289,106 +289,106 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
|
||||
game_versions: gameVersions
|
||||
.filter((x) => x.version === metadata.dependencies.minecraft)
|
||||
.map((x) => x.version),
|
||||
}
|
||||
};
|
||||
},
|
||||
// Resource Packs + Data Packs
|
||||
'pack.mcmeta': (file) => {
|
||||
const metadata = JSON.parse(file)
|
||||
"pack.mcmeta": (file) => {
|
||||
const metadata = JSON.parse(file);
|
||||
|
||||
function getRange(versionA, versionB) {
|
||||
const startingIndex = gameVersions.findIndex((x) => x.version === versionA)
|
||||
const endingIndex = gameVersions.findIndex((x) => x.version === versionB)
|
||||
const startingIndex = gameVersions.findIndex((x) => x.version === versionA);
|
||||
const endingIndex = gameVersions.findIndex((x) => x.version === versionB);
|
||||
|
||||
const final = []
|
||||
const filterOnlyRelease = gameVersions[startingIndex].version_type === 'release'
|
||||
const final = [];
|
||||
const filterOnlyRelease = gameVersions[startingIndex].version_type === "release";
|
||||
|
||||
for (let i = startingIndex; i >= endingIndex; i--) {
|
||||
if (gameVersions[i].version_type === 'release' || !filterOnlyRelease) {
|
||||
final.push(gameVersions[i].version)
|
||||
if (gameVersions[i].version_type === "release" || !filterOnlyRelease) {
|
||||
final.push(gameVersions[i].version);
|
||||
}
|
||||
}
|
||||
|
||||
return final
|
||||
return final;
|
||||
}
|
||||
|
||||
const loaders = []
|
||||
let newGameVersions = []
|
||||
const loaders = [];
|
||||
let newGameVersions = [];
|
||||
|
||||
if (project.actualProjectType === 'mod') {
|
||||
loaders.push('datapack')
|
||||
if (project.actualProjectType === "mod") {
|
||||
loaders.push("datapack");
|
||||
|
||||
switch (metadata.pack.pack_format) {
|
||||
case 4:
|
||||
newGameVersions = getRange('1.13', '1.14.4')
|
||||
break
|
||||
newGameVersions = getRange("1.13", "1.14.4");
|
||||
break;
|
||||
case 5:
|
||||
newGameVersions = getRange('1.15', '1.16.1')
|
||||
break
|
||||
newGameVersions = getRange("1.15", "1.16.1");
|
||||
break;
|
||||
case 6:
|
||||
newGameVersions = getRange('1.16.2', '1.16.5')
|
||||
break
|
||||
newGameVersions = getRange("1.16.2", "1.16.5");
|
||||
break;
|
||||
case 7:
|
||||
newGameVersions = getRange('1.17', '1.17.1')
|
||||
break
|
||||
newGameVersions = getRange("1.17", "1.17.1");
|
||||
break;
|
||||
case 8:
|
||||
newGameVersions = getRange('1.18', '1.18.1')
|
||||
break
|
||||
newGameVersions = getRange("1.18", "1.18.1");
|
||||
break;
|
||||
case 9:
|
||||
newGameVersions.push('1.18.2')
|
||||
break
|
||||
newGameVersions.push("1.18.2");
|
||||
break;
|
||||
case 10:
|
||||
newGameVersions = getRange('1.19', '1.19.3')
|
||||
break
|
||||
newGameVersions = getRange("1.19", "1.19.3");
|
||||
break;
|
||||
case 11:
|
||||
newGameVersions = getRange('23w03a', '23w05a')
|
||||
break
|
||||
newGameVersions = getRange("23w03a", "23w05a");
|
||||
break;
|
||||
case 12:
|
||||
newGameVersions.push('1.19.4')
|
||||
break
|
||||
newGameVersions.push("1.19.4");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if (project.actualProjectType === 'resourcepack') {
|
||||
loaders.push('minecraft')
|
||||
if (project.actualProjectType === "resourcepack") {
|
||||
loaders.push("minecraft");
|
||||
|
||||
switch (metadata.pack.pack_format) {
|
||||
case 1:
|
||||
newGameVersions = getRange('1.6.1', '1.8.9')
|
||||
break
|
||||
newGameVersions = getRange("1.6.1", "1.8.9");
|
||||
break;
|
||||
case 2:
|
||||
newGameVersions = getRange('1.9', '1.10.2')
|
||||
break
|
||||
newGameVersions = getRange("1.9", "1.10.2");
|
||||
break;
|
||||
case 3:
|
||||
newGameVersions = getRange('1.11', '1.12.2')
|
||||
break
|
||||
newGameVersions = getRange("1.11", "1.12.2");
|
||||
break;
|
||||
case 4:
|
||||
newGameVersions = getRange('1.13', '1.14.4')
|
||||
break
|
||||
newGameVersions = getRange("1.13", "1.14.4");
|
||||
break;
|
||||
case 5:
|
||||
newGameVersions = getRange('1.15', '1.16.1')
|
||||
break
|
||||
newGameVersions = getRange("1.15", "1.16.1");
|
||||
break;
|
||||
case 6:
|
||||
newGameVersions = getRange('1.16.2', '1.16.5')
|
||||
break
|
||||
newGameVersions = getRange("1.16.2", "1.16.5");
|
||||
break;
|
||||
case 7:
|
||||
newGameVersions = getRange('1.17', '1.17.1')
|
||||
break
|
||||
newGameVersions = getRange("1.17", "1.17.1");
|
||||
break;
|
||||
case 8:
|
||||
newGameVersions = getRange('1.18', '1.18.2')
|
||||
break
|
||||
newGameVersions = getRange("1.18", "1.18.2");
|
||||
break;
|
||||
case 9:
|
||||
newGameVersions = getRange('1.19', '1.19.2')
|
||||
break
|
||||
newGameVersions = getRange("1.19", "1.19.2");
|
||||
break;
|
||||
case 11:
|
||||
newGameVersions = getRange('22w42a', '22w44a')
|
||||
break
|
||||
newGameVersions = getRange("22w42a", "22w44a");
|
||||
break;
|
||||
case 12:
|
||||
newGameVersions.push('1.19.3')
|
||||
break
|
||||
newGameVersions.push("1.19.3");
|
||||
break;
|
||||
case 13:
|
||||
newGameVersions.push('1.19.4')
|
||||
break
|
||||
newGameVersions.push("1.19.4");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -396,20 +396,20 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
|
||||
return {
|
||||
loaders,
|
||||
game_versions: newGameVersions,
|
||||
}
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const zipReader = new JSZip()
|
||||
const zipReader = new JSZip();
|
||||
|
||||
const zip = await zipReader.loadAsync(rawFile)
|
||||
const zip = await zipReader.loadAsync(rawFile);
|
||||
|
||||
for (const fileName in inferFunctions) {
|
||||
const file = zip.file(fileName)
|
||||
const file = zip.file(fileName);
|
||||
|
||||
if (file !== null) {
|
||||
const text = await file.async('text')
|
||||
return inferFunctions[fileName](text, zip)
|
||||
const text = await file.async("text");
|
||||
return inferFunctions[fileName](text, zip);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { useNuxtApp } from '#imports'
|
||||
/* eslint-disable no-undef */
|
||||
import { useNuxtApp } from "#imports";
|
||||
|
||||
async function getBulk(type, ids, apiVersion = 2) {
|
||||
if (ids.length === 0) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
|
||||
const url = `${type}?ids=${encodeURIComponent(JSON.stringify([...new Set(ids)]))}`
|
||||
return await useBaseFetch(url, { apiVersion })
|
||||
const url = `${type}?ids=${encodeURIComponent(JSON.stringify([...new Set(ids)]))}`;
|
||||
return await useBaseFetch(url, { apiVersion });
|
||||
}
|
||||
|
||||
export async function fetchExtraNotificationData(notifications) {
|
||||
@@ -17,154 +18,154 @@ export async function fetchExtraNotificationData(notifications) {
|
||||
users: [],
|
||||
versions: [],
|
||||
organizations: [],
|
||||
}
|
||||
};
|
||||
|
||||
for (const notification of notifications) {
|
||||
if (notification.body) {
|
||||
if (notification.body.project_id) {
|
||||
bulk.projects.push(notification.body.project_id)
|
||||
bulk.projects.push(notification.body.project_id);
|
||||
}
|
||||
if (notification.body.version_id) {
|
||||
bulk.versions.push(notification.body.version_id)
|
||||
bulk.versions.push(notification.body.version_id);
|
||||
}
|
||||
if (notification.body.report_id) {
|
||||
bulk.reports.push(notification.body.report_id)
|
||||
bulk.reports.push(notification.body.report_id);
|
||||
}
|
||||
if (notification.body.thread_id) {
|
||||
bulk.threads.push(notification.body.thread_id)
|
||||
bulk.threads.push(notification.body.thread_id);
|
||||
}
|
||||
if (notification.body.invited_by) {
|
||||
bulk.users.push(notification.body.invited_by)
|
||||
bulk.users.push(notification.body.invited_by);
|
||||
}
|
||||
if (notification.body.organization_id) {
|
||||
bulk.organizations.push(notification.body.organization_id)
|
||||
bulk.organizations.push(notification.body.organization_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const reports = await getBulk('reports', bulk.reports)
|
||||
const reports = await getBulk("reports", bulk.reports);
|
||||
for (const report of reports) {
|
||||
if (report.item_type === 'project') {
|
||||
bulk.projects.push(report.item_id)
|
||||
} else if (report.item_type === 'user') {
|
||||
bulk.users.push(report.item_id)
|
||||
} else if (report.item_type === 'version') {
|
||||
bulk.versions.push(report.item_id)
|
||||
if (report.item_type === "project") {
|
||||
bulk.projects.push(report.item_id);
|
||||
} else if (report.item_type === "user") {
|
||||
bulk.users.push(report.item_id);
|
||||
} else if (report.item_type === "version") {
|
||||
bulk.versions.push(report.item_id);
|
||||
}
|
||||
}
|
||||
const versions = await getBulk('versions', bulk.versions)
|
||||
const versions = await getBulk("versions", bulk.versions);
|
||||
for (const version of versions) {
|
||||
bulk.projects.push(version.project_id)
|
||||
bulk.projects.push(version.project_id);
|
||||
}
|
||||
const [projects, threads, users, organizations] = await Promise.all([
|
||||
getBulk('projects', bulk.projects),
|
||||
getBulk('threads', bulk.threads),
|
||||
getBulk('users', bulk.users),
|
||||
getBulk('organizations', bulk.organizations, 3),
|
||||
])
|
||||
getBulk("projects", bulk.projects),
|
||||
getBulk("threads", bulk.threads),
|
||||
getBulk("users", bulk.users),
|
||||
getBulk("organizations", bulk.organizations, 3),
|
||||
]);
|
||||
for (const notification of notifications) {
|
||||
notification.extra_data = {}
|
||||
notification.extra_data = {};
|
||||
if (notification.body) {
|
||||
if (notification.body.project_id) {
|
||||
notification.extra_data.project = projects.find(
|
||||
(x) => x.id === notification.body.project_id
|
||||
)
|
||||
(x) => x.id === notification.body.project_id,
|
||||
);
|
||||
}
|
||||
if (notification.body.organization_id) {
|
||||
notification.extra_data.organization = organizations.find(
|
||||
(x) => x.id === notification.body.organization_id
|
||||
)
|
||||
(x) => x.id === notification.body.organization_id,
|
||||
);
|
||||
}
|
||||
if (notification.body.report_id) {
|
||||
notification.extra_data.report = reports.find((x) => x.id === notification.body.report_id)
|
||||
notification.extra_data.report = reports.find((x) => x.id === notification.body.report_id);
|
||||
|
||||
const type = notification.extra_data.report.item_type
|
||||
if (type === 'project') {
|
||||
const type = notification.extra_data.report.item_type;
|
||||
if (type === "project") {
|
||||
notification.extra_data.project = projects.find(
|
||||
(x) => x.id === notification.extra_data.report.item_id
|
||||
)
|
||||
} else if (type === 'user') {
|
||||
(x) => x.id === notification.extra_data.report.item_id,
|
||||
);
|
||||
} else if (type === "user") {
|
||||
notification.extra_data.user = users.find(
|
||||
(x) => x.id === notification.extra_data.report.item_id
|
||||
)
|
||||
} else if (type === 'version') {
|
||||
(x) => x.id === notification.extra_data.report.item_id,
|
||||
);
|
||||
} else if (type === "version") {
|
||||
notification.extra_data.version = versions.find(
|
||||
(x) => x.id === notification.extra_data.report.item_id
|
||||
)
|
||||
(x) => x.id === notification.extra_data.report.item_id,
|
||||
);
|
||||
notification.extra_data.project = projects.find(
|
||||
(x) => x.id === notification.extra_data.version.project_id
|
||||
)
|
||||
(x) => x.id === notification.extra_data.version.project_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (notification.body.thread_id) {
|
||||
notification.extra_data.thread = threads.find((x) => x.id === notification.body.thread_id)
|
||||
notification.extra_data.thread = threads.find((x) => x.id === notification.body.thread_id);
|
||||
}
|
||||
if (notification.body.invited_by) {
|
||||
notification.extra_data.invited_by = users.find(
|
||||
(x) => x.id === notification.body.invited_by
|
||||
)
|
||||
(x) => x.id === notification.body.invited_by,
|
||||
);
|
||||
}
|
||||
if (notification.body.version_id) {
|
||||
notification.extra_data.version = versions.find(
|
||||
(x) => x.id === notification.body.version_id
|
||||
)
|
||||
(x) => x.id === notification.body.version_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return notifications
|
||||
return notifications;
|
||||
}
|
||||
|
||||
export function groupNotifications(notifications) {
|
||||
const grouped = []
|
||||
const grouped = [];
|
||||
|
||||
for (let i = 0; i < notifications.length; i++) {
|
||||
const current = notifications[i]
|
||||
const next = notifications[i + 1]
|
||||
const current = notifications[i];
|
||||
const next = notifications[i + 1];
|
||||
if (current.body && i < notifications.length - 1 && isSimilar(current, next)) {
|
||||
current.grouped_notifs = [next]
|
||||
current.grouped_notifs = [next];
|
||||
|
||||
let j = i + 2
|
||||
let j = i + 2;
|
||||
while (j < notifications.length && isSimilar(current, notifications[j])) {
|
||||
current.grouped_notifs.push(notifications[j])
|
||||
j++
|
||||
current.grouped_notifs.push(notifications[j]);
|
||||
j++;
|
||||
}
|
||||
|
||||
grouped.push(current)
|
||||
i = j - 1 // skip i to the last ungrouped
|
||||
grouped.push(current);
|
||||
i = j - 1; // skip i to the last ungrouped
|
||||
} else {
|
||||
grouped.push(current)
|
||||
grouped.push(current);
|
||||
}
|
||||
}
|
||||
|
||||
return grouped
|
||||
return grouped;
|
||||
}
|
||||
|
||||
function isSimilar(notifA, notifB) {
|
||||
return !!notifA.body.project_id && notifA.body.project_id === notifB.body.project_id
|
||||
return !!notifA.body.project_id && notifA.body.project_id === notifB.body.project_id;
|
||||
}
|
||||
|
||||
export async function markAsRead(ids) {
|
||||
try {
|
||||
await useBaseFetch(`notifications?ids=${JSON.stringify([...new Set(ids)])}`, {
|
||||
method: 'PATCH',
|
||||
})
|
||||
method: "PATCH",
|
||||
});
|
||||
return (notifications) => {
|
||||
const newNotifs = notifications
|
||||
const newNotifs = notifications;
|
||||
newNotifs.forEach((notif) => {
|
||||
if (ids.includes(notif.id)) {
|
||||
notif.read = true
|
||||
notif.read = true;
|
||||
}
|
||||
})
|
||||
return newNotifs
|
||||
}
|
||||
});
|
||||
return newNotifs;
|
||||
};
|
||||
} catch (err) {
|
||||
const app = useNuxtApp()
|
||||
const app = useNuxtApp();
|
||||
app.$notify({
|
||||
group: 'main',
|
||||
title: 'Error marking notification as read',
|
||||
group: "main",
|
||||
title: "Error marking notification as read",
|
||||
text: err.data ? err.data.description : err,
|
||||
type: 'error',
|
||||
})
|
||||
return () => {}
|
||||
type: "error",
|
||||
});
|
||||
return () => {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import JSZip from 'jszip'
|
||||
import TOML from '@ltd/j-toml'
|
||||
/* eslint-disable no-undef */
|
||||
import JSZip from "jszip";
|
||||
import TOML from "@ltd/j-toml";
|
||||
|
||||
export const createDataPackVersion = async function (
|
||||
project,
|
||||
@@ -7,18 +8,18 @@ export const createDataPackVersion = async function (
|
||||
primaryFile,
|
||||
members,
|
||||
allGameVersions,
|
||||
loaders
|
||||
loaders,
|
||||
) {
|
||||
// force version to start with number, as required by FML
|
||||
const newVersionNumber = version.version_number.match(/^\d/)
|
||||
? version.version_number
|
||||
: `1-${version.version_number}`
|
||||
: `1-${version.version_number}`;
|
||||
|
||||
const newSlug = `mr_${project.slug.replace('-', '_').replace(/\W/g, '')}`.substring(0, 63)
|
||||
const newSlug = `mr_${project.slug.replace("-", "_").replace(/\W/g, "")}`.substring(0, 63);
|
||||
|
||||
const iconPath = `${project.slug}_pack.png`
|
||||
const iconPath = `${project.slug}_pack.png`;
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const fabricModJson = {
|
||||
schemaVersion: 1,
|
||||
@@ -32,16 +33,16 @@ export const createDataPackVersion = async function (
|
||||
},
|
||||
license: project.license.id,
|
||||
icon: iconPath,
|
||||
environment: '*',
|
||||
environment: "*",
|
||||
depends: {
|
||||
'fabric-resource-loader-v0': '*',
|
||||
"fabric-resource-loader-v0": "*",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const quiltModJson = {
|
||||
schema_version: 1,
|
||||
quilt_loader: {
|
||||
group: 'com.modrinth',
|
||||
group: "com.modrinth",
|
||||
id: newSlug,
|
||||
version: newVersionNumber,
|
||||
metadata: {
|
||||
@@ -52,7 +53,7 @@ export const createDataPackVersion = async function (
|
||||
...acc,
|
||||
[x.name]: x.role,
|
||||
}),
|
||||
{}
|
||||
{},
|
||||
),
|
||||
contact: {
|
||||
homepage: `${config.public.siteUrl}/${project.project_type}/${
|
||||
@@ -61,32 +62,32 @@ export const createDataPackVersion = async function (
|
||||
},
|
||||
icon: iconPath,
|
||||
},
|
||||
intermediate_mappings: 'net.fabricmc:intermediary',
|
||||
intermediate_mappings: "net.fabricmc:intermediary",
|
||||
depends: [
|
||||
{
|
||||
id: 'quilt_resource_loader',
|
||||
versions: '*',
|
||||
unless: 'fabric-resource-loader-v0',
|
||||
id: "quilt_resource_loader",
|
||||
versions: "*",
|
||||
unless: "fabric-resource-loader-v0",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const cutoffIndex = allGameVersions.findIndex((x) => x.version === '1.18.2')
|
||||
const cutoffIndex = allGameVersions.findIndex((x) => x.version === "1.18.2");
|
||||
|
||||
let maximumIndex = Number.MIN_VALUE
|
||||
let maximumIndex = Number.MIN_VALUE;
|
||||
for (const val of version.game_versions) {
|
||||
const index = allGameVersions.findIndex((x) => x.version === val)
|
||||
const index = allGameVersions.findIndex((x) => x.version === val);
|
||||
if (index > maximumIndex) {
|
||||
maximumIndex = index
|
||||
maximumIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
const newForge = maximumIndex < cutoffIndex
|
||||
const newForge = maximumIndex < cutoffIndex;
|
||||
|
||||
const forgeModsToml = {
|
||||
modLoader: newForge ? 'lowcodefml' : 'javafml',
|
||||
loaderVersion: newForge ? '[40,)' : '[25,)',
|
||||
modLoader: newForge ? "lowcodefml" : "javafml",
|
||||
loaderVersion: newForge ? "[40,)" : "[25,)",
|
||||
license: project.license.id,
|
||||
showAsResourcePack: false,
|
||||
mods: [
|
||||
@@ -96,103 +97,103 @@ export const createDataPackVersion = async function (
|
||||
displayName: project.title,
|
||||
description: project.description,
|
||||
logoFile: iconPath,
|
||||
updateJSONURL: `${config.public.apiBaseUrl.replace('/v2/', '')}/updates/${
|
||||
updateJSONURL: `${config.public.apiBaseUrl.replace("/v2/", "")}/updates/${
|
||||
project.id
|
||||
}/forge_updates.json`,
|
||||
credits: 'Generated by Modrinth',
|
||||
authors: members.map((x) => x.name).join(', '),
|
||||
credits: "Generated by Modrinth",
|
||||
authors: members.map((x) => x.name).join(", "),
|
||||
displayURL: `${config.public.siteUrl}/${project.project_type}/${
|
||||
project.slug ?? project.id
|
||||
}`,
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
if (project.source_url) {
|
||||
quiltModJson.quilt_loader.metadata.contact.sources = project.source_url
|
||||
fabricModJson.contact.sources = project.source_url
|
||||
quiltModJson.quilt_loader.metadata.contact.sources = project.source_url;
|
||||
fabricModJson.contact.sources = project.source_url;
|
||||
}
|
||||
|
||||
if (project.issues_url) {
|
||||
quiltModJson.quilt_loader.metadata.contact.issues = project.issues_url
|
||||
fabricModJson.contact.issues = project.issues_url
|
||||
forgeModsToml.issueTrackerURL = project.issues_url
|
||||
quiltModJson.quilt_loader.metadata.contact.issues = project.issues_url;
|
||||
fabricModJson.contact.issues = project.issues_url;
|
||||
forgeModsToml.issueTrackerURL = project.issues_url;
|
||||
}
|
||||
|
||||
const primaryFileData = await (await fetch(primaryFile.url)).blob()
|
||||
const primaryFileData = await (await fetch(primaryFile.url)).blob();
|
||||
|
||||
const primaryZipReader = new JSZip()
|
||||
await primaryZipReader.loadAsync(primaryFileData)
|
||||
const primaryZipReader = new JSZip();
|
||||
await primaryZipReader.loadAsync(primaryFileData);
|
||||
|
||||
if (loaders.includes('fabric')) {
|
||||
primaryZipReader.file('fabric.mod.json', JSON.stringify(fabricModJson))
|
||||
if (loaders.includes("fabric")) {
|
||||
primaryZipReader.file("fabric.mod.json", JSON.stringify(fabricModJson));
|
||||
}
|
||||
if (loaders.includes('quilt')) {
|
||||
primaryZipReader.file('quilt.mod.json', JSON.stringify(quiltModJson))
|
||||
if (loaders.includes("quilt")) {
|
||||
primaryZipReader.file("quilt.mod.json", JSON.stringify(quiltModJson));
|
||||
}
|
||||
if (loaders.includes('forge')) {
|
||||
primaryZipReader.file('META-INF/mods.toml', TOML.stringify(forgeModsToml, { newline: '\n' }))
|
||||
if (loaders.includes("forge")) {
|
||||
primaryZipReader.file("META-INF/mods.toml", TOML.stringify(forgeModsToml, { newline: "\n" }));
|
||||
}
|
||||
|
||||
if (!newForge && loaders.includes('forge')) {
|
||||
if (!newForge && loaders.includes("forge")) {
|
||||
const classFile = new Uint8Array(
|
||||
await (
|
||||
await fetch('https://cdn.modrinth.com/wrapper/ModrinthWrapperRestiched.class')
|
||||
).arrayBuffer()
|
||||
)
|
||||
await fetch("https://cdn.modrinth.com/wrapper/ModrinthWrapperRestiched.class")
|
||||
).arrayBuffer(),
|
||||
);
|
||||
|
||||
let binary = ''
|
||||
let binary = "";
|
||||
for (let i = 0; i < classFile.byteLength; i++) {
|
||||
binary += String.fromCharCode(classFile[i])
|
||||
binary += String.fromCharCode(classFile[i]);
|
||||
}
|
||||
|
||||
let sanitizedId = project.id
|
||||
let sanitizedId = project.id;
|
||||
|
||||
if (project.id.match(/^(\d+)/g)) {
|
||||
sanitizedId = '_' + sanitizedId
|
||||
sanitizedId = "_" + sanitizedId;
|
||||
}
|
||||
|
||||
sanitizedId = sanitizedId.substring(0, 8)
|
||||
sanitizedId = sanitizedId.substring(0, 8);
|
||||
|
||||
binary = binary
|
||||
.replace(
|
||||
String.fromCharCode(32) + 'needs1to1be1changed1modrinth1mod',
|
||||
String.fromCharCode(newSlug.length) + newSlug
|
||||
String.fromCharCode(32) + "needs1to1be1changed1modrinth1mod",
|
||||
String.fromCharCode(newSlug.length) + newSlug,
|
||||
)
|
||||
.replace('/wrappera/', `/${sanitizedId}/`)
|
||||
.replace("/wrappera/", `/${sanitizedId}/`);
|
||||
|
||||
const newArr = []
|
||||
const newArr = [];
|
||||
for (let i = 0; i < binary.length; i++) {
|
||||
newArr.push(binary.charCodeAt(i))
|
||||
newArr.push(binary.charCodeAt(i));
|
||||
}
|
||||
|
||||
primaryZipReader.file(
|
||||
`com/modrinth/${sanitizedId}/ModrinthWrapper.class`,
|
||||
new Uint8Array(newArr)
|
||||
)
|
||||
new Uint8Array(newArr),
|
||||
);
|
||||
}
|
||||
|
||||
const resourcePack = version.files.find((x) => x.file_type === 'required-resource-pack')
|
||||
const resourcePack = version.files.find((x) => x.file_type === "required-resource-pack");
|
||||
|
||||
const resourcePackData = resourcePack ? await (await fetch(resourcePack.url)).blob() : null
|
||||
const resourcePackData = resourcePack ? await (await fetch(resourcePack.url)).blob() : null;
|
||||
|
||||
if (resourcePackData) {
|
||||
const resourcePackReader = new JSZip()
|
||||
await resourcePackReader.loadAsync(resourcePackData)
|
||||
const resourcePackReader = new JSZip();
|
||||
await resourcePackReader.loadAsync(resourcePackData);
|
||||
|
||||
for (const [path, file] of Object.entries(resourcePackReader.files)) {
|
||||
if (!primaryZipReader.file(path) && !path.includes('.mcassetsroot')) {
|
||||
primaryZipReader.file(path, await file.async('uint8array'))
|
||||
if (!primaryZipReader.file(path) && !path.includes(".mcassetsroot")) {
|
||||
primaryZipReader.file(path, await file.async("uint8array"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (primaryZipReader.file('pack.png')) {
|
||||
primaryZipReader.file(iconPath, await primaryZipReader.file('pack.png').async('uint8array'))
|
||||
if (primaryZipReader.file("pack.png")) {
|
||||
primaryZipReader.file(iconPath, await primaryZipReader.file("pack.png").async("uint8array"));
|
||||
}
|
||||
|
||||
return await primaryZipReader.generateAsync({
|
||||
type: 'blob',
|
||||
mimeType: 'application/java-archive',
|
||||
})
|
||||
}
|
||||
type: "blob",
|
||||
mimeType: "application/java-archive",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,131 +1,132 @@
|
||||
/* eslint-disable no-undef */
|
||||
export const getProjectTypeForUrl = (type, categories) => {
|
||||
return getProjectTypeForUrlShorthand(type, categories)
|
||||
}
|
||||
return getProjectTypeForUrlShorthand(type, categories);
|
||||
};
|
||||
|
||||
export const getProjectTypeForUrlShorthand = (type, categories, overrideTags) => {
|
||||
const tags = overrideTags ?? useTags().value
|
||||
const tags = overrideTags ?? useTags().value;
|
||||
|
||||
if (type === 'mod') {
|
||||
if (type === "mod") {
|
||||
const isMod = categories.some((category) => {
|
||||
return tags.loaderData.modLoaders.includes(category)
|
||||
})
|
||||
return tags.loaderData.modLoaders.includes(category);
|
||||
});
|
||||
|
||||
const isPlugin = categories.some((category) => {
|
||||
return tags.loaderData.allPluginLoaders.includes(category)
|
||||
})
|
||||
return tags.loaderData.allPluginLoaders.includes(category);
|
||||
});
|
||||
|
||||
const isDataPack = categories.some((category) => {
|
||||
return tags.loaderData.dataPackLoaders.includes(category)
|
||||
})
|
||||
return tags.loaderData.dataPackLoaders.includes(category);
|
||||
});
|
||||
|
||||
if (isDataPack) {
|
||||
return 'datapack'
|
||||
return "datapack";
|
||||
} else if (isPlugin) {
|
||||
return 'plugin'
|
||||
return "plugin";
|
||||
} else if (isMod) {
|
||||
return 'mod'
|
||||
return "mod";
|
||||
} else {
|
||||
return 'mod'
|
||||
return "mod";
|
||||
}
|
||||
} else {
|
||||
return type
|
||||
return type;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const getProjectLink = (project) => {
|
||||
return `/${getProjectTypeForUrl(project.project_type, project.loaders)}/${
|
||||
project.slug ? project.slug : project.id
|
||||
}`
|
||||
}
|
||||
}`;
|
||||
};
|
||||
|
||||
export const getVersionLink = (project, version) => {
|
||||
if (version) {
|
||||
return getProjectLink(project) + '/version/' + version.id
|
||||
return getProjectLink(project) + "/version/" + version.id;
|
||||
} else {
|
||||
return getProjectLink(project)
|
||||
return getProjectLink(project);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const isApproved = (project) => {
|
||||
return project && APPROVED_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && APPROVED_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isListed = (project) => {
|
||||
return project && LISTED_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && LISTED_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isUnlisted = (project) => {
|
||||
return project && UNLISTED_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && UNLISTED_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isPrivate = (project) => {
|
||||
return project && PRIVATE_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && PRIVATE_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isRejected = (project) => {
|
||||
return project && REJECTED_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && REJECTED_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isUnderReview = (project) => {
|
||||
return project && UNDER_REVIEW_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && UNDER_REVIEW_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const isDraft = (project) => {
|
||||
return project && DRAFT_PROJECT_STATUSES.includes(project.status)
|
||||
}
|
||||
return project && DRAFT_PROJECT_STATUSES.includes(project.status);
|
||||
};
|
||||
|
||||
export const APPROVED_PROJECT_STATUSES = ['approved', 'archived', 'unlisted', 'private']
|
||||
export const LISTED_PROJECT_STATUSES = ['approved', 'archived']
|
||||
export const UNLISTED_PROJECT_STATUSES = ['unlisted', 'withheld']
|
||||
export const PRIVATE_PROJECT_STATUSES = ['private', 'rejected', 'processing']
|
||||
export const REJECTED_PROJECT_STATUSES = ['rejected', 'withheld']
|
||||
export const UNDER_REVIEW_PROJECT_STATUSES = ['processing']
|
||||
export const DRAFT_PROJECT_STATUSES = ['draft']
|
||||
export const APPROVED_PROJECT_STATUSES = ["approved", "archived", "unlisted", "private"];
|
||||
export const LISTED_PROJECT_STATUSES = ["approved", "archived"];
|
||||
export const UNLISTED_PROJECT_STATUSES = ["unlisted", "withheld"];
|
||||
export const PRIVATE_PROJECT_STATUSES = ["private", "rejected", "processing"];
|
||||
export const REJECTED_PROJECT_STATUSES = ["rejected", "withheld"];
|
||||
export const UNDER_REVIEW_PROJECT_STATUSES = ["processing"];
|
||||
export const DRAFT_PROJECT_STATUSES = ["draft"];
|
||||
|
||||
export function getVersionsToDisplay(project, overrideTags) {
|
||||
const tags = overrideTags ?? useTags().value
|
||||
const tags = overrideTags ?? useTags().value;
|
||||
|
||||
const projectVersions = project.game_versions.slice()
|
||||
const allVersions = tags.gameVersions.slice()
|
||||
const projectVersions = project.game_versions.slice();
|
||||
const allVersions = tags.gameVersions.slice();
|
||||
|
||||
const allSnapshots = allVersions.filter((version) => version.version_type === 'snapshot')
|
||||
const allReleases = allVersions.filter((version) => version.version_type === 'release')
|
||||
const allSnapshots = allVersions.filter((version) => version.version_type === "snapshot");
|
||||
const allReleases = allVersions.filter((version) => version.version_type === "release");
|
||||
const allLegacy = allVersions.filter(
|
||||
(version) => version.version_type !== 'snapshot' && version.version_type !== 'release'
|
||||
)
|
||||
(version) => version.version_type !== "snapshot" && version.version_type !== "release",
|
||||
);
|
||||
|
||||
{
|
||||
const indices = allVersions.reduce((map, gameVersion, index) => {
|
||||
map[gameVersion.version] = index
|
||||
return map
|
||||
}, {})
|
||||
projectVersions.sort((a, b) => indices[a] - indices[b])
|
||||
map[gameVersion.version] = index;
|
||||
return map;
|
||||
}, {});
|
||||
projectVersions.sort((a, b) => indices[a] - indices[b]);
|
||||
}
|
||||
|
||||
const releaseVersions = projectVersions.filter((projVer) =>
|
||||
allReleases.some((gameVer) => gameVer.version === projVer)
|
||||
)
|
||||
allReleases.some((gameVer) => gameVer.version === projVer),
|
||||
);
|
||||
|
||||
const latestReleaseVersionDate = Date.parse(
|
||||
allReleases.find((version) => version.version === releaseVersions[0])?.date
|
||||
)
|
||||
allReleases.find((version) => version.version === releaseVersions[0])?.date,
|
||||
);
|
||||
const latestSnapshot = projectVersions.find((projVer) =>
|
||||
allSnapshots.some(
|
||||
(gameVer) =>
|
||||
gameVer.version === projVer &&
|
||||
(!latestReleaseVersionDate || latestReleaseVersionDate < Date.parse(gameVer.date))
|
||||
)
|
||||
)
|
||||
(!latestReleaseVersionDate || latestReleaseVersionDate < Date.parse(gameVer.date)),
|
||||
),
|
||||
);
|
||||
|
||||
const allReleasesGrouped = groupVersions(
|
||||
allReleases.map((release) => release.version),
|
||||
false
|
||||
)
|
||||
const projectVersionsGrouped = groupVersions(releaseVersions, true)
|
||||
false,
|
||||
);
|
||||
const projectVersionsGrouped = groupVersions(releaseVersions, true);
|
||||
|
||||
const releaseVersionsAsRanges = projectVersionsGrouped.map(({ major, minor }) => {
|
||||
if (minor.length === 1) {
|
||||
return formatVersion(major, minor[0])
|
||||
return formatVersion(major, minor[0]);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -133,120 +134,121 @@ export function getVersionsToDisplay(project, overrideTags) {
|
||||
.find((x) => x.major === major)
|
||||
.minor.every((value, index) => value === minor[index])
|
||||
) {
|
||||
return `${major}.x`
|
||||
return `${major}.x`;
|
||||
}
|
||||
|
||||
return `${formatVersion(major, minor[0])}–${formatVersion(major, minor[minor.length - 1])}`
|
||||
})
|
||||
return `${formatVersion(major, minor[0])}–${formatVersion(major, minor[minor.length - 1])}`;
|
||||
});
|
||||
|
||||
const legacyVersionsAsRanges = groupConsecutiveIndices(
|
||||
projectVersions.filter((projVer) => allLegacy.some((gameVer) => gameVer.version === projVer)),
|
||||
allLegacy
|
||||
)
|
||||
allLegacy,
|
||||
);
|
||||
|
||||
let output = [...legacyVersionsAsRanges]
|
||||
let output = [...legacyVersionsAsRanges];
|
||||
|
||||
// show all snapshots if there's no release versions
|
||||
if (releaseVersionsAsRanges.length === 0) {
|
||||
const snapshotVersionsAsRanges = groupConsecutiveIndices(
|
||||
projectVersions.filter((projVer) =>
|
||||
allSnapshots.some((gameVer) => gameVer.version === projVer)
|
||||
allSnapshots.some((gameVer) => gameVer.version === projVer),
|
||||
),
|
||||
allSnapshots
|
||||
)
|
||||
output = [...snapshotVersionsAsRanges, ...output]
|
||||
allSnapshots,
|
||||
);
|
||||
output = [...snapshotVersionsAsRanges, ...output];
|
||||
} else {
|
||||
output = [...releaseVersionsAsRanges, ...output]
|
||||
output = [...releaseVersionsAsRanges, ...output];
|
||||
}
|
||||
|
||||
if (latestSnapshot) {
|
||||
output = [latestSnapshot, ...output]
|
||||
output = [latestSnapshot, ...output];
|
||||
}
|
||||
return output
|
||||
return output;
|
||||
}
|
||||
|
||||
const mcVersionRegex = /^([0-9]+.[0-9]+)(.[0-9]+)?$/
|
||||
const mcVersionRegex = /^([0-9]+.[0-9]+)(.[0-9]+)?$/;
|
||||
|
||||
function groupVersions(versions, consecutive = false) {
|
||||
return versions
|
||||
.slice()
|
||||
.reverse()
|
||||
.reduce((ranges, version) => {
|
||||
const matchesVersion = version.match(mcVersionRegex)
|
||||
const matchesVersion = version.match(mcVersionRegex);
|
||||
|
||||
if (matchesVersion) {
|
||||
const majorVersion = matchesVersion[1]
|
||||
const minorVersion = matchesVersion[2]
|
||||
const minorNumeric = minorVersion ? parseInt(minorVersion.replace('.', '')) : 0
|
||||
const majorVersion = matchesVersion[1];
|
||||
const minorVersion = matchesVersion[2];
|
||||
const minorNumeric = minorVersion ? parseInt(minorVersion.replace(".", "")) : 0;
|
||||
|
||||
let prevInRange
|
||||
let prevInRange;
|
||||
if (
|
||||
(prevInRange = ranges.find(
|
||||
(x) => x.major === majorVersion && (!consecutive || x.minor.at(-1) === minorNumeric - 1)
|
||||
(x) =>
|
||||
x.major === majorVersion && (!consecutive || x.minor.at(-1) === minorNumeric - 1),
|
||||
))
|
||||
) {
|
||||
prevInRange.minor.push(minorNumeric)
|
||||
return ranges
|
||||
prevInRange.minor.push(minorNumeric);
|
||||
return ranges;
|
||||
}
|
||||
|
||||
return [...ranges, { major: majorVersion, minor: [minorNumeric] }]
|
||||
return [...ranges, { major: majorVersion, minor: [minorNumeric] }];
|
||||
}
|
||||
|
||||
return ranges
|
||||
return ranges;
|
||||
}, [])
|
||||
.reverse()
|
||||
.reverse();
|
||||
}
|
||||
|
||||
function groupConsecutiveIndices(versions, referenceList) {
|
||||
if (!versions || versions.length === 0) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
|
||||
const referenceMap = new Map()
|
||||
const referenceMap = new Map();
|
||||
referenceList.forEach((item, index) => {
|
||||
referenceMap.set(item.version, index)
|
||||
})
|
||||
referenceMap.set(item.version, index);
|
||||
});
|
||||
|
||||
const sortedList = versions.slice().sort((a, b) => referenceMap.get(a) - referenceMap.get(b))
|
||||
const sortedList = versions.slice().sort((a, b) => referenceMap.get(a) - referenceMap.get(b));
|
||||
|
||||
const ranges = []
|
||||
let start = sortedList[0]
|
||||
let previous = sortedList[0]
|
||||
const ranges = [];
|
||||
let start = sortedList[0];
|
||||
let previous = sortedList[0];
|
||||
|
||||
for (let i = 1; i < sortedList.length; i++) {
|
||||
const current = sortedList[i]
|
||||
const current = sortedList[i];
|
||||
if (referenceMap.get(current) !== referenceMap.get(previous) + 1) {
|
||||
ranges.push(validateRange(`${previous}–${start}`))
|
||||
start = current
|
||||
ranges.push(validateRange(`${previous}–${start}`));
|
||||
start = current;
|
||||
}
|
||||
previous = current
|
||||
previous = current;
|
||||
}
|
||||
|
||||
ranges.push(validateRange(`${previous}–${start}`))
|
||||
ranges.push(validateRange(`${previous}–${start}`));
|
||||
|
||||
return ranges
|
||||
return ranges;
|
||||
}
|
||||
|
||||
function validateRange(range) {
|
||||
switch (range) {
|
||||
case 'rd-132211–b1.8.1':
|
||||
return 'All legacy versions'
|
||||
case 'a1.0.4–b1.8.1':
|
||||
return 'All alpha and beta versions'
|
||||
case 'a1.0.4–a1.2.6':
|
||||
return 'All alpha versions'
|
||||
case 'b1.0–b1.8.1':
|
||||
return 'All beta versions'
|
||||
case 'rd-132211–inf20100618':
|
||||
return 'All pre-alpha versions'
|
||||
case "rd-132211–b1.8.1":
|
||||
return "All legacy versions";
|
||||
case "a1.0.4–b1.8.1":
|
||||
return "All alpha and beta versions";
|
||||
case "a1.0.4–a1.2.6":
|
||||
return "All alpha versions";
|
||||
case "b1.0–b1.8.1":
|
||||
return "All beta versions";
|
||||
case "rd-132211–inf20100618":
|
||||
return "All pre-alpha versions";
|
||||
}
|
||||
const splitRange = range.split('–')
|
||||
const splitRange = range.split("–");
|
||||
if (splitRange && splitRange[0] === splitRange[1]) {
|
||||
return splitRange[0]
|
||||
return splitRange[0];
|
||||
}
|
||||
return range
|
||||
return range;
|
||||
}
|
||||
|
||||
function formatVersion(major, minor) {
|
||||
return minor === 0 ? major : `${major}.${minor}`
|
||||
return minor === 0 ? major : `${major}.${minor}`;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
/* eslint-disable no-undef */
|
||||
export const acceptTeamInvite = async (teamId) => {
|
||||
await useBaseFetch(`team/${teamId}/join`, {
|
||||
apiVersion: 3,
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
method: "POST",
|
||||
});
|
||||
};
|
||||
export const removeSelfFromTeam = async (teamId) => {
|
||||
const auth = await useAuth()
|
||||
await removeTeamMember(teamId, auth.value.user.id)
|
||||
}
|
||||
const auth = await useAuth();
|
||||
await removeTeamMember(teamId, auth.value.user.id);
|
||||
};
|
||||
export const removeTeamMember = async (teamId, userId) => {
|
||||
await useBaseFetch(`team/${teamId}/members/${userId}`, {
|
||||
apiVersion: 3,
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
export function addReportMessage(thread, report) {
|
||||
if (!thread || !report) {
|
||||
return thread
|
||||
return thread;
|
||||
}
|
||||
if (
|
||||
!thread.members.some((user) => {
|
||||
return user.id === report.reporterUser.id
|
||||
return user.id === report.reporterUser.id;
|
||||
})
|
||||
) {
|
||||
thread.members.push(report.reporterUser)
|
||||
thread.members.push(report.reporterUser);
|
||||
}
|
||||
if (!thread.messages.some((message) => message.id === 'original')) {
|
||||
if (!thread.messages.some((message) => message.id === "original")) {
|
||||
thread.messages.push({
|
||||
id: 'original',
|
||||
id: "original",
|
||||
author_id: report.reporterUser.id,
|
||||
body: {
|
||||
type: 'text',
|
||||
type: "text",
|
||||
body: report.body,
|
||||
private: false,
|
||||
replying_to: null,
|
||||
},
|
||||
created: report.created,
|
||||
})
|
||||
});
|
||||
}
|
||||
return thread
|
||||
return thread;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export const getUserLink = (user) => {
|
||||
return `/user/${user.username}`
|
||||
}
|
||||
return `/user/${user.username}`;
|
||||
};
|
||||
|
||||
export const isStaff = (user) => {
|
||||
return user && STAFF_ROLES.includes(user.role)
|
||||
}
|
||||
return user && STAFF_ROLES.includes(user.role);
|
||||
};
|
||||
|
||||
export const STAFF_ROLES = ['moderator', 'admin']
|
||||
export const STAFF_ROLES = ["moderator", "admin"];
|
||||
|
||||
Reference in New Issue
Block a user