Skip to content

Commit

Permalink
Merge branch 'main' into 0.8.0-beta-fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Geometrically <[email protected]>
  • Loading branch information
Geometrically authored Aug 14, 2024
2 parents dffd22b + c7d8c8b commit 8db6bb5
Show file tree
Hide file tree
Showing 36 changed files with 519 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1-app-bug.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🎮 Modrinth App bug
description: Report an issue on the Modrinth website.
description: Report an issue in the Modrinth Launcher.
labels: [bug, app]
body:
- type: checkboxes
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/3-api-bug.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🛠️ API issue (api.modrinth.com)
description: Report an issue on the Modrinth website.
description: Report an issue regarding the Modrinth API.
labels: [bug, api]
body:
- type: checkboxes
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/frontend-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ jobs:
accountId: '9ddae624c98677d68d93df6e524a6061'
project: 'frontend'
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitHash: ${{ steps.push-changes.outputs.commit-hash }}
commitHash: ${{ steps.push-changes.outputs.commit-hash }}
- name: Purge cache
if: github.ref == 'refs/heads/main'
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.CF_API_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{"hosts": ["modrinth.com", "www.modrinth.com"]}' \
https://api.cloudflare.com/client/v4/zones/e39df17b9c4ef44cbce2646346ee6d33/purge_cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If you discover a security vulnerability within our codebase, please follow our

## Support

If you need help with the Modrinth web interface or app, please visit our [support page](https://support.modrinth.com). For general inquiries, you can also join our [Discord server](https://discord.gg/modrinth).
If you need help with the Modrinth web interface or app, please visit our [support page](https://support.modrinth.com). For general inquiries, you can also join our [Discord server](https://discord.modrinth.com).

## License

Expand Down
6 changes: 5 additions & 1 deletion apps/app-frontend/src/components/ui/ErrorModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function retryDirectoryChange() {
</div>
<div class="input-group push-right">
<a :href="supportLink" class="btn" @click="errorModal.hide()"><ChatIcon /> Get support</a>
<button v-if="closable" class="btn" @clicdck="errorModal.hide()"><XIcon /> Close</button>
<button v-if="closable" class="btn" @click="errorModal.hide()"><XIcon /> Close</button>
</div>
</div>
</Modal>
Expand Down Expand Up @@ -297,4 +297,8 @@ function retryDirectoryChange() {
gap: var(--gap-md);
padding: var(--gap-lg);
}

.markdown-body {
overflow: auto;
}
</style>
2 changes: 1 addition & 1 deletion apps/frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: ["custom/nuxt"],
extends: ["../../packages/eslint-config-custom/nuxt.js"],
};
42 changes: 33 additions & 9 deletions apps/frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export default defineNuxtConfig({
gameVersions?: any[];
donationPlatforms?: any[];
reportTypes?: any[];
homePageProjects?: any[];
homePageSearch?: any[];
homePageNotifs?: any[];
} = {};

try {
Expand Down Expand Up @@ -153,21 +156,34 @@ export default defineNuxtConfig({
},
};

const [categories, loaders, gameVersions, donationPlatforms, reportTypes] = await Promise.all(
[
$fetch(`${API_URL}tag/category`, headers),
$fetch(`${API_URL}tag/loader`, headers),
$fetch(`${API_URL}tag/game_version`, headers),
$fetch(`${API_URL}tag/donation_platform`, headers),
$fetch(`${API_URL}tag/report_type`, headers),
],
);
const [
categories,
loaders,
gameVersions,
donationPlatforms,
reportTypes,
homePageProjects,
homePageSearch,
homePageNotifs,
] = await Promise.all([
$fetch(`${API_URL}tag/category`, headers),
$fetch(`${API_URL}tag/loader`, headers),
$fetch(`${API_URL}tag/game_version`, headers),
$fetch(`${API_URL}tag/donation_platform`, headers),
$fetch(`${API_URL}tag/report_type`, headers),
$fetch(`${API_URL}projects_random?count=60`, headers),
$fetch(`${API_URL}search?limit=3&query=leave&index=relevance`, headers),
$fetch(`${API_URL}search?limit=3&query=&index=updated`, headers),
]);

state.categories = categories;
state.loaders = loaders;
state.gameVersions = gameVersions;
state.donationPlatforms = donationPlatforms;
state.reportTypes = reportTypes;
state.homePageProjects = homePageProjects;
state.homePageSearch = homePageSearch;
state.homePageNotifs = homePageNotifs;

await fs.writeFile("./src/generated/state.json", JSON.stringify(state));

Expand Down Expand Up @@ -392,6 +408,14 @@ export default defineNuxtConfig({
autoprefixer: {},
},
},
routeRules: {
"/**": {
headers: {
"Accept-CH": "Sec-CH-Prefers-Color-Scheme",
"Critical-CH": "Sec-CH-Prefers-Color-Scheme",
},
},
},
compatibilityDate: "2024-07-03",
});

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/ui/charts/ChartDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<div
:style="{
'--color-brand': isUsingProjectColors
? intToRgba(project.color, project.id, theme ?? undefined)
? intToRgba(project.color, project.id, theme.active ?? undefined)
: getDefaultColor(project.id),
}"
class="legend__item__color"
Expand Down
13 changes: 0 additions & 13 deletions apps/frontend/src/composables/auto-ref.ts

This file was deleted.

52 changes: 0 additions & 52 deletions apps/frontend/src/composables/cosmetics.js

This file was deleted.

13 changes: 7 additions & 6 deletions apps/frontend/src/composables/display-names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useAutoRef, type AutoRef } from "./auto-ref.ts";

const safeTags = new Map<string, string>();

function safeTagFor(locale: string) {
Expand Down Expand Up @@ -81,11 +79,14 @@ export function createDisplayNames(
}

export function useDisplayNames(
locale: AutoRef<string>,
options?: AutoRef<Intl.DisplayNamesOptions | undefined>,
locale: string | (() => string) | Ref<string>,
options?:
| (Intl.DisplayNamesOptions | undefined)
| (() => Intl.DisplayNamesOptions | undefined)
| Ref<Intl.DisplayNamesOptions | undefined>,
) {
const $locale = useAutoRef(locale);
const $options = useAutoRef(options);
const $locale = toRef(locale);
const $options = toRef(options);

return computed(() => createDisplayNames($locale.value, $options.value));
}
7 changes: 7 additions & 0 deletions apps/frontend/src/composables/nuxt-accessors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function useTheme() {
return useNuxtApp().$theme;
}

export function useCosmetics() {
return useNuxtApp().$cosmetics;
}
58 changes: 0 additions & 58 deletions apps/frontend/src/composables/theme.js

This file was deleted.

14 changes: 14 additions & 0 deletions apps/frontend/src/composables/vue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Creates a computed reference that uses a provide getter function called with an argument representing the current mount state of the component.
* @param getter A getter function that will run with `mounted` argument representing whether or not the component is mounted.
* @returns A computed reference that changes when component becomes mounted or unmounted.
*/
export function useMountedValue<T>(getter: (isMounted: boolean) => T) {
const mounted = ref(getCurrentInstance()?.isMounted ?? false);

onMounted(() => (mounted.value = true));

onUnmounted(() => (mounted.value = false));

return computed(() => getter(mounted.value));
}
62 changes: 38 additions & 24 deletions apps/frontend/src/helpers/infer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TOML from "@ltd/j-toml";
import { parse as parseTOML } from "@ltd/j-toml";
import JSZip from "jszip";
import yaml from "js-yaml";
import { satisfies } from "semver";
Expand Down Expand Up @@ -95,9 +95,43 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
.map((it) => it.version);

const inferFunctions = {
// Forge 1.13+ and NeoForge
// NeoForge
"META-INF/neoforge.mods.toml": (file) => {
const metadata = parseTOML(file, { joiner: "\n" });
if (!metadata.mods || metadata.mods.length === 0) {
return {};
}

const neoForgeDependency = Object.values(metadata.dependencies)
.flat()
.find((dependency) => dependency.modId === "neoforge");
if (!neoForgeDependency) {
return {};
}

// https://docs.neoforged.net/docs/gettingstarted/versioning/#neoforge
const mcVersionRange = neoForgeDependency.versionRange
.replace("-beta", "")
.replace(/(\d+)(?:\.(\d+))?(?:\.(\d+)?)?/g, (_match, major, minor) => {
return `1.${major}${minor ? "." + minor : ""}`;
});
const gameVersions = getGameVersionsMatchingMavenRange(
mcVersionRange,
simplifiedGameVersions,
);

const versionNum = metadata.mods[0].version;
return {
name: `${project.title} ${versionNum}`,
version_number: versionNum,
loaders: ["neoforge"],
version_type: versionType(versionNum),
game_versions: gameVersions,
};
},
// Forge 1.13+
"META-INF/mods.toml": async (file, zip) => {
const metadata = TOML.parse(file, { joiner: "\n" }); // eslint-disable-line import/no-named-as-default-member
const metadata = parseTOML(file, { joiner: "\n" });

if (metadata.mods && metadata.mods.length > 0) {
let versionNum = metadata.mods[0].version;
Expand Down Expand Up @@ -130,31 +164,11 @@ export const inferVersionInfo = async function (rawFile, project, gameVersions)
);
}

const hasNeoForge =
Object.values(metadata.dependencies)
.flat()
.filter((dependency) => dependency.modId === "neoforge").length > 0;

const hasForge =
Object.values(metadata.dependencies)
.flat()
.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 isOlderThan1202 = below1202.some((r) => gameVersions.includes(r));

const loaders = [];

if (hasNeoForge) loaders.push("neoforge");
if (hasForge || isOlderThan1202) loaders.push("forge");

return {
name: `${project.title} ${versionNum}`,
version_number: versionNum,
version_type: versionType(versionNum),
loaders,
loaders: ["forge"],
game_versions: gameVersions,
};
} else {
Expand Down
Loading

0 comments on commit 8db6bb5

Please sign in to comment.